Example usage for java.lang Float toString

List of usage examples for java.lang Float toString

Introduction

In this page you can find the example usage for java.lang Float toString.

Prototype

public static String toString(float f) 

Source Link

Document

Returns a string representation of the float argument.

Usage

From source file:org.apache.tez.dag.app.web.AMWebController.java

private Map<String, Object> getVertexInfoMap(Vertex vertex, Map<String, Set<String>> counterNames) {
    Map<String, Object> vertexInfo = new HashMap<String, Object>();
    vertexInfo.put("id", vertex.getVertexId().toString());
    vertexInfo.put("status", vertex.getState().toString());
    vertexInfo.put("progress", Float.toString(vertex.getCompletedTaskProgress()));

    vertexInfo.put("initTime", Long.toString(vertex.getInitTime()));
    vertexInfo.put("startTime", Long.toString(vertex.getStartTime()));
    vertexInfo.put("finishTime", Long.toString(vertex.getFinishTime()));
    vertexInfo.put("firstTaskStartTime", Long.toString(vertex.getFirstTaskStartTime()));
    vertexInfo.put("lastTaskFinishTime", Long.toString(vertex.getLastTaskFinishTime()));

    ProgressBuilder vertexProgress = vertex.getVertexProgress();
    vertexInfo.put("totalTasks", Integer.toString(vertexProgress.getTotalTaskCount()));
    vertexInfo.put("runningTasks", Integer.toString(vertexProgress.getRunningTaskCount()));
    vertexInfo.put("succeededTasks", Integer.toString(vertexProgress.getSucceededTaskCount()));

    vertexInfo.put("failedTaskAttempts", Integer.toString(vertexProgress.getFailedTaskAttemptCount()));
    vertexInfo.put("killedTaskAttempts", Integer.toString(vertexProgress.getKilledTaskAttemptCount()));

    try {//www  . j a v  a  2 s . com
        if (counterNames != null && !counterNames.isEmpty()) {
            TezCounters counters = vertex.getCachedCounters();
            Map<String, Map<String, Long>> counterMap = constructCounterMapInfo(counters, counterNames);
            if (counterMap != null && !counterMap.isEmpty()) {
                vertexInfo.put("counters", counterMap);
            }
        }
    } catch (LimitExceededException e) {
        // Ignore
        // TODO: add an error message instead for counter key
    }

    return vertexInfo;
}

From source file:co.foldingmap.mapImportExport.SvgExporter.java

private void writeSvgLine(BufferedWriter outputStream, String id, CoordinateList<Coordinate> coordinates,
        ColorStyle style, boolean isOutline) {
    Coordinate c;/*from w w w  .  ja v  a 2s  .c o m*/
    String styleString;

    try {
        styleString = generateLineStyleString(style, isOutline);

        addIndent();
        outputStream.write(getIndent());
        outputStream.write("<polyline points=\"");

        for (int i = 0; i < coordinates.size(); i++) {
            c = coordinates.get(i);

            outputStream.write(Float.toString(c.getCenterPoint().x));
            outputStream.write(",");
            outputStream.write(Float.toString(c.getCenterPoint().y));

            if (i + 1 < coordinates.size())
                outputStream.write(" ");
        }

        outputStream.write("\"\n");
        outputStream.write(getIndent());
        outputStream.write("style=\"");
        outputStream.write(styleString);
        outputStream.write("\" />\n");
        removeIndent();
    } catch (Exception e) {
        Logger.log(Logger.ERR,
                "Error in SvgExporter.writePolyLine(BufferedWriter, String, CoordinateList, ColorStyle - " + e);
    }
}

From source file:eu.europeana.uim.gui.cp.server.RetrievalServiceImpl.java

