List of usage examples for java.lang Double parseDouble
public static double parseDouble(String s) throws NumberFormatException
From source file:dingwen.Command.java
public static void containsCmd(String command, ShapeCache shapeCache) { String x_coordinate = command.substring(command.indexOf(" ") + 1, command.lastIndexOf(" ")); String y_coordinate = command.substring(command.lastIndexOf(" ") + 1); if (!NumberUtils.isParsable(x_coordinate) || !NumberUtils.isParsable(y_coordinate)) { System.out.println(CommonStatement.INPUT_INVALID); return;// ww w . j ava 2 s .co m } double x = Double.parseDouble(command.substring(command.indexOf(" "), command.lastIndexOf(" "))); double y = Double.parseDouble(command.substring(command.lastIndexOf(" "))); Point p = new Point(x, y); double totalArea = 0; Iterator it = shapeCache.getShapes().entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); BigInteger id = (BigInteger) pair.getKey(); Shape shape = (Shape) pair.getValue(); if (shape.contains(p)) { System.out.println("shape " + id + " " + shape); System.out.println("area is " + shape.area()); totalArea += shape.area(); } } System.out.println("total area is " + totalArea); }
From source file:uk.ac.ebi.intact.editor.config.property.DoublePropertyConverter.java
@Override public Double convertFromString(String str) { if (str == null) return null; return Double.parseDouble(str); }
From source file:at.ac.tuwien.dsg.utility.DesignChart.java
public void chart(LinkedList<String> xValue, LinkedList<String> yValue) throws Exception { XYSeries series = new XYSeries("Sensory Data"); final JFreeChart chart; //data assignment in the chart {// ww w . j a va2 s.c om for (int i = 0; i < xValue.size(); i++) { series.add(Double.parseDouble(xValue.get(i)), Double.parseDouble(yValue.get(i))); } final XYSeriesCollection data = new XYSeriesCollection(series); chart = ChartFactory.createXYLineChart("Graph Visualization", "collection_time", "collection_data", data, PlotOrientation.VERTICAL, true, true, false); } //design the plot of the chart { XYPlot xyPlot = chart.getXYPlot(); NumberAxis xAxis = (NumberAxis) xyPlot.getDomainAxis(); NumberAxis yAxis = (NumberAxis) xyPlot.getRangeAxis(); xAxis.setRange(20, 120); xAxis.setTickUnit(new NumberTickUnit(15)); yAxis.setRange(947, 950); yAxis.setTickUnit(new NumberTickUnit(0.5)); } //generation of the image { try { BufferedImage img = chart.createBufferedImage(300, 200); //File outputfile = new File("./example/Sample.png"); File outputfile = new File( "/Users/dsg/Documents/phd/Big Demo/CloudLyra/Utils/JBPMEngine/example/Sample.png"); ImageIO.write(img, "png", outputfile); } catch (Exception e) { System.out.println("exception occured in tomcat: " + e); } } }
From source file:ColdestWeather.ColdestWeather.java
public CSVRecord checkColdest(CSVRecord currentRow, CSVRecord coldestSoFar) { if (coldestSoFar == null) { coldestSoFar = currentRow;// ww w. ja v a 2s.c om } else { double currentTemp = Double.parseDouble(currentRow.get("TemperatureF")); double coldestTemp = Double.parseDouble(coldestSoFar.get("TemperatureF")); //Check if currentTemp < coldestTemp if (currentTemp < coldestTemp && currentTemp > -9000) { //Update coldesSoFar to currentRow coldestSoFar = currentRow; } } return coldestSoFar; }
From source file:com.tsg.sitemapwebappmvc.controller.TipCalcController.java
@RequestMapping(value = "/TipCalcController", method = RequestMethod.POST) public String getTipCalcResults(HttpServletRequest request, Model model) { String serviceCost = request.getParameter("costOfService"); double cost = Double.parseDouble(serviceCost); String tipPercentage = request.getParameter("tipPercent"); double tips = Double.parseDouble(tipPercentage); TipCalculator tipper = new TipCalculator(cost, tips); double tipNow = tipper.CalculateTip(); request.setAttribute("tip", tipNow); return "tipcalcresponse"; }
From source file:com.atomiton.watermanagement.ngo.Resource.java
/** * This method is use to get all residents model details. * @return//from w ww. ja v a 2 s . c o m */ public static List<Residents> getAllResidents() { String query = "<Query><Find><Residents><Id><ne></ne></Id></Residents></Find></Query>"; List<Residents> residentsList = new ArrayList<Residents>(); try { String response = HttpRequestResponseHandler.sendPost(Constants.SERVER_URL, query); JSONObject object = WaterMgmtNGOUtility.convertXMLToJSON(response); JSONArray residentsObj = object.getJSONObject("Find").getJSONArray("Result"); for (int i = 0; i < residentsObj.length(); i++) { JSONObject resident = residentsObj.getJSONObject(i).getJSONObject("Residents"); Residents obj = new Residents(); obj.setName(resident.getString("Name")); obj.setMonthlyAllowance(resident.getDouble("MonthlyAllowance")); obj.setBudgetBalance((resident.getString("BudgetBalance").equals("")) ? 0 : Double.parseDouble(resident.getString("BudgetBalance"))); obj.setContamination(resident.getBoolean("Contamination")); obj.setDaysOfAccess(resident.getInt("DaysOfAccess")); obj.setMobile(resident.getString("Mobile")); obj.setHealthCost(resident.getString("HealthCost").equals("") ? 0 : Double.parseDouble(resident.getString("HealthCost"))); /*System.out.println("Resident id ==================="+resident.getString("Id")); System.out.println("HourCost ======================="+resident.get("HourCost").getClass());*/ obj.setHourCost(resident.get("HourCost") == null || resident.get("HourCost").equals("") ? 0 : Double.parseDouble(resident.getString("HourCost"))); obj.setResidentID(resident.getString("ResidentID")); obj.setSourceGuideID(resident.getString("SourceGuideID")); obj.setSourceType(""); // System.out.println("Travel distance ======================="+resident.get("TravelDistance").getClass()); obj.setTravelDistance( resident.get("TravelDistance") == null || resident.get("TravelDistance").equals("") ? 0 : resident.getDouble("TravelDistance")); obj.setTravelTime(resident.get("TravelTime") == null || resident.get("TravelTime").equals("") ? 0 : resident.getDouble("TravelTime")); obj.setUnitCost( resident.getString("UnitCost").equals("") || resident.getString("UnitCost").equals("0E-10") ? 0 : Double.parseDouble(resident.getString("UnitCost"))); obj.setWaterCost(resident.getString("WaterCost").equals("") ? 0 : Double.parseDouble(resident.getString("WaterCost"))); obj.setWaterAccess( resident.get("WaterAccess") == null || resident.get("WaterAccess").equals("") ? false : resident.getBoolean("WaterAccess")); obj.setWaterSourceID(resident.getString("WaterSourceID")); obj.setWaterNeed(resident.getString("WaterNeed").equals("") ? 0 : Double.parseDouble(resident.getString("WaterNeed"))); /*GeoLocation location= new GeoLocation();*/ JSONObject houseLocObject = resident.getJSONObject("HouseLocation"); /*location.setLatitude(houseLocObject.getDouble("latitude")); location.setLongitude(houseLocObject.getDouble("longitude"));*/ obj.setHouseLocation_latitude(String.valueOf(houseLocObject.getDouble("latitude"))); obj.setHouseLocation_longitude(String.valueOf(houseLocObject.getDouble("longitude"))); obj.setRecordDate(resident.getString("RecordDate")); obj.setId(resident.getString("Id")); residentsList.add(obj); } System.out.println("Response message for getAllResidents === " + residentsList.size()); } catch (Exception e) { e.printStackTrace(); } return residentsList; }
From source file:uta.ak.usttmp.common.dao.mapper.TopicRowMapper.java
@Override public Object mapRow(ResultSet rs, int rowNum) throws SQLException { Topic tp = new Topic(); tp.setId(rs.getLong("mme_eid")); tp.setName(rs.getString("name")); tp.setRemark(rs.getString("remark")); tp.setSeq(rs.getInt("seq_no")); tp.setMiningTaskId(rs.getLong("miningtask_id")); String content = rs.getString("content"); String[] wordProbs = content.split(","); for (String wpstr : wordProbs) { String[] wp = wpstr.split(":"); tp.addWordProbability(wp[0], Double.parseDouble(wp[1])); }//from w ww . j a v a 2s. c om return tp; }
From source file:com.tsg.sitemapwebappmvc.controller.InterestCalcController.java
@RequestMapping(value = "/InterestCalcController", method = RequestMethod.POST) public String getInterestCalcResults(HttpServletRequest request, Model model) { String newAPR = request.getParameter("percentageToCalc"); Double apr = Double.parseDouble(newAPR); String newPrincipal = request.getParameter("intitialPrincipal"); Double principal = Double.parseDouble(newPrincipal); String investLength = request.getParameter("periodToInvest"); int year = Integer.parseInt(investLength); String compoundType = request.getParameter("typeOfCompounding"); InterestCalc.TypeOfCompounding type = InterestCalc.TypeOfCompounding.fromAbbrv(compoundType); InterestCalc calc = new InterestCalc(apr, principal, year, type); request.setAttribute("interestYearsCalcs", calc.getYearlyInterestCalculations()); request.setAttribute("interestCalcError", calc.getError()); return "icresponse"; }
From source file:algoritma.LoadData.java
public void read(String filePath, int confi) throws FileNotFoundException, IOException { FileReader fileReader = null; CSVParser csvFileParser = null;//from w ww . j a va2 s . c o m CSVFormat csvFileFormat = CSVFormat.EXCEL.withFirstRecordAsHeader(); fileReader = new FileReader(filePath); csvFileParser = new CSVParser(fileReader, csvFileFormat); List csvRecords = csvFileParser.getRecords(); for (int i = 0; i < csvRecords.size(); i++) { CSVRecord record = (CSVRecord) csvRecords.get(i); double confidence = Double.parseDouble(record.get("confidence")); if (confidence >= confi) { Point p = new Point(); p.setBrightness(Double.parseDouble(record.get("brightness"))); p.setBright_t31(Double.parseDouble(record.get("bright_t31"))); p.setFrp(Double.parseDouble(record.get("frp"))); p.add(p); } } }
From source file:moacscoper.Parser.java
public void addServers() throws IOException { List<CSVRecord> vms = parse("vm.dat"); int serverNumber = 1; int performance; double reliability; double cost;/*from ww w .j a v a 2 s.c o m*/ for (CSVRecord r : vms) { performance = Integer.parseInt(r.get(0)); reliability = Double.parseDouble(r.get(1)); cost = Double.parseDouble(r.get(2)); this.sim.servers.add(new Server(serverNumber + "", performance, reliability, cost)); serverNumber++; } }