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:com.igormaznitsa.ideamindmap.facet.InMemoryPreferenceNode.java

@Override
public float getFloat(String key, float def) {
    final String value = get(key, Float.toString(def));
    try {//from   w  w w  .  ja  va2 s.  c om
        return Float.parseFloat(value);
    } catch (NumberFormatException ex) {
        return def;
    }
}

From source file:eu.itesla_project.online.tools.RunTDSimulation.java

private void writeCsvViolations(Path folder, Map<String, List<LimitViolation>> networksViolations)
        throws IOException {
    Path csvFile = getFile(folder, "networks-violations.csv");
    System.out.println("writing pre-contingency network violations to file " + csvFile.toString());
    try (FileWriter content = new FileWriter(csvFile.toFile())) {
        CsvWriter cvsWriter = null;//from w  w w .ja  v a  2s.  c  om
        try {
            cvsWriter = new CsvWriter(content, ',');
            String[] headers = new String[] { "Basecase", "Equipment", "Type", "Value", "Limit" };
            cvsWriter.writeRecord(headers);
            for (String caseBasename : networksViolations.keySet()) {
                for (LimitViolation violation : networksViolations.get(caseBasename)) {
                    String[] values = new String[] { caseBasename, violation.getSubject().getId(),
                            violation.getLimitType().name(), Float.toString(violation.getValue()),
                            Float.toString(violation.getLimit()) };
                    cvsWriter.writeRecord(values);
                }
            }
            cvsWriter.flush();
        } finally {
            if (cvsWriter != null)
                cvsWriter.close();
        }
    }
}

From source file:com.davidecirillo.dashboard.gui.viewholder.PIViewHolder.java

public void setCpuTemperature(Context context, float temp) {

    int resColor = 0;
    String suggestion = "";

    if (temp < 10 || temp > 75) {
        //Red/*  ww w .  j  av a2s  . com*/
        resColor = android.R.color.holo_red_dark;
        suggestion = "Not Good! Danger";
    } else if (temp > 10 && temp < 25 || temp > 55 && temp < 75) {
        //orange
        resColor = android.R.color.holo_orange_dark;
        suggestion = "Not So Good";
    } else if (temp > 25 && temp < 55) {
        //green
        resColor = android.R.color.holo_green_dark;
        suggestion = "Good";
    }

    mBigLabe.setText(context.getString(R.string.cpu_temperature_string, Float.toString(temp), suggestion));
    mBigLabe.setTextColor(ContextCompat.getColor(context, resColor));
    mBigLabe.setVisibility(View.VISIBLE);

}

From source file:layout.BLDComponent.java

public void paint(Graphics g) {
    int width = getWidth();
    int height = getHeight();
    float alignmentX = getAlignmentX();

    g.setColor(normalHue);/* www.  j a  va2 s.c  o  m*/
    g.fill3DRect(0, 0, width, height, true);

    /* Draw a vertical white line at the alignment point.*/
    // XXX: This code is probably not the best.
    g.setColor(Color.white);
    int x = (int) (alignmentX * (float) width) - 1;
    g.drawLine(x, 0, x, height - 1);

    /* Say what the alignment point is. */
    g.setColor(Color.black);
    g.drawString(Float.toString(alignmentX), 3, height - 3);

    if (printSize) {
        System.out.println("BLDComponent " + name + ": size is " + width + "x" + height + "; preferred size is "
                + getPreferredSize().width + "x" + getPreferredSize().height);
    }
}

From source file:de.micromata.genome.gwiki.page.gspt.BodyContentImpl.java

@Override
public void print(float arg0) throws IOException {
    write(Float.toString(arg0));
}

From source file:com.laex.cg2d.model.joints.BEPulleyJoint.java

@Override
public Object getPropertyValue(Object id) {
    if (isGroundAnchorA(id)) {
        return new Vec2PropertySource(groundAnchorA);
    } else if (isGroundAnchorB(id)) {
        return new Vec2PropertySource(groundAnchorB);
    } else if (isRatioProp(id)) {
        return Float.toString(ratio);
    }/*from www  . j a va2s .c om*/

    return super.getPropertyValue(id);
}

From source file:it.uniroma2.sag.kelp.data.representation.vector.SparseVector.java

@Override
public String toString() {
    StringBuilder description = new StringBuilder();
    // accessing keys/values through an iterator:
    for (TIntFloatIterator it = this.vector.iterator(); it.hasNext();) {
        it.advance();/*from  www  . j av a2 s  .  c o  m*/
        String name = fromIntToWord.get(it.key());
        description.append(name + NAME_VALUE_SEPARATOR + Float.toString(it.value()) + FEATURE_SEPARATOR);
    }
    return description.toString();
}

From source file:Main.java

public static void appendChild(Document document, Node root, String nsURI, String name, float value) {
    appendChild(document, root, nsURI, name, Float.toString(value));
    return;/*  ww  w.j a  va 2  s.  c  o m*/
}

From source file:edu.stanford.muse.index.NEROld.java

public static void readLocationsWG() {
    try {//from w  w w.  j a  v a2 s  .co  m
        InputStream is = new GZIPInputStream(
                NER.class.getClassLoader().getResourceAsStream("WG.locations.txt.gz"));
        LineNumberReader lnr = new LineNumberReader(new InputStreamReader(is, "UTF-8"));
        while (true) {
            String line = lnr.readLine();
            if (line == null)
                break;
            StringTokenizer st = new StringTokenizer(line, "\t");
            if (st.countTokens() == 4) {
                String locationName = st.nextToken();
                String canonicalName = locationName.toLowerCase();
                if (locationsToSuppress.contains(canonicalName))
                    continue;
                String lat = st.nextToken();
                String longi = st.nextToken();
                String pop = st.nextToken();
                long popl = Long.parseLong(pop);
                float latf = ((float) Integer.parseInt(lat)) / 100.0f;
                float longif = ((float) Integer.parseInt(longi)) / 100.0f;
                Long existingPop = populations.get(canonicalName);
                if (existingPop == null || popl > existingPop) {
                    populations.put(canonicalName, popl);
                    locations.put(canonicalName,
                            new LocationInfo(locationName, Float.toString(latf), Float.toString(longif)));
                }
            }
        }
    } catch (Exception e) {
        log.warn("Unable to read World Gazetteer file, places info may be inaccurate");
        log.debug(Util.stackTrace(e));
    }
}

From source file:com.narvis.dataaccess.weather.OpenWeatherMapPortal.java

/**
 * Return the temperature in the city in celsius
 *
 * @return/*from ww  w .j  a v a2  s. com*/
 * @throws com.narvis.dataaccess.exception.NoAccessDataException in case the
 * data is not accessible
 */
@Command(CommandName = "temperature")
public String getTemperatureInCelsius() throws NoAccessDataException {

    //Early out
    if (this._currentWeather == null || !this._currentWeather.hasMainInstance()
            || !this._currentWeather.getMainInstance().hasMaxTemperature()) {
        throw new NoAccessDataException(OpenWeatherMapPortal.class, "Can not find temperature",
                this._confProvider.getErrorsLayout().getData("temperature"));
    }

    float farenheitTemperature = this._currentWeather.getMainInstance().getTemperature();
    float celsiusTemp = (farenheitTemperature - 32.0f) * 5.0f / 9.0f;
    return Float.toString(celsiusTemp);
}