List of usage examples for java.lang Float parseFloat
public static float parseFloat(String s) throws NumberFormatException
From source file:org.openimaj.demos.sandbox.PlotFlickrGeo.java
public static void main(String[] args) throws IOException { File inputcsv = new File("/Users/jsh2/Desktop/world-geo.csv"); List<float[]> data = new ArrayList<float[]>(10000000); //read in images BufferedReader br = new BufferedReader(new FileReader(inputcsv)); String line;/*w w w . j a v a2 s. co m*/ int i = 0; while ((line = br.readLine()) != null) { String[] parts = line.split(","); float longitude = Float.parseFloat(parts[0]); float latitude = Float.parseFloat(parts[1]); data.add(new float[] { longitude, latitude }); if (i++ % 10000 == 0) System.out.println(i); } System.out.println("Done reading"); float[][] dataArr = new float[2][data.size()]; for (i = 0; i < data.size(); i++) { dataArr[0][i] = data.get(i)[0]; dataArr[1][i] = data.get(i)[1]; } NumberAxis domainAxis = new NumberAxis("X"); domainAxis.setRange(-180, 180); NumberAxis rangeAxis = new NumberAxis("Y"); rangeAxis.setRange(-90, 90); FastScatterPlot plot = new FastScatterPlot(dataArr, domainAxis, rangeAxis); JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot); chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); final ApplicationFrame frame = new ApplicationFrame("Title"); frame.setContentPane(chartPanel); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static float str2float(String str) { return Float.parseFloat(str.trim()); }
From source file:Main.java
public static String yuan2fen(String yuan) { return ((int) ((Float.parseFloat(yuan)) * 100)) + ""; }
From source file:Main.java
public static String fen2yuan(String fen) { float temp = Float.parseFloat(fen); String tempStr = (temp / 100) + ""; return tempStr; }
From source file:Main.java
public static float getBuildVersion() { return Float.parseFloat(Build.VERSION.RELEASE); }
From source file:Main.java
public static String liangweixiaoshu1(String value) { return String.format("%.2f", Float.parseFloat(value)); }
From source file:Main.java
public static boolean IsDecimal(String string) { try {// w w w .j a v a 2 s. com float r = Float.parseFloat(string); return r != r + 1; // just to suppress the hint } catch (Exception e) { return false; } }
From source file:Main.java
public static String truncateBidPrice(String bidPrice) { bidPrice = String.format("%.2f", Float.parseFloat(bidPrice)); return bidPrice; }
From source file:Main.java
public static float roundFloatTwoHouse(float value) { return Float.parseFloat(String.format(Locale.US, "%.2f", value)); }
From source file:Main.java
public static String getSpace(String range) { String space = ""; float r = Float.parseFloat(range); if (r >= 1000) { space = (r / 1000 + 0.5f) + "km"; } else {/*from w w w .ja v a2 s . co m*/ space = r + "m"; } return space; }