List of usage examples for java.lang Float parseFloat
public static float parseFloat(String s) throws NumberFormatException
From source file:de.qaware.chronix.solr.type.metric.functions.transformation.Vectorization.java
/** * Constructs the vectorization transformation. * <p>//www .java 2 s . c om * A typical tolerance value is 0.01f * * @param tolerance the value that is used to decide if the distance of values is almost equals. */ public Vectorization(String[] args) { this.tolerance = Float.parseFloat(args[0]); }
From source file:convertCSV.ConvertCSV.java
/** * @param fichier_// w ww . ja v a 2 s .com * @throws java.io.IOException */ public void importer(String fichier_) throws IOException { // TODO code application logic here float lat, lon, ele, secjour; int bpm; List<MonPoint> points = new ArrayList<>(); Reader in = null; CSVParser parser; List<CSVRecord> list; GPXWriter monGPX = new GPXWriter(); // lecture du CSV try { System.out.println("Lecture de " + fichier_); in = new FileReader(fichier_); } catch (FileNotFoundException ex) { Logger.getLogger(ConvertCSV.class.getName()).log(Level.SEVERE, null, ex); } parser = new CSVParser(in, CSVFormat.EXCEL); list = parser.getRecords(); list.remove(0); // remplissage de la liste de point GPX if (in != null) { for (CSVRecord elem : list) { try { // on recupere les donnees dans le CSV lat = Float.parseFloat(elem.get(0)); lon = Float.parseFloat(elem.get(1)); ele = Float.parseFloat(elem.get(2)); secjour = Float.parseFloat(elem.get(3)); if (elem.size() > 4) { bpm = Integer.parseInt(elem.get(4)); points.add(new MonPoint(lat, lon, ele, secjour, bpm)); } else { points.add(new MonPoint(lat, lon, ele, secjour)); } } catch (NumberFormatException ex) { System.out.println(elem.toString()); } } // ecriture du GPX monGPX.writePath("C:\\Users\\vincent\\Desktop\\today.gpx", "Training", points); in.close(); } System.exit(0); }
From source file:monitoring.Monitoring.java
/** * //from w w w .jav a 2s .com */ public void run() { Pve2Api api = new Pve2Api("192.168.100.10", "root", "pam", "pppppppp"); //Iaas iaas = new Iaas(); float percent; int var; List<Container> list = null; while (true) { try { list = api.getOpenvzCTs("proxmox"); //list = api.getOpenvzCTs(null); Iterator<Container> it = list.iterator(); while (it.hasNext()) { Container ct = it.next(); percent = (Float.parseFloat(ct.getMem_usage()) * 100) / Float.parseFloat(ct.getMemory()); System.out.println("vmID " + ct.getVmid()); System.out.println("Memory Usage " + ct.getMem_usage()); System.out.println("Memory " + ct.getMemory()); System.out.println("percentage " + percent); if (percent > 5) { //reale value 70 var = Integer.parseInt(ct.getMemory()) / 1000000; System.out.println("var " + var); System.out.println("var +1 " + (++var)); //updateTemplate(int container, int ram , int cpu) updateContainer(Integer.parseInt(ct.getVmid()), var + 50, 0, 0); //ct.setMemory(var); //iaas.UpdateContainer(ct); } } } catch (JSONException | LoginException | IOException ex) { Logger.getLogger(Monitoring.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:org.cellcore.code.engine.page.extractor.mfrag.MFRAGPageDataExtractor.java
@Override protected float getPrice(Document doc) { String var = doc.select(".prod-det_prix").text(); return Float.parseFloat(this.cleanPriceString(var)); }
From source file:com.ebay.nest.io.sede.lazy.LazyFloat.java
@Override public void init(ByteArrayRef bytes, int start, int length) { String byteData = null;/* w w w.j a v a 2 s. c o m*/ try { byteData = Text.decode(bytes.getData(), start, length); data.set(Float.parseFloat(byteData)); isNull = false; } catch (NumberFormatException e) { isNull = true; LOG.debug("Data not in the Float data type range so converted to null. Given data is :" + byteData, e); } catch (CharacterCodingException e) { isNull = true; LOG.debug("Data not in the Float data type range so converted to null.", e); } }
From source file:com.mobileacuity.android.cloudmvsdemo.Result.java
public static Result[] unpackJsonResultsList(String json) throws JSONException { JSONArray jsonArray = new JSONArray(json); List<Result> resultsList = new LinkedList<Result>(); for (int resultIdx = 0; resultIdx < jsonArray.length(); resultIdx += 1) { JSONObject jsonObject = jsonArray.getJSONObject(resultIdx); String raw = jsonObject.getString(RAW); String result = jsonObject.getString(RESULT); float score = (float) jsonObject.getDouble(SCORE); String centre = jsonObject.getString(CENTRE); int commaPos = centre.indexOf(','); float cx = Float.parseFloat(centre.substring(0, commaPos)); float cy = Float.parseFloat(centre.substring(commaPos + 1)); resultsList.add(new Result(raw, result, score, cx, cy)); }//from w w w .j av a 2 s . c om Result[] results = new Result[resultsList.size()]; resultsList.toArray(results); return results; }
From source file:net.sourceforge.processdash.ui.web.reports.DiscChart.java
public static JFreeChart createDiscChart(ResultSet data, Map parameters) { // data.sortBy(1, true); CategoryDataset catData = data.catDataSource(); PieDataset pieData = null;/*from ww w.j a va 2 s . c o m*/ if (catData.getColumnCount() == 1) pieData = DatasetUtilities.createPieDatasetForColumn(catData, 0); else pieData = DatasetUtilities.createPieDatasetForRow(catData, 0); DiscPlot plot = new DiscPlot(pieData); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); plot.setDrawingSupplier(DRAWING_SUPPLIER_FACTORY.newDrawingSupplier()); JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false); if (parameters.get("skipItemLabels") != null || parameters.get("skipDiscLabels") != null) plot.setLabelGenerator(null); else if (parameters.get("discLabelFontSize") != null) try { float fontSize = Float.parseFloat((String) parameters.get("discLabelFontSize")); plot.setLabelFont(plot.getLabelFont().deriveFont(fontSize)); } catch (Exception lfe) { } if (parameters.get("ellipse") != null) ((StandardDiscItemDistributor) plot.getDiscDistributor()).setCircular(false); String interiorGap = (String) parameters.get("interiorGap"); if (interiorGap != null) try { plot.setInteriorGap(Integer.parseInt(interiorGap) / 100.0); } catch (NumberFormatException e) { } String interiorSpacing = (String) parameters.get("interiorSpacing"); if (interiorSpacing != null) try { plot.setInteriorGap(Integer.parseInt(interiorSpacing) / 200.0); } catch (NumberFormatException e) { } return chart; }
From source file:api.Controller.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w .j a v a2 s . c om * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //API responds with JSON response.setContentType("application/json"); try (PrintWriter out = response.getWriter()) { //Perform different operations based on the path that was requested JSONObject data = new JSONObject(); switch (request.getRequestURI()) { case "/getNearestKLocationsAtCounty": data.put("ok", Test.getNearestKLocationsAtCounty()); break; case "/getLocationsInBound": float low_lat = Float.parseFloat(request.getParameter("low_lat")); float low_long = Float.parseFloat(request.getParameter("low_long")); float high_lat = Float.parseFloat(request.getParameter("high_lat")); float high_long = Float.parseFloat(request.getParameter("high_long")); ArrayList<County> result = FileLoader.tree .getLocationsInBound(new Bound(low_long, high_long, low_lat, high_lat)); ArrayList<JSONObject> results = new ArrayList<JSONObject>(); for (County c : result) { JSONObject temp = new JSONObject(); temp.put("long", c.lon); temp.put("lat", c.lat); temp.put("state", c.state); temp.put("title", c.title); results.add(temp); } data.put("results", results); break; case "/getLocationsAtCounty": data.put("ok", Test.getLocationsAtCounty()); break; case "/getNearestKLocationsAtCoord": float lat = Float.parseFloat(request.getParameter("lat")); float lng = Float.parseFloat(request.getParameter("long")); int k = Integer.parseInt(request.getParameter("k")); ArrayList<County> kResult = FileLoader.tree.getNearestKLocationsAtPoint(lng, lat, k); ArrayList<JSONObject> kJSONResults = new ArrayList<JSONObject>(); for (County c : kResult) { JSONObject temp = new JSONObject(); temp.put("long", c.lon); temp.put("lat", c.lat); temp.put("state", c.state); temp.put("title", c.title); kJSONResults.add(temp); } data.put("results", kJSONResults); break; case "/isWithinBound": int x = Integer.parseInt(request.getParameter("locationX")); int y = Integer.parseInt(request.getParameter("locationY")); data.put("mouseX", x); data.put("mouseY", y); data.put("ok", Test.isWithinBound(x, y)); break; default: JSONArray endpoints = new JSONArray(); endpoints.put("/NearestFinderServer/getNearestKLocationsAtCounty"); endpoints.put("/NearestFinderServer/getLocationsInBound"); endpoints.put("/NearestFinderServer/getLocationsAtCounty"); endpoints.put("/NearestFinderServer/getNearestKLocationsAtCoord"); endpoints.put("/NearestFinderServer/isWithinBound"); data.put("error", "request not recognized"); data.put("available endpoints", endpoints); break; } out.println(data); } }
From source file:com.kbotpro.cache.xml.XMLParser.java
public Object getValue(Element element) { final String type = element.getAttributeValue("type"); if (type == null) { return null; }/* www.j a v a 2 s. c o m*/ if (element.getText() == null) { return null; } if (type.equals("int")) { return Integer.parseInt(element.getText()); } if (type.equals("long")) { return Long.parseLong(element.getText()); } if (type.equals("double")) { return Double.parseDouble(element.getText()); } if (type.equals("float")) { return Float.parseFloat(element.getText()); } if (type.equals("boolean")) { return Boolean.parseBoolean(element.getText()); } if (type.equals("base64")) { return Base64.decodeBase64(element.getText()); } if (type.equals("string")) { return element.getText(); } if (type.equals("null")) { return null; } return null; }
From source file:edu.uci.ics.asterix.optimizer.base.FuzzyUtils.java
public static IAObject getSimThreshold(AqlMetadataProvider metadata, String simFuncName) { String simThresholValue = metadata.getPropertyValue(SIM_THRESHOLD_PROP_NAME); IAObject ret = null;/* w w w . j a va 2s . c o m*/ if (simFuncName.equals(JACCARD_FUNCTION_NAME)) { if (simThresholValue != null) { float jaccThresh = Float.parseFloat(simThresholValue); ret = new AFloat(jaccThresh); } else { ret = new AFloat(JACCARD_DEFAULT_SIM_THRESHOLD); } } else if (simFuncName.equals(EDIT_DISTANCE_FUNCTION_NAME)) { if (simThresholValue != null) { int edThresh = Integer.parseInt(simThresholValue); ret = new AInt32(edThresh); } else { ret = new AFloat(EDIT_DISTANCE_DEFAULT_SIM_THRESHOLD); } } return ret; }