List of usage examples for java.lang Float parseFloat
public static float parseFloat(String s) throws NumberFormatException
From source file:ilarkesto.form.FloatFormField.java
private Float parse(String s) { s = s.replace(".", ""); s = s.replace(',', '.'); try {// ww w . j av a 2 s . co m return Float.parseFloat(s); } catch (Exception ex) { return null; } }
From source file:esprit.rt.gui.StatistiquesRestaurateur.java
/** * Creates new form StatistiquesRestaurateur *///ww w . j av a2 s.com public StatistiquesRestaurateur() { initComponents(); setLocationRelativeTo(null); dataset = new DefaultPieDataset(); //Statique PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} places rservs ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); PieSectionLabelGenerator gen2 = new StandardPieSectionLabelGenerator("{0}: {1} DT de revenue ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); for (Entry e : new StatistiqueDAO().mostBooked().entrySet()) { if (Float.parseFloat((String) e.getValue()) > max1) { i1 = j; max1 = Float.parseFloat((String) e.getValue()); } dataset.setValue((Comparable) e.getKey(), Float.parseFloat((String) e.getValue())); j++; } graphe = ChartFactory.createPieChart3D("Les restaurant les plus rserv", dataset, true, true, false); PiePlot plot = (PiePlot) graphe.getPlot(); plot.setLabelGenerator(gen); cp = new ChartPanel(graphe); cp.setBounds(new Rectangle(490, 400)); PieChart.getContentPane().add(cp); cp.setVisible(true); PieChart.setVisible(true); title.setHorizontalAlignment(JLabel.CENTER); try { title.setFont(new FontsPartieRestaurateur().getFont(FontsPartieRestaurateur.TITLE, 70)); } catch (FontFormatException ex) { Logger.getLogger(ConsultRestaurant.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ConsultRestaurant.class.getName()).log(Level.SEVERE, null, ex); } dataset2 = new DefaultPieDataset(); //Statique for (Entry e : new StatistiqueDAO().mostPayed().entrySet()) { if (Float.parseFloat((String) e.getValue()) > max2) { i2 = k; max2 = Float.parseFloat((String) e.getValue()); } dataset2.setValue((Comparable) e.getKey(), Float.parseFloat((String) e.getValue())); k++; } graphe2 = ChartFactory.createPieChart3D("Restaurant avec le meilleur revenue", dataset2, true, true, false); PiePlot plot2 = (PiePlot) graphe2.getPlot(); plot2.setLabelGenerator(gen2); cp2 = new ChartPanel(graphe2); cp2.setBounds(new Rectangle(490, 400)); Pie2.add(cp2); cp2.setVisible(true); Pie2.setVisible(true); try { if (i1 == i2) { conseil.setForeground(Color.green); conseil.setText( "Vos statistiques sont parfaites! Votre restaurant le plus rserv est celui avec le plus de revenue!"); } else { conseil.setForeground(Color.red); conseil.setText( "Le restaurant le plus rserv n'est pas celui avec le plus revenue! Verifier votre stratgie de prix!"); } } catch (Exception e) { conseil.setVisible(false); } }
From source file:geva.FitnessEvaluation.LSystem.LSystemDimension.java
public void getFitness(Individual i) { String grammar = i.getPhenotype().getString().substring(6); String depth = i.getPhenotype().getString().substring(0, 1); String angle = i.getPhenotype().getString().substring(1, 6); double fractalDim = new LSystem2FDBoxCounting(null, grammar, Integer.parseInt(depth), Float.parseFloat(angle), boxCountDivision).calcFractalDimension(); i.getFitness().setDouble(Math.abs(targetFractalDim - fractalDim)); }
From source file:org.owasp.webgoat.plugin.HtmlTamperingTask.java
@RequestMapping(method = RequestMethod.POST) public @ResponseBody AttackResult completed(@RequestParam String QTY, @RequestParam String Total) throws IOException { if (Float.parseFloat(QTY) * 2999.99 > Float.parseFloat(Total) + 1) { return trackProgress(success().feedback("html-tampering.tamper.success").build()); }// w w w . ja v a 2s . c o m return trackProgress(failed().feedback("html-tampering.tamper.failure").build()); }
From source file:com.me.Controller.AddBookController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { ModelAndView mav = new ModelAndView(); String action = request.getParameter("action"); if (action.equals("get")) { String number = request.getParameter("noOfBooks"); int noOfBooks = Integer.parseInt(number); if (noOfBooks > 0) { mav.addObject("numberBooks", noOfBooks); mav.setViewName("Books"); }//ww w.jav a2 s. com } else if (action.equals("post")) { DAO dao = new DAO(); Connection conn = null; PreparedStatement preparedStatement = null; try { conn = dao.getConnection(); String[] isbn = request.getParameterValues("isbn"); String[] title = request.getParameterValues("title"); String[] authors = request.getParameterValues("authors"); String[] price = request.getParameterValues("Price"); String insertQuery = "insert into books(isbn,title,authors,price)" + "values(?,?,?,?)"; int count = 0; for (int i = 0; i < isbn.length; i++) { preparedStatement = conn.prepareStatement(insertQuery); preparedStatement.setString(1, isbn[i]); preparedStatement.setString(2, title[i]); preparedStatement.setString(3, authors[i]); preparedStatement.setFloat(4, Float.parseFloat(price[i])); int result = preparedStatement.executeUpdate(); count++; } mav.addObject("noOfRecords", count); mav.setViewName("Result"); } finally { dao.closeConnection(conn); dao.closeStatement(preparedStatement); } } return mav; }
From source file:eu.popgen.canephora.parsers.plink.BIMReader.java
BIMRecord readRecord() throws IOException { String line = this.in.readLine(); if (line == null) { return null; }//from ww w . j av a 2 s . c om String[] toks = StringUtils.split(line); BIMRecord rec = new BIMRecord(Integer.parseInt(toks[0]), toks[1], Float.parseFloat(toks[2]), Integer.parseInt(toks[3]), toks[4].charAt(0), toks[5].charAt(0)); return rec; }
From source file:de.d3web.empiricaltesting.casevisualization.jung.EdgeStrokeTransformer.java
/** * Transforms a Finding to color depending on the state of the next * RatedTestCase//from w ww . ja v a 2 s .c o m */ @Override public Stroke transform(EdgeFinding f) { RatedTestCase rtc = graph.getDest(f); String strength = ConfigLoader.getInstance().getProperty("edgeWidthNewCase"); if (rtc.wasTestedBefore()) { strength = ConfigLoader.getInstance().getProperty("edgeWidthOldCase"); } return new BasicStroke(Float.parseFloat(strength) / 2, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER); }
From source file:net.gtaun.wl.race.importer.SraceImporter.java
@Override public void importTrack(File file) throws Throwable { Ini ini = new Ini(file); Section trackInfo = ini.get("TrackInfo"); String name = file.getName().replace(".ini", ""); String desc = trackInfo.get("Description"); String author = trackInfo.get("Designer"); Section checkpointInfo = ini.get("CheckpointInfo"); int checkpointCount = Integer.parseInt(checkpointInfo.get("Count")); Radius[] checkpointPos = new Radius[checkpointCount]; for (int i = 0; i < checkpointCount; i++) { String line = checkpointInfo.get("Checkpoint" + (i + 1)); String[] splits = StringUtils.split(line, ','); checkpointPos[i] = new Radius(Float.parseFloat(splits[0]), Float.parseFloat(splits[1]), Float.parseFloat(splits[2]), Float.parseFloat(splits[3])); }//from w ww .ja v a2 s .c om Track track = trackManager.createTrack(author, name); track.setDesc(desc); for (int i = 0; i < checkpointCount; i++) { TrackCheckpoint checkpoint = track.createCheckpoint(checkpointPos[i]); checkpoint.setSize(checkpointPos[i].getRadius()); } track.setStatus(TrackStatus.COMPLETED); }
From source file:de.Keyle.MyPet.api.Util.java
public static boolean isFloat(String number) { try {//from w ww . jav a2s . c om Float.parseFloat(number); return true; } catch (NumberFormatException nFE) { return false; } }
From source file:info.bonjean.beluga.gui.pivot.WelcomeUI.java
@Override public void initialize(Map<String, Object> namespace, URL location, Resources resources) { belugaVersion.setText("Beluga Player " + state.getVersion()); new Thread() { @Override/* w w w . j a va2 s .c o m*/ public void run() { InputStream in = null; try { float currentVersion = Float.parseFloat(state.getVersion()); in = new URL("http://jbonjean.github.io/beluga-player/VERSION").openStream(); float newVersion = Float.parseFloat(IOUtils.toString(in)); if (newVersion > currentVersion) { ApplicationContext.queueCallback(new Runnable() { @Override public void run() { newVersionPane.setVisible(true); } }, true); } else log.debug("No new version available"); } catch (Exception e) { log.debug(e.getMessage()); } finally { if (in != null) IOUtils.closeQuietly(in); } } }.start(); }