private EdmFieldRecordDTO createSolrFields(QueryResponse response) {
    EdmFieldRecordDTO solrFields = new EdmFieldRecordDTO();
    SolrDocument doc = response.getResults().get(0);
    List<FieldValueDTO> fieldValues = new ArrayList<FieldValueDTO>();
    for (Entry<String, Object> entry : doc.entrySet()) {
        FieldValueDTO fieldValue = new FieldValueDTO();
        List<String> values = new ArrayList<String>();
        fieldValue.setFieldName(entry.getKey());
        if (entry.getValue() instanceof ArrayList) {
            for (Object obj : (ArrayList<Object>) entry.getValue()) {
                values.add(obj.toString());
            }/*  w  w w . j a  va2s .  co m*/
        }
        if (entry.getValue() instanceof String) {
            values.add((String) entry.getValue());
        }
        if (entry.getValue() instanceof Float) {
            values.add(Float.toString((Float) entry.getValue()));
        }
        if (entry.getValue() instanceof String[]) {
            for (String str : (String[]) entry.getValue()) {
                values.add(str);
            }
        }
        if (entry.getValue() instanceof Date) {
            values.add(((Date) entry.getValue()).toString());
        }
        fieldValue.setFieldValue(values);
        fieldValues.add(fieldValue);
    }
    solrFields.setFieldValue(fieldValues);
    return solrFields;
}

From source file:edu.umd.gorden2.RunPersonalizedPageRankBasic.java

private void phase2(int i, int j, float[] missing, String basePath, int numNodes, String m) throws Exception {
    Job job = Job.getInstance(getConf());
    job.setJobName("PageRank:Basic:iteration" + j + ":Phase2");
    job.setJarByClass(RunPersonalizedPageRankBasic.class);

    LOG.info("missing PageRank mass: " + Arrays.toString(missing));
    LOG.info("number of nodes: " + numNodes);

    String in = basePath + "/iter" + formatter.format(j) + "t";
    String out = basePath + "/iter" + formatter.format(j);

    LOG.info("PageRank: iteration " + j + ": Phase2");
    LOG.info(" - input: " + in);
    LOG.info(" - output: " + out);

    String missings = Float.toString(missing[0]);
    for (int x = 1; x < missing.length; x++) {
        missings = missings + "," + Float.toString(missing[x]);
    }// ww w  .j  a va2  s  .  c  o  m

    job.getConfiguration().setBoolean("mapred.map.tasks.speculative.execution", false);
    job.getConfiguration().setBoolean("mapred.reduce.tasks.speculative.execution", false);
    job.getConfiguration().setStrings("MissingMass", missings);
    job.getConfiguration().setInt("NodeCount", numNodes);
    job.getConfiguration().setStrings("sources", m);

    job.setNumReduceTasks(0);

    FileInputFormat.setInputPaths(job, new Path(in));
    FileOutputFormat.setOutputPath(job, new Path(out));

    job.setInputFormatClass(NonSplitableSequenceFileInputFormat.class);
    job.setOutputFormatClass(SequenceFileOutputFormat.class);

    job.setMapOutputKeyClass(IntWritable.class);
    job.setMapOutputValueClass(PageRankNode.class);

    job.setOutputKeyClass(IntWritable.class);
    job.setOutputValueClass(PageRankNode.class);

    job.setMapperClass(MapPageRankMassDistributionClass.class);

    FileSystem.get(getConf()).delete(new Path(out), true);

    long startTime = System.currentTimeMillis();
    job.waitForCompletion(true);
    System.out.println("Job Finished in " + (System.currentTimeMillis() - startTime) / 1000.0 + " seconds");
}

From source file:investiagenofx2.view.InvestiaGenOFXController.java

private void getTransactionsFromWeb() {
    try {//from w  w w .j a va  2  s.  c om
        if (!htmlPage.getUrl().toString().contains("/TransactionReports/Select")) {
            if (InvestiaGenOFX.debug) {
                htmlPage = InvestiaGenOFX.getWebClient()
                        .getPage(InvestiaGenOFX.debugFullPath + "-Transactions.htm");
            } else {
                htmlPage = InvestiaGenOFX.getWebClient()
                        .getPage(txt_investiaURL.getText() + "/TransactionReports/Select" + "?wcag=true");
                waitForGeneratedTransactions();
            }
        }
        @SuppressWarnings(("unchecked"))
        List<HtmlHeading4> h4from = (List<HtmlHeading4>) htmlPage
                .getByXPath("//h4[contains(text(),'Priode: de ')]");
        String from = h4from.get(0).asText();
        int index = from.indexOf("Priode: de ");
        LocalDate selFromDate = LocalDate.parse(from.substring(index + 12, index + 12 + 10));

        if (dtp_lastDate.getValue().isBefore(selFromDate)) {
            @SuppressWarnings(("unchecked"))
            List<HtmlForm> forms = (List<HtmlForm>) htmlPage.getByXPath("//form");
            HtmlForm form = forms.get(1);
            HtmlTextInput selPerFrom = form.getInputByName("selPerFrom");
            selPerFrom.setValueAttribute(dtp_lastDate.getValue().toString());

            HtmlAnchor generate = (HtmlAnchor) form.getByXPath("//a[contains(@class, 'btn-investia-blue')]")
                    .get(0);
            if (InvestiaGenOFX.debug) {
                htmlPage = InvestiaGenOFX.getWebClient()
                        .getPage(InvestiaGenOFX.debugFullPath + "-Transactions.htm");
            } else {
                htmlPage = generate.click();
                waitForGeneratedTransactions();
            }
        }

        HtmlTable htmlTable = (HtmlTable) htmlPage.getElementById("tblTransactionReports");
        if (htmlTable == null) {
            return;
        }
        for (int i = 0; i < htmlTable.getRowCount(); i++) {
            LocalDate transacDate = LocalDate.parse(htmlTable.getCellAt(i, 0).getTextContent(),
                    DateTimeFormatter.ofPattern("dd MMM yyyy", Locale.CANADA_FRENCH));
            if (transacDate.isBefore(dtp_lastDate.getValue())) {
                break;
            }
            String transacType = htmlTable.getCellAt(i, 2).getTextContent();
            String[] token = transacType.split("[\\-/(]");
            switch (token[0].replace(" ", "")) {
            case "Dividendes":
                transacType = "Distribution";
                break;
            case "Achat":
            case "changeentrant":
            case "Prlvementautomatique":
            case "Transfertentrantdecourtier":
            case "Transfertexterneentrant":
            case "Transfertinterneentrant":
                transacType = "Purchase";
                break;
            case "changesortant":
            case "Rachat":
            case "Transfertexternesortant":
            case "Transf.int.sort.":
            case "Transf.Int.sortant":
            case "Transfertinternesortant":
                transacType = "Switch Out";
                break;
            case "Dpt":
                transacType = "Credit";
                break;
            case "Retrait":
            case "Retenue":
                transacType = "Debit";
                break;
            case "Crditenespces":
            case "Entred'espces":
            case "Fraisd'administration":
            case "Sortied'espces":
            case "Transfertd'espcesentrant":
            case "Transfertd'espcessortant":
                continue;
            default:
                try {
                    throw new MyOwnException("Type de transaction non prise en charge: " + transacType.trim());
                } catch (MyOwnException ex) {
                    Logger.getLogger(OFXUtilites.class.getName()).log(Level.SEVERE, null, ex);
                    continue;
                }
            }

            String transacAccount = accountOwnerName.split(" ")[0] + "\\"
                    + htmlTable.getCellAt(i, 1).getTextContent();
            String symbol = htmlTable.getCellAt(i, 3).getTextContent();
            String unit = htmlTable.getCellAt(i, 5).getTextContent().replaceAll("[^0-9,]", "").replace(",",
                    ".");
            String fitid = "";
            String price = "0.00";
            String amount;
            if ("Credit".equals(transacType) || "Debit".equals(transacType)) {
                amount = htmlTable.getCellAt(i, 9).getTextContent().replaceAll("[^0-9,]", "").replace(",", ".");
                fitid = StringUtils.stripAccents(htmlTable.getCellAt(i, 2).getTextContent());
            } else {
                amount = htmlTable.getCellAt(i, 10).getTextContent().replaceAll("[^0-9,]", "").replace(",",
                        ".");
                price = Float.toString(Float.parseFloat(amount) / Float.parseFloat(unit));
            }
            if (PropertiesInit.getLinkAccountsTransac().indexOf(transacAccount) < 0) {
                linkAccountTransac(transacAccount);
            }
            int idxAccount = linkAccountToLocalAccountIndex[PropertiesInit.getLinkAccountsTransac()
                    .indexOf(transacAccount)];
            accounts.get(idxAccount)
                    .add(new Transaction(transacDate, transacType, amount, fitid, symbol, unit, price, ""));
        }
    } catch (Exception ex) {
        Logger.getLogger(InvestiaGenOFXController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:MetaFramework.Bayesian.java

/**
 * Checks if a chosen column can be used as differentiation point (has to be binary)
 * Idea: For now, it might as well give user a choice to set a threshold for differentiation
 *
 * @param dataset//from w  ww  .ja va  2s. co m
 * @param choice
 * @return
 */
public boolean checkForBinary(Dataset dataset, int choice) {
    Set<String> allValues = new HashSet<String>();

    float[][] data = dataset.getData();
    for (int i = 0; i < data.length; i++) {
        allValues.add(Float.toString(data[i][choice]));
    }

    System.out.println("Amount of different values : " + allValues.size());
    return allValues.size() <= 2; // Means, we can easily distinguish if needed.
    // And we make sure to use original data, not the processed one
}

From source file:com.skratchdot.electribe.model.esx.provider.SampleItemProvider.java

/**
 * This returns the column text for the adapted class.
 * <!-- begin-user-doc -->//from w ww  .  ja v a2s . c o m
 * <!-- end-user-doc -->
 */
@Override
public String getColumnText(Object object, int columnIndex) {
    switch (columnIndex) {
    // Esx#
    case 0:
        return ((Sample) object).getSampleNumberCurrent().toString();
    // Orig#
    case 1:
        return ((Sample) object).getSampleNumberOriginal().toString();
    // Name
    case 2:
        return ((Sample) object).getName();
    // MemSize
    case 3:
        return Integer.toString(((Sample) object).getMemUsedInBytes());
    // SampleRate
    case 4:
        return Integer.toString(((Sample) object).getSampleRate());
    // SampleTune
    case 5:
        return Float.toString(((Sample) object).getSampleTune().getValue());
    // StretchStep
    case 6:
        return ((Sample) object).getStretchStep().getLiteral();
    // IsLoop?
    case 7:
        return ((Sample) object).getLoopType().getLiteral();
    // IsSlice?
    case 8:
        return ((Sample) object).isSlice() ? getString("_UI_Display_Yes") : getString("_UI_Display_No");
    // PlayLevel
    case 9:
        return ((Sample) object).getPlayLevel().getLiteral();
    // Start
    case 10:
        return Integer.toString(((Sample) object).getStart());
    // LoopStart
    case 11:
        return Integer.toString(((Sample) object).getLoopStart());
    // End
    case 12:
        return Integer.toString(((Sample) object).getEnd());
    // NumSampleFrames
    case 13:
        return Integer.toString(((Sample) object).getNumberOfSampleFrames());
    // StereoOriginal
    case 14:
        return ((Sample) object).isStereoOriginal() ? getString("_UI_Display_Yes")
                : getString("_UI_Display_No");
    default:
        return getText(object);
    }
}

From source file:org.odk.collect.android.activities.GeoTraceOsmMapActivity.java

private void addLocationMarker() {
    if (myLocationOverlay.getMyLocation() != null) {
        Marker marker = new Marker(mapView);
        marker.setPosition(myLocationOverlay.getMyLocation());
        Float lastKnownAccuracy = myLocationOverlay.getMyLocationProvider().getLastKnownLocation()
                .getAccuracy();/*www . ja  v a 2s .c o  m*/
        myLocationOverlay.getMyLocationProvider().getLastKnownLocation().getAccuracy();
        marker.setIcon(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_place_black_36dp));
        marker.setSubDescription(Float.toString(lastKnownAccuracy));
        marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
        marker.setDraggable(true);
        marker.setOnMarkerDragListener(dragListener);
        mapMarkers.add(marker);

        marker.setOnMarkerClickListener(nullMarkerListener);
        mapView.getOverlays().add(marker);
        List<GeoPoint> points = polyline.getPoints();
        points.add(marker.getPosition());
        polyline.setPoints(points);
        mapView.invalidate();
    }
}

From source file:com.ratebeer.android.gui.fragments.BeerViewFragment.java

public void setOwnRating(ArrayList<BeerRating> ownRatings) {
    if (ownRatings == null) {
        // Still loading and we didn't have a retained rating object
        return;//from www  .  j a  v  a2 s  . com
    }
    if (ownRatings.size() > 0) {
        BeerRating ownRating = ownRatings.get(0);
        ownratinglabel.setVisibility(View.VISIBLE);
        ownratingRow.setVisibility(View.VISIBLE);
        ownratingTotal.setText(Float.toString(PostRatingCommand.calculateTotal(ownRating.aroma,
                ownRating.appearance, ownRating.flavor, ownRating.mouthfeel, ownRating.overall)));
        ownratingAroma.setText(Integer.toString(ownRating.aroma));
        ownratingAppearance.setText(Integer.toString(ownRating.appearance));
        ownratingTaste.setText(Integer.toString(ownRating.flavor));
        ownratingPalate.setText(Integer.toString(ownRating.mouthfeel));
        ownratingOverall.setText(Integer.toString(ownRating.overall));
        ownratingUsername.setText(ownRating.userName + " (" + Integer.toString(ownRating.rateCount) + ")");
        ownratingComments.setText(ownRating.comments
                + (ownRating.timeUpdated != null ? " (" + displayDateFormat.format(ownRating.timeUpdated) + ")"
                        : ownRating.timeEntered != null
                                ? " (" + displayDateFormat.format(ownRating.timeEntered) + ")"
                                : ""));
        rateThisButton.setText(R.string.details_viewrerate);
    } else {
        ownratinglabel.setVisibility(View.GONE);
        ownratingRow.setVisibility(View.GONE);
        rateThisButton.setText(R.string.details_ratethis);
    }
    rateThisButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            onRateBeerClick();
        }
    });
}

