List of usage examples for java.lang Float toString
public static String toString(float f)
From source file:org.muse.mneme.tool.QuestionScoreDelegate.java
/** * Format a score to 2 decimal places, trimming ".0" if present. * /*from www . j av a 2 s .com*/ * @param score * The score to format. * @return The formatted score */ protected static String formatScore(Context context, Float score) { if (score == null) return context.getMessages().getString("question-score-ungraded"); // round to a single place String rv = Float.toString(Math.round(score * 100.0f) / 100.0f); // get rid of ".00" if (rv.endsWith(".00")) { rv = rv.substring(0, rv.length() - 3); } // get rid of ".0" if (rv.endsWith(".0")) { rv = rv.substring(0, rv.length() - 2); } return rv; }
From source file:com.libresoft.apps.ARviewer.Utils.GeoNames.AltitudeManager.java
public static double getAltitudeFromLatLong(float latitude, float longitude) { double altitude = AltitudeManager.NO_ALTITUDE_VALUE; String data = "?lat=" + Float.toString(latitude) + "&lng=" + Float.toString(longitude); try {//Aster DefaultHttpClient httpclient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(URL + data); HttpResponse response = httpclient.execute(httpGet); HttpEntity entity = response.getEntity(); String str = convertStreamToString(entity.getContent()); Log.d("GeoNames: ", str); altitude = Double.parseDouble(str); if (altitude < 0) altitude = 0;/* ww w .j a v a 2s . c om*/ return altitude; } catch (Exception e) { Log.e("GeoNames: ", e.getMessage()); return emergencyService(data); } }
From source file:de.grobmeier.jjson.JSONNumber.java
/** * @param value */ public JSONNumber(float value) { this.value = Float.toString(value); }
From source file:cn.ctyun.amazonaws.util.StringUtils.java
public static String fromFloat(Float value) { return Float.toString(value); }
From source file:ColorComposite.java
public ColorComposite() { super();/*w w w. j ava 2 s . c om*/ Container container = getContentPane(); canvas = new MyCanvas(); container.add(canvas); JPanel panel = new JPanel(); JLabel label = new JLabel("Color-Composite: "); JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 65); slider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider tempSlider = (JSlider) e.getSource(); alphaValue = (float) (tempSlider.getValue() / 100.0); textField.setText(Float.toString(alphaValue)); canvas.repaint(); } }); textField = new JTextField("0.65", 4); panel.add(label); panel.add(slider); panel.add(textField); container.add(BorderLayout.SOUTH, panel); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); setSize(450, 450); setVisible(true); }
From source file:com.gargoylesoftware.htmlunit.html.IEConditionalCommentExpressionEvaluator.java
/** * Evaluates the condition.//from www. ja v a 2 s .co m * @param condition the condition like "lt IE 7" * @param browserVersion the browser version. Note that currently it can only be an IE browser. * @return the evaluation result */ public static boolean evaluate(String condition, final BrowserVersion browserVersion) { condition = condition.trim(); if ("IE".equals(condition)) { return true; } else if ("true".equals(condition)) { return true; } else if ("false".equals(condition)) { return false; } else if (condition.contains("&")) { return evaluate(StringUtils.substringBefore(condition, "&"), browserVersion) && evaluate(StringUtils.substringAfter(condition, "&"), browserVersion); } else if (condition.contains("|")) { return evaluate(StringUtils.substringBefore(condition, "|"), browserVersion) || evaluate(StringUtils.substringAfter(condition, "|"), browserVersion); } else if (condition.startsWith("!")) { return !evaluate(condition.substring(1), browserVersion); } else if (condition.startsWith("IE")) { final String currentVersion = Float.toString(browserVersion.getBrowserVersionNumeric()); return currentVersion.startsWith(condition.substring(2).trim()); } else if (condition.startsWith("lte IE")) { return browserVersion.getBrowserVersionNumeric() <= parseVersion(condition.substring(6)); } else if (condition.startsWith("lt IE")) { return browserVersion.getBrowserVersionNumeric() < parseVersion(condition.substring(5)); } else if (condition.startsWith("gt IE")) { return browserVersion.getBrowserVersionNumeric() > parseVersion(condition.substring(5)); } else if (condition.startsWith("gte IE")) { return browserVersion.getBrowserVersionNumeric() >= parseVersion(condition.substring(6)); } else if (condition.startsWith("lt")) { return true; } else if (condition.startsWith("gt")) { return false; } else if (condition.startsWith("(")) { // in fact not fully correct if () can be nested return evaluate(StringUtils.substringBetween(condition, "(", ")"), browserVersion); } else { return false; } }
From source file:Main.java
public static Element createElement(Document document, String name, float value) { return createElement(document, name, Float.toString(value)); }
From source file:com.autentia.intra.manager.admin.SettingManager.java
/** * Save a property for current user//from w ww .j av a2 s.c o m * * @param propertyPath property path * @param value property value */ public static void setValue(Setting val, float value) { val.setType(SettingType.FLOAT); val.setValue(Float.toString(value)); }
From source file:com.norconex.commons.wicket.markup.html.chart.jqplot.Point.java
private String convert(Object obj) { if (obj == null) { return "''"; }//from w ww .j a v a 2 s. co m if (Integer.class.isAssignableFrom(obj.getClass())) { return Integer.toString((Integer) obj); } if (Float.class.isAssignableFrom(obj.getClass())) { return Float.toString((Float) obj); } if (Long.class.isAssignableFrom(obj.getClass())) { return Long.toString((Long) obj); } if (Double.class.isAssignableFrom(obj.getClass())) { return Double.toString((Double) obj); } return "'" + StringUtils.replace(obj.toString(), "'", "\\'") + "'"; }
From source file:com.chargebee.Application.Amountediting.java
public void formatter(CSVParser parser, CSVPrinter printer, JSONObject jobj) throws Exception { String refund_column_header = jobj.getString("refund_column_header"); String tax_column_header = jobj.getString("tax_column_header"); String amount_column_header = jobj.getString("amount_column_header"); boolean isHeader = true; for (CSVRecord record : parser) { String[] s = MethodBank.toArray(record); if (isHeader) { amountColumnIndex = MethodBank.indexFinder(s, amount_column_header); refundColumnIndex = MethodBank.indexFinder(s, refund_column_header); taxColumnIndex = MethodBank.indexFinder(s, tax_column_header); MethodBank.print(printer, s); isHeader = false;//from www. j a v a2s . co m continue; } int tempo; float tempo2; tempo = Integer.parseInt(s[amountColumnIndex]); tempo2 = ((float) tempo) / 100; s[amountColumnIndex] = Float.toString(tempo2); tempo = Integer.parseInt(s[refundColumnIndex]); tempo2 = ((float) tempo) / 10; s[refundColumnIndex] = Float.toString(tempo2); tempo = Integer.parseInt(s[taxColumnIndex]); tempo2 = ((float) tempo) / 100; System.out.println(tempo2); s[taxColumnIndex] = Float.toString(tempo2); MethodBank.print(printer, s); } }