List of usage examples for java.lang Float toString
public static String toString(float f)
From source file:com.narvis.dataaccess.weather.OpenWeatherMapPortal.java
/** * Return the percentage of clouds/*from w ww. j ava 2 s .c o m*/ * * @return * @throws com.narvis.dataaccess.exception.NoAccessDataException in case the * data is not accessible */ @Command(CommandName = "cloud") public String GetPercentageOfCloud() throws NoAccessDataException { //Early out if (this._currentWeather == null || !this._currentWeather.hasCloudsInstance() || !this._currentWeather.getCloudsInstance().hasPercentageOfClouds()) { throw new NoAccessDataException(OpenWeatherMapPortal.class, "Can not find clouds percentage", this._confProvider.getErrorsLayout().getData("cloud")); } float cloudPercentage = this._currentWeather.getCloudsInstance().getPercentageOfClouds(); return Float.toString(cloudPercentage); }
From source file:edu.csudh.goTorosBank.WithdrawServlet.java
/** * TODO: Finish filling this out..../* w w w . ja v a 2 s . co m*/ * @param request * @param response * @throws ServletException * @throws IOException */ @Override @SuppressWarnings("unchecked") //need this to suppress warnings for our json.put protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { getServletContext().log("goGet () called"); JSONObject returnJSON = new JSONObject(); response.setContentType("application/json"); HttpSession userSession = request.getSession(); String username = (String) userSession.getAttribute("username"); try { DatabaseInterface database = new DatabaseInterface(); User myUser = database.getUser(username); if (request.getParameter("accountID") == null || request.getParameter("amount") == null) { returnJSON.put("successfulWithdraw", false); returnJSON.put("message", "Not valid arguments!"); //response.getWriter().write(returnJSON.toJSONString()); return; } int accountID = Integer.parseInt(request.getParameter("accountID")); float amount = Float.parseFloat(request.getParameter("amount")); Account accountFrom = myUser.getUserAccount(accountID); String personGettingPaid = request.getParameter("personGettingPaid"); String billType = request.getParameter("billType"); String memo = request.getParameter("memo"); //Checks if user has selected an account if (myUser.getUserAccounts().size() == 0) { returnJSON.put("successfulWithdraw", false); returnJSON.put("message", "No account to withdraw from"); } //checks if user has sufficient funds else if (0 > (accountFrom.getAccountBalance() - amount)) { returnJSON.put("successfulWithdraw", false); returnJSON.put("message", "Insufficient funds in account" + accountFrom.getAccountNumber()); } //checks that user withdraws in amounts of 20 else if (amount % 20 != 0) { returnJSON.put("successfulWithdraw", false); returnJSON.put("message", "Must withdraw in amounts of 20"); } //checks that uer doesn't withdraw more than $500.00 else if (amount > 500) { returnJSON.put("successfulWithdraw", false); returnJSON.put("message", "Withdraw amount cannot exceed $500.00"); } else if (personGettingPaid == null) { returnJSON.put("successfulWithdraw", false); returnJSON.put("message", "There is no person getting payed"); } else if (billType == null) { returnJSON.put("successfulWithdraw", false); returnJSON.put("message", "There is no bill description"); } //creates check for user and makes changes to the database... else { //response.setContentType("image/jpeg"); File blueCheck = new File("blank-blue-check"); String pathToWeb = getServletContext().getRealPath("/" + blueCheck); //File blueCheck = new File(pathToWeb + "blank-blue-check.jpg"); returnJSON.put("pathToWeb", pathToWeb); String fullpath = writeIntoCheck(pathToWeb, username, Float.toString(amount), "AMOUNT IN WORDS", "DATE", personGettingPaid, "BULLSHIT"); String[] fullpathSplit = fullpath.split("/"); String filename = fullpathSplit[fullpathSplit.length - 1]; database.withdraw(accountID, amount, username); returnJSON.put("filename", filename); returnJSON.put("successfulWithdraw", true); returnJSON.put("message", "Successfully withdrew $" + amount + " from account " + accountID); } } catch (SQLException s) { returnJSON.put("errorMessage", "Sorry we have a SQLException"); returnJSON.put("errorMessage2", s); } catch (ClassNotFoundException cl) { returnJSON.put("errorMessage", "Sorry we have a ClassNotFoundException"); returnJSON.put("errorMessage2", cl); } catch (ParseException p) { returnJSON.put("successfulWithdraw", false); returnJSON.put("message", "ParseException: " + p.getMessage()); } /*added new case, where parseInt finds nothing*/ catch (NumberFormatException e) { returnJSON.put("successfulWithdraw", false); returnJSON.put("message", "NumberFormatException " + e.getMessage()); } response.getWriter().write(returnJSON.toJSONString()); }
From source file:com.blocks.framework.utils.date.StringUtil.java
/** * float??String/* w ww . j ava 2 s.c o m*/ * * @param val * float * @return String */ public static String toString(float val) { return Float.toString(val); }
From source file:blue.soundObject.pianoRoll.PianoNote.java
public Element saveAsXML() { Element retVal = new Element("pianoNote"); retVal.addElement("octave").setText(Integer.toString(octave)); retVal.addElement("scaleDegree").setText(Integer.toString(scaleDegree)); retVal.addElement("start").setText(Float.toString(start)); retVal.addElement("duration").setText(Float.toString(duration)); retVal.addElement("noteTemplate").setText(noteTemplate); return retVal; }
From source file:ca.uhn.hl7v2.model.primitive.tests.CommonTSTest.java
@Before public void BeforeTheTest() throws Exception { year = 2002;//w w w.j av a 2s . com month = 11; day = 30; hour = 11; minute = 23; second = 15; fractionalSecond = .1234F; offset = DataTypeUtil.getLocalGMTOffset(); offsetStr = DataTypeUtil.preAppendZeroes(Math.abs(offset), 4); if (offset >= 0) { offsetStr = "+" + offsetStr; } else { offsetStr = "-" + offsetStr; } timeStamp = Integer.toString(year) + Integer.toString(month) + Integer.toString(day) + Integer.toString(hour) + Integer.toString(minute) + Integer.toString(second) + Float.toString(fractionalSecond).substring(1) + offsetStr; baseTime = Integer.toString(year) + Integer.toString(month) + Integer.toString(day) + Integer.toString(hour) + Integer.toString(minute) + Integer.toString(second) + Float.toString(fractionalSecond).substring(1); commonTS = new CommonTS(); }
From source file:org.apache.hadoop.hive.accumulo.AccumuloTestSetup.java
protected void createAccumuloTable(Connector conn) throws TableExistsException, TableNotFoundException, AccumuloException, AccumuloSecurityException { TableOperations tops = conn.tableOperations(); if (tops.exists(TABLE_NAME)) { tops.delete(TABLE_NAME);/*from www .j a v a2 s . c om*/ } tops.create(TABLE_NAME); boolean[] booleans = new boolean[] { true, false, true }; byte[] bytes = new byte[] { Byte.MIN_VALUE, -1, Byte.MAX_VALUE }; short[] shorts = new short[] { Short.MIN_VALUE, -1, Short.MAX_VALUE }; int[] ints = new int[] { Integer.MIN_VALUE, -1, Integer.MAX_VALUE }; long[] longs = new long[] { Long.MIN_VALUE, -1, Long.MAX_VALUE }; String[] strings = new String[] { "Hadoop, Accumulo", "Hive", "Test Strings" }; float[] floats = new float[] { Float.MIN_VALUE, -1.0F, Float.MAX_VALUE }; double[] doubles = new double[] { Double.MIN_VALUE, -1.0, Double.MAX_VALUE }; HiveDecimal[] decimals = new HiveDecimal[] { HiveDecimal.create("3.14159"), HiveDecimal.create("2.71828"), HiveDecimal.create("0.57721") }; Date[] dates = new Date[] { Date.valueOf("2014-01-01"), Date.valueOf("2014-03-01"), Date.valueOf("2014-05-01") }; Timestamp[] timestamps = new Timestamp[] { new Timestamp(50), new Timestamp(100), new Timestamp(150) }; BatchWriter bw = conn.createBatchWriter(TABLE_NAME, new BatchWriterConfig()); final String cf = "cf"; try { for (int i = 0; i < 3; i++) { Mutation m = new Mutation("key-" + i); m.put(cf, "cq-boolean", Boolean.toString(booleans[i])); m.put(cf.getBytes(), "cq-byte".getBytes(), new byte[] { bytes[i] }); m.put(cf, "cq-short", Short.toString(shorts[i])); m.put(cf, "cq-int", Integer.toString(ints[i])); m.put(cf, "cq-long", Long.toString(longs[i])); m.put(cf, "cq-string", strings[i]); m.put(cf, "cq-float", Float.toString(floats[i])); m.put(cf, "cq-double", Double.toString(doubles[i])); m.put(cf, "cq-decimal", decimals[i].toString()); m.put(cf, "cq-date", dates[i].toString()); m.put(cf, "cq-timestamp", timestamps[i].toString()); bw.addMutation(m); } } finally { bw.close(); } }
From source file:Interface.Stats.java
/** * * @param f /*from ww w .j a v a2s . c o m*/ */ private Stats(JFrame f) { // On initialise les boutons JButton valider = new JButton("Valider"); JButton retour = new JButton("Retour"); JComboBox combo = new JComboBox(); // On initialise et remplit la combobox combo.setPreferredSize(new Dimension(400, 30)); combo.addItem("Nombre de patient par service"); combo.addItem("Salaire moyen des employs"); combo.addItem("Nombre d'intervention par mdecin"); // On initialise les JLabels JLabel texte = new JLabel("Veuillez selectionner la requete envoyer"); // On change le bouton de forme valider.setPreferredSize(new Dimension(200, 30)); valider.setOpaque(false); retour.setPreferredSize(new Dimension(200, 30)); retour.setOpaque(false); // On initialise les Jpanels p1 = new JPanel(); p1.setPreferredSize(new Dimension(600, 100)); p1.add(texte); p1.setOpaque(false); p2 = new JPanel(); p2.add(combo); p2.setOpaque(false); p4 = new JPanel(); p4.add(retour); p4.add(valider); p4.setOpaque(false); // Gestion des boutons retour.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Accueil.getFenetre(f); } }); valider.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (combo.getSelectedItem().equals("Nombre de patient par service")) { System.out.println( "Nb de patients en REA : " + Connexion.getInstance().nb_malade_services("\"REA\"")); System.out.println( "Nb de patients en ORL : " + Connexion.getInstance().nb_malade_services("\"ORL\"")); System.out.println( "Nb de patients en CHG : " + Connexion.getInstance().nb_malade_services("\"CHG\"")); // new Camembert(f, Connexion.getInstance().nb_malade_services("\"REA\""), Connexion.getInstance().nb_malade_services("\"ORL\""), Connexion.getInstance().nb_malade_services("\"CHG\"")); JPanel panel_camemb = Camembert.cCamembert(f, Connexion.getInstance().nb_malade_services("\"REA\""), Connexion.getInstance().nb_malade_services("\"ORL\""), Connexion.getInstance().nb_malade_services("\"CHG\"")); ; f.setContentPane(new ImagePanel(new ImageIcon("fond66.jpg").getImage())); // Met l'image en background f.add(p1); f.add(p2); f.add(p4); f.add(panel_camemb); f.setVisible(true); } else if (combo.getSelectedItem().equals("Salaire moyen des employs")) { JLabel jf_doc, jf_inf, jf_emp; JTextField jtf_doc, jtf_inf, jtf_emp; JPanel p5, p6, p7; // On initialise les JF jf_doc = new JLabel("Salaire moyen des docteurs"); jf_inf = new JLabel("Salaire moyen des infirmiers"); jf_emp = new JLabel("Salaire moyen de tous les employs"); // On initialise les JTF jtf_doc = new JTextField(); jtf_doc.setPreferredSize(new Dimension(200, 30)); jtf_doc.setText(Float.toString(Connexion.getInstance().moyenne_salaired()) + " "); jtf_inf = new JTextField(); jtf_inf.setPreferredSize(new Dimension(200, 30)); jtf_inf.setText(Float.toString((Connexion.getInstance().moyenne_salairei())) + " "); jtf_emp = new JTextField(); jtf_emp.setPreferredSize(new Dimension(160, 30)); jtf_emp.setText(Float.toString((Connexion.getInstance().moyenne_salaire())) + " "); // On cre les JPanels p5 = new JPanel(); p5.add(jf_doc); p5.add(jtf_doc); p5.setOpaque(false); p6 = new JPanel(); p6.add(jf_inf); p6.add(jtf_inf); p6.setOpaque(false); p7 = new JPanel(); p7.add(jf_emp); p7.add(jtf_emp); p7.setOpaque(false); f.setContentPane(new ImagePanel(new ImageIcon("fond66.jpg").getImage())); // Met l'image en background f.add(p1); f.add(p2); f.add(p4); f.add(p5); f.add(p6); f.add(p7); f.setVisible(true); f.setSize(new Dimension(600, 600)); } else if (combo.getSelectedItem().equals("Nombre d'intervention par mdecin")) { ArrayList liste = null; try { // ICI !!!!!!!!!! liste = Connexion.getInstance().reporting( "SELECT e.nom , COUNT(d.no_docteur) FROM hospitalisation h, docteur d , employe e WHERE (h.no_docteur= d.no_docteur) AND e.no_employe = d.no_docteur GROUP BY e.nom"); } catch (SQLException ex) { Logger.getLogger(Stats.class.getName()).log(Level.SEVERE, null, ex); } if (liste != null) { JPanel panel_camemb = Camembert.cCamembert(f, liste); f.setContentPane(new ImagePanel(new ImageIcon("fond66.jpg").getImage())); // Met l'image en background f.add(p1); f.add(p2); f.add(p4); f.add(panel_camemb); f.setVisible(true); } } } }); }
From source file:com.oprisnik.semdroid.app.parser.manifest.AXMLConverter.java
private static String getAttributeValue(AXmlResourceParser parser, int index) { int type = parser.getAttributeValueType(index); int data = parser.getAttributeValueData(index); if (type == TypedValue.TYPE_STRING) { return parser.getAttributeValue(index); }/*from ww w.j a va 2 s . c om*/ if (type == TypedValue.TYPE_ATTRIBUTE) { return String.format("?%s%08X", getPackage(data), data); } if (type == TypedValue.TYPE_REFERENCE) { return String.format("@%s%08X", getPackage(data), data); } if (type == TypedValue.TYPE_FLOAT) { return String.valueOf(Float.intBitsToFloat(data)); } if (type == TypedValue.TYPE_INT_HEX) { return String.format("0x%08X", data); } if (type == TypedValue.TYPE_INT_BOOLEAN) { return data != 0 ? "true" : "false"; } if (type == TypedValue.TYPE_DIMENSION) { return Float.toString(complexToFloat(data)) + DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK]; } if (type == TypedValue.TYPE_FRACTION) { return Float.toString(complexToFloat(data)) + FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK]; } if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) { return String.format("#%08X", data); } if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) { return String.valueOf(data); } return String.format("<0x%X, type 0x%02X>", data, type); }
From source file:org.eclipse.gyrex.persistence.internal.storage.RepositoryPreferences.java
@Override public void putFloat(final String key, final float value, final boolean encrypt) { put(key, Float.toString(value), encrypt); }
From source file:ui.Graph.java
/** * Creates a chart./*from w w w. j a v a2 s. c om*/ * * @param dataset * the data for the chart. * * @return a chart. */ private JFreeChart createChart(ArrayList<Setpoint> setpoints, ArrayList<Setpoint> traj) { trajectory = traj; XYSeries posSeries = new XYSeries("Position"); XYSeries trajSeries = new XYSeries("Trajectory"); XYSeries velSeries = new XYSeries("Velocity"); for (int i = 0; i < setpoints.size(); i++) { Setpoint p = setpoints.get(i); posSeries.add(p.time, p.position); velSeries.add(p.time, p.velocity); } for (int i = 0; i < trajectory.size(); i++) { Setpoint p = trajectory.get(i); trajSeries.add(p.time, p.position); } XYSeriesCollection posDataset = new XYSeriesCollection(); XYSeriesCollection trajDataset = new XYSeriesCollection(); XYSeriesCollection velDataset = new XYSeriesCollection(); posDataset.addSeries(posSeries); velDataset.addSeries(velSeries); trajDataset.addSeries(trajSeries); // create the chart... final JFreeChart chart = ChartFactory.createScatterPlot("System output", // chart title "X", // x axis label "Y", // y axis label posDataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setDataset(0, posDataset); plot.setDataset(1, trajDataset); plot.setDataset(2, velDataset); plot.setBackgroundPaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer posRenderer = new XYLineAndShapeRenderer(); // renderer.setSeriesShape(0, new Ellipse2D.Float(1.0f, 1.0f, 1.0f, // 1.0f)); posRenderer.setSeriesPaint(0, Color.BLUE); posRenderer.setSeriesLinesVisible(0, true); posRenderer.setSeriesShapesVisible(0, false); XYStepRenderer trajRenderer = new XYStepRenderer(); trajRenderer.setSeriesPaint(1, Color.RED); trajRenderer.setSeriesStroke(1, new BasicStroke(10)); trajRenderer.setSeriesLinesVisible(1, true); trajRenderer.setSeriesShapesVisible(1, false); XYLineAndShapeRenderer velRenderer = new XYLineAndShapeRenderer(); velRenderer.setSeriesPaint(0, Color.MAGENTA); velRenderer.setSeriesLinesVisible(0, true); velRenderer.setSeriesShapesVisible(0, false); // renderer.setSeriesStroke(1, new BasicStroke(0.01f)); plot.setRenderer(0, posRenderer); plot.setRenderer(1, trajRenderer); plot.setRenderer(2, velRenderer); for (Setpoint s : trajectory) { Marker marker = new ValueMarker(s.time); marker.setPaint(Color.DARK_GRAY); marker.setLabel(Float.toString((float) s.position)); marker.setLabelAnchor(RectangleAnchor.TOP_LEFT); marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addDomainMarker(marker); } XYTextAnnotation p = new XYTextAnnotation("kP = " + gains.kP, plot.getDomainAxis().getUpperBound() * 0.125, plot.getRangeAxis().getUpperBound() * .75); p.setFont(new Font("Dialog", Font.PLAIN, 12)); plot.addAnnotation(p); XYTextAnnotation i = new XYTextAnnotation("kI = " + gains.kI, plot.getDomainAxis().getUpperBound() * 0.125, plot.getRangeAxis().getUpperBound() * .7); i.setFont(new Font("Dialog", Font.PLAIN, 12)); plot.addAnnotation(i); XYTextAnnotation d = new XYTextAnnotation("kD = " + gains.kD, plot.getDomainAxis().getUpperBound() * 0.125, plot.getRangeAxis().getUpperBound() * .65); d.setFont(new Font("Dialog", Font.PLAIN, 12)); plot.addAnnotation(d); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(true); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }