List of usage examples for java.lang Double Double
@Deprecated(since = "9") public Double(String s) throws NumberFormatException
From source file:edu.anu.spice.Evaluation.java
@SuppressWarnings("unchecked") @Override//from w w w . j a va2s. co m public String toJSONString() { JSONObject jsonObj = new JSONObject(); jsonObj.put("tp", new Integer(tp)); jsonObj.put("fp", new Integer(fp)); jsonObj.put("fn", new Integer(fn)); jsonObj.put("f", new Double(f)); jsonObj.put("pr", new Double(pr)); jsonObj.put("re", new Double(re)); jsonObj.put("numImages", new Integer(numImages)); return JSONValue.toJSONString(jsonObj); }
From source file:org.jfree.data.category.junit.DefaultCategoryDatasetTest.java
/** * Some checks for the getValue() method. *///from w w w . j a va 2s . c o m public void testGetValue() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); assertEquals(new Double(1.0), d.getValue("R1", "C1")); boolean pass = false; try { d.getValue("XX", "C1"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { d.getValue("R1", "XX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); }
From source file:com.fredhopper.connector.index.provider.ProductPriceValueProvider.java
private void addPriceValue(final HashBasedTable<Optional<String>, Optional<Locale>, String> table, final PriceInformation priceInformation) { final String value = String.format(java.util.Locale.US, "%.2f", new Double(priceInformation.getPriceValue().getValue())); table.put(Optional.empty(), Optional.empty(), value); }
From source file:ijfx.ui.utils.ChartUpdater.java
public void updateChart() { final double min; // minimum value final double max; // maximum value double range; // max - min final double binSize; // int maximumBinNumber = 30; int finalBinNumber; int differentValuesCount = possibleValues.stream().filter(n -> Double.isFinite(n.doubleValue())) .collect(Collectors.toSet()).size(); if (differentValuesCount < maximumBinNumber) { finalBinNumber = differentValuesCount; } else {/*from w w w . ja v a2 s.com*/ finalBinNumber = maximumBinNumber; } EmpiricalDistribution distribution = new EmpiricalDistribution(finalBinNumber); Double[] values = possibleValues.parallelStream().filter(n -> Double.isFinite(n.doubleValue())) .map(v -> v.doubleValue()).sorted() //.toArray(); .toArray(size -> new Double[size]); distribution.load(ArrayUtils.toPrimitive(values)); min = values[0]; max = values[values.length - 1]; range = max - min; binSize = range / (finalBinNumber - 1); //System.out.println(String.format("min = %.0f, max = %.0f, range = %.0f, bin size = %.0f, bin number = %d", min, max, range, binSize, finalBinNumber)); XYChart.Series<Double, Double> serie = new XYChart.Series<>(); ArrayList<XYChart.Data<Double, Double>> data = new ArrayList<>(); double k = min; for (SummaryStatistics st : distribution.getBinStats()) { data.add(new XYChart.Data<>(k, new Double(st.getN()))); k += binSize; } Platform.runLater(() -> { serie.getData().addAll(data); areaChart.getData().clear(); areaChart.getData().add(serie); }); }
From source file:eu.smartfp7.terrier.sensor.ParserUtility.java
public static EdgeNodeSnapShot parse(InputStream is) throws Exception { DocumentBuilderFactory xmlfact = DocumentBuilderFactory.newInstance(); xmlfact.setNamespaceAware(true);/*from ww w .j av a 2 s. com*/ Document document = xmlfact.newDocumentBuilder().parse(is); NamespaceContext ctx = new NamespaceContext() { @Override public Iterator getPrefixes(String namespaceURI) { // TODO Auto-generated method stub return null; } @Override public String getPrefix(String namespaceURI) { // TODO Auto-generated method stub return null; } @Override public String getNamespaceURI(String prefix) { String uri = null; /* * xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:smart="http://www.ait.gr/ait_web_site/faculty/apne/schema.xml#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:contact="http://www.w3.org/2000/10/swap/pim/contact#" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:time="http://www.w3.org/2006/time#" xml:base="http://www.ait.gr/ait_web_site/faculty/apne/report.xml" * */ if (prefix.equals("rdf")) { uri = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; } if (prefix.equals("smart")) { uri = "http://www.ait.gr/ait_web_site/faculty/apne/schema.xml#"; } if (prefix.equals("dc")) { uri = "http://purl.org/dc/elements/1.1/#"; } if (prefix.equals("geo")) { uri = "http://www.w3.org/2003/01/geo/wgs84_pos#"; } if (prefix.equals("time")) { uri = "http://www.w3.org/2006/time#"; } return uri; } }; // find the node data XPath xpath = XPathFactory.newInstance().newXPath(); xpath.setNamespaceContext(ctx); String id = (String) xpath.compile("//smart:Node/@rdf:ID").evaluate(document, XPathConstants.STRING); String lat = (String) xpath.compile("//smart:Node/geo:lat/text()").evaluate(document, XPathConstants.STRING); String lon = (String) xpath.compile("//smart:Node/geo:long/text()").evaluate(document, XPathConstants.STRING); String fullName = (String) xpath.compile("//smart:Node/dc:fullName/text()").evaluate(document, XPathConstants.STRING); Node node = new Node(new Double(lat), new Double(lon), id, fullName); String time = (String) xpath.compile("//smart:Report/time:inXSDDateTime/text()").evaluate(document, XPathConstants.STRING); String reportId = (String) xpath.compile("//smart:Report/@rdf:ID").evaluate(document, XPathConstants.STRING); DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); Calendar c = Calendar.getInstance(); ; c.setTime(df.parse(time)); String density = (String) xpath.compile("//smart:Crowd/smart:density/text()").evaluate(document, XPathConstants.STRING); String cameraGain = (String) xpath.compile("//smart:Crowd/smart:cameraGain/text()").evaluate(document, XPathConstants.STRING); NodeList list = (NodeList) xpath.compile("//smart:Crowd/smart:colour").evaluate(document, XPathConstants.NODESET); double[] colors = new double[list.getLength()]; for (int i = 0; i < list.getLength(); i++) { org.w3c.dom.Node colorNode = list.item(i); String v = colorNode.getFirstChild().getTextContent(); colors[i] = new Double(v); } CrowdReport crowdReport = new CrowdReport(reportId, new Double(density), new Double(cameraGain), colors); EdgeNodeSnapShot snapShot = new EdgeNodeSnapShot(node, id, c, crowdReport); return snapShot; }
From source file:com.aliyun.odps.ship.common.RecordConverterTest.java
/** * ?string<->record?<br/>// w ww .ja v a2 s . c om * ?BIGINT\STRING\DATETIME\BOOLEAM\BOUBLE\DECIMAL<br/> * <br/> * 1) ??string?tunnelrecord.<br/> * 2) ?rocord??string<br/> * */ @Test public void testNormal() throws Exception { TableSchema rs = new TableSchema(); rs.addColumn(new Column("i1", OdpsType.BIGINT)); rs.addColumn(new Column("s1", OdpsType.STRING)); rs.addColumn(new Column("d1", OdpsType.DATETIME)); rs.addColumn(new Column("b1", OdpsType.BOOLEAN)); rs.addColumn(new Column("doub1", OdpsType.DOUBLE)); rs.addColumn(new Column("de1", OdpsType.DOUBLE)); String[] l = new String[] { "1", "string", "20130925101010", "true", "2345.1209", "2345.1" }; RecordConverter cv = new RecordConverter(rs, "NULL", "yyyyMMddHHmmss", null); Record r = cv.parse(toByteArray(l)); SimpleDateFormat formater = new SimpleDateFormat("yyyyMMddHHmmss"); formater.setTimeZone(gmt); assertEquals("bigint not equal.", Long.valueOf(1), r.getBigint(0)); assertEquals("string not equal.", "string", r.getString(1)); assertEquals("datetime not equal.", formater.parse("20130925101010"), r.getDatetime(2)); assertEquals("boolean not equal.", Boolean.valueOf("true"), r.getBoolean(3)); assertEquals("double not equal.", new Double("2345.1209"), r.getDouble(4)); // assertEquals("decimal not equal.", new BigDecimal("2345.1"), r.getDecimal(5)); byte[][] l1 = cv.format(r); for (int i = 0; i < l1.length; i++) { assertEquals("converter at index:" + i, l[i], new String(l1[i], "UTF-8")); } }
From source file:com.orange.atk.atkUI.coregui.StatisticTool.java
/** * Creates data set with percentage of passed, failed, skipped and not * analysed./* www .j a va 2 s . c om*/ * * @return the data set */ private PieDataset createSampleDataset() { DefaultPieDataset defaultpiedataset = new DefaultPieDataset(); int passed = 0; int failed = 0; int skipped = 0; int notAnalyzed = 0; for (int i = 0; i < campaign.size(); i++) { Step cmdLine = (Step) campaign.get(i); if (cmdLine.getVerdict() == Verdict.PASSED) { passed++; } else if (cmdLine.getVerdict() == Verdict.FAILED) { failed++; } else if (cmdLine.getVerdict() == Verdict.SKIPPED) { skipped++; } else if (cmdLine.getVerdict() == Verdict.NONE) { notAnalyzed++; } } int total = passed + failed + skipped + notAnalyzed; defaultpiedataset.setValue("Passed", new Double(passed * 100 / (double) total)); data.put("Passed", passed); defaultpiedataset.setValue("Failed", new Double(failed * 100 / (double) total)); data.put("Failed", failed); defaultpiedataset.setValue("Skipped", new Double(skipped * 100 / (double) total)); data.put("Skipped", skipped); defaultpiedataset.setValue("Not analysed", new Double(notAnalyzed * 100 / (double) total)); data.put("Not analysed", notAnalyzed); data.put("Total", total); return defaultpiedataset; }
From source file:org.jfree.chart.demo.TimeSeriesDemo5.java
/** * Creates a sample dataset.//from w w w .j a va 2s . co m * * @return A sample dataset. */ private XYDataset createDataset() { final TimeSeries series = new TimeSeries("Random Data"); Day current = new Day(1, 1, 1990); double value = 100.0; for (int i = 0; i < 4000; i++) { try { value = value + Math.random() - 0.5; series.add(current, new Double(value)); current = (Day) current.next(); } catch (SeriesException e) { System.err.println("Error adding to series"); } } return new TimeSeriesCollection(series); }
From source file:Main.java
private static final Object readThisValueXml(XmlPullParser parser, String[] name) throws XmlPullParserException, java.io.IOException { final String valueName = parser.getAttributeValue(null, "name"); final String tagName = parser.getName(); //System.out.println("Reading this value tag: " + tagName + ", name=" + valueName); Object res;/*from w ww.j av a 2 s . c o m*/ if (tagName.equals("null")) { res = null; } else if (tagName.equals("string")) { String value = ""; int eventType; while ((eventType = parser.next()) != parser.END_DOCUMENT) { if (eventType == parser.END_TAG) { if (parser.getName().equals("string")) { name[0] = valueName; //System.out.println("Returning value for " + valueName + ": " + value); return value; } throw new XmlPullParserException("Unexpected end tag in <string>: " + parser.getName()); } else if (eventType == parser.TEXT) { value += parser.getText(); } else if (eventType == parser.START_TAG) { throw new XmlPullParserException("Unexpected start tag in <string>: " + parser.getName()); } } throw new XmlPullParserException("Unexpected end of document in <string>"); } else if (tagName.equals("int")) { res = Integer.parseInt(parser.getAttributeValue(null, "value")); } else if (tagName.equals("long")) { res = Long.valueOf(parser.getAttributeValue(null, "value")); } else if (tagName.equals("float")) { res = new Float(parser.getAttributeValue(null, "value")); } else if (tagName.equals("double")) { res = new Double(parser.getAttributeValue(null, "value")); } else if (tagName.equals("boolean")) { res = Boolean.valueOf(parser.getAttributeValue(null, "value")); } else if (tagName.equals("int-array")) { parser.next(); res = readThisIntArrayXml(parser, "int-array", name); name[0] = valueName; //System.out.println("Returning value for " + valueName + ": " + res); return res; } else if (tagName.equals("map")) { parser.next(); res = readThisMapXml(parser, "map", name); name[0] = valueName; //System.out.println("Returning value for " + valueName + ": " + res); return res; } else if (tagName.equals("list")) { parser.next(); res = readThisListXml(parser, "list", name); name[0] = valueName; //System.out.println("Returning value for " + valueName + ": " + res); return res; } else { throw new XmlPullParserException("Unknown tag: " + tagName); } // Skip through to end tag. int eventType; while ((eventType = parser.next()) != parser.END_DOCUMENT) { if (eventType == parser.END_TAG) { if (parser.getName().equals(tagName)) { name[0] = valueName; //System.out.println("Returning value for " + valueName + ": " + res); return res; } throw new XmlPullParserException("Unexpected end tag in <" + tagName + ">: " + parser.getName()); } else if (eventType == parser.TEXT) { throw new XmlPullParserException("Unexpected text in <" + tagName + ">: " + parser.getName()); } else if (eventType == parser.START_TAG) { throw new XmlPullParserException("Unexpected start tag in <" + tagName + ">: " + parser.getName()); } } throw new XmlPullParserException("Unexpected end of document in <" + tagName + ">"); }
From source file:org.jfree.data.WaferMapDataset.java
/** * Creates a new dataset./* ww w. j a va 2s.c om*/ * * @param maxChipX * the wafer x-dimension. * @param maxChipY * the wafer y-dimension. * @param chipSpace * the space between chips. */ public WaferMapDataset(final int maxChipX, final int maxChipY, final Number chipSpace) { this.maxValue = new Double(Double.NEGATIVE_INFINITY); this.minValue = new Double(Double.POSITIVE_INFINITY); this.data = new DefaultKeyedValues2D(); this.maxChipX = maxChipX; this.maxChipY = maxChipY; if (chipSpace == null) { this.chipSpace = DEFAULT_CHIP_SPACE; } else { this.chipSpace = chipSpace.doubleValue(); } }