From source file:ca.uhn.hl7v2.model.primitive.tests.CommonTSTest.java

@Test
public void testSetDateSecondPrecision() {
    class TestSpec {
        int year;
        int month;
        int day;/*from w w  w . ja v a  2 s. c om*/
        int hour;
        int minute;
        float second;
        Object outcome;
        Exception exception = null;
        String retval;

        TestSpec(int year, int month, int day, int hour, int minute, float second, Object outcome) {
            this.year = year;
            this.month = month;
            this.day = day;
            this.hour = hour;
            this.minute = minute;
            this.second = second;
            this.outcome = outcome;
        }

        public String toString() {
            return "[ " + Integer.toString(year) + " " + Integer.toString(month) + " " + Integer.toString(day)
                    + " " + Integer.toString(hour) + " " + Integer.toString(minute) + " "
                    + Float.toString(second) + " : " + (outcome != null ? outcome : "null") + " : "
                    + (retval != null ? retval : "null")
                    + (exception != null ? " [ " + exception.toString() + " ]" : " ]");
        }

        public boolean executeTest() {
            CommonTS ts = new CommonTS();
            try {
                ts.setDateSecondPrecision(year, month, day, hour, minute, second);
                retval = ts.getValue();
                if (retval != null) {
                    return retval.equals(outcome);
                } else {
                    return outcome == null;
                }
            } catch (Exception e) {
                if (e.getClass().equals(outcome)) {
                    return true;
                } else {
                    this.exception = e;
                    return (e.getClass().equals(outcome));
                }
            }
        }
    }//inner class

    TestSpec[] tests = { new TestSpec(2001, -1, 1, 1, 1, 1.0F, DataTypeException.class),
            new TestSpec(2001, 1, -1, 1, 1, 1.0F, DataTypeException.class),
            new TestSpec(2001, 1, 1, -1, 1, 1.0F, DataTypeException.class),
            new TestSpec(2001, 1, 1, 1, -1, 1.0F, DataTypeException.class),
            new TestSpec(2001, 1, 1, 1, 1, -1.0F, DataTypeException.class),
            new TestSpec(9, 1, 1, 1, 1, 1.0F, DataTypeException.class),
            new TestSpec(99, 1, 1, 1, 1, 1.0F, DataTypeException.class),
            new TestSpec(999, 1, 1, 1, 1, 1.0F, DataTypeException.class),
            new TestSpec(1000, 1, 1, 1, 1, 1.0F, "10000101010101"),
            new TestSpec(1987, 1, 1, 0, 30, 1.1234F, "19870101003001.1234"),
            new TestSpec(2001, 0, 1, 1, 1, 1.0F, DataTypeException.class),
            new TestSpec(2001, 1, 0, 1, 1, 1.0F, DataTypeException.class),
            new TestSpec(2001, 1, 1, 1, 1, 0.0F, "20010101010100"),
            new TestSpec(2001, 1, 1, 1, 1, 1.12F, "20010101010101.12"),
            new TestSpec(2001, 1, 1, 1, 1, 12.12F, "20010101010112.12"),
            new TestSpec(2001, 1, 1, 1, 1, 123.12F, DataTypeException.class),
            new TestSpec(2001, 1, 1, 1, 1, 12.123F, "20010101010112.123"),
            new TestSpec(2001, 1, 1, 1, 1, 12.1234F, "20010101010112.1234"),
            new TestSpec(2001, 1, 1, 1, 1, 12.12345F, "20010101010112.1235"),
            new TestSpec(2001, 1, 1, 1, 1, 59.1234F, "20010101010159.1234"),
            new TestSpec(2001, 1, 1, 1, 1, 59.9999F, "20010101010159.9999"),
            new TestSpec(2001, 1, 1, 1, 1, 59.99999F, DataTypeException.class),
            new TestSpec(2001, 1, 1, 1, 1, 60.0F, DataTypeException.class),
            new TestSpec(2001, 1, 1, 1, 1, 1.12F, "20010101010101.12"),
            new TestSpec(2001, 1, 1, 0, 0, 23.456F, "20010101000023.456"),
            new TestSpec(2001, 1, 1, 8, 15, 1.0F, "20010101081501"),
            new TestSpec(2001, 1, 7, 13, 27, 1.0F, "20010107132701"),
            new TestSpec(2001, 1, 12, 23, 59, 1.0F, "20010112235901"),
            new TestSpec(2001, 1, 12, 23, 59, 1.0F, "20010112235901"),
            new TestSpec(2001, 1, 12, 23, 60, 1.0F, DataTypeException.class),
            new TestSpec(2001, 1, 12, 24, 59, 1.0F, DataTypeException.class),
            new TestSpec(2001, 1, 12, 24, 60, 1.0F, DataTypeException.class),
            new TestSpec(2001, 1, 25, 1, 1, 1.0F, "20010125010101"),
            new TestSpec(2001, 1, 31, 1, 1, 1.0F, "20010131010101"),
            new TestSpec(2001, 1, 32, 1, 1, 1.0F, DataTypeException.class),
            new TestSpec(9999, 1, 1, 1, 1, 1.0F, "99990101010101"),
            new TestSpec(10000, 1, 1, 1, 1, 1.0F, DataTypeException.class),
            new TestSpec(2001, 1, 1, 1, 1, 1.0F, "20010101010101"),
            new TestSpec(2001, -1, 21, 1, 1, 1.0F, DataTypeException.class), };

    ArrayList failedTests = new ArrayList();

    for (int i = 0; i < tests.length; i++) {
        if (!tests[i].executeTest())
            failedTests.add(tests[i]);
    }

    assertEquals("Failures: " + failedTests, 0, failedTests.size());
}