List of usage examples for java.lang Double Double
@Deprecated(since = "9") public Double(String s) throws NumberFormatException
From source file:gov.nih.nci.caintegrator.application.zip.ZipManager.java
/** * Compute the percentage of series that have * been processed. Used by the progress bar * /*from w w w .ja v a2 s. com*/ * @return */ public Integer getPercentProcessed() { if (totalBytesToZip != 0) { return new Double(bytesZippedSoFar * 100 / totalBytesToZip).intValue(); } else return 0; }
From source file:org.jfree.chart.demo.ThermometerDemo2.java
/** * Creates a new demo./*ww w .j ava 2 s . co m*/ * * @param title the frame title. */ public ThermometerDemo2(final String title) { super(title); // create a dataset... final DefaultValueDataset dataset = new DefaultValueDataset(new Double(43.0)); // create the chart... final ThermometerPlot plot = new ThermometerPlot(dataset); final JFreeChart chart = new JFreeChart("Thermometer Demo 2", // chart title JFreeChart.DEFAULT_TITLE_FONT, plot, // plot false); // include legend // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // plot.setInsets(new Insets(5, 5, 5, 5)); //plot.setRangeInfo(ThermometerPlot.NORMAL, 0.0, 55.0, 0.0, 100.0); //plot.setRangeInfo(ThermometerPlot.WARNING, 55.0, 75.0, 0.0, 100.0); //plot.setRangeInfo(ThermometerPlot.CRITICAL, 75.0, 100.0, 0.0, 100.0); plot.setThermometerStroke(new BasicStroke(2.0f)); plot.setThermometerPaint(Color.lightGray); // OPTIONAL CUSTOMISATION COMPLETED. // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); setContentPane(chartPanel); }
From source file:org.hxzon.demo.jfreechart.PieDatasetDemo.java
private static PieDataset createDataset() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("One", new Double(43.2)); dataset.setValue("Two", new Double(10.0)); dataset.setValue("Three", new Double(27.5)); dataset.setValue("Four", new Double(17.5)); dataset.setValue("Five", new Double(11.0)); dataset.setValue("Six", new Double(19.4)); return dataset; }
From source file:edu.umd.umiacs.clip.tools.classifier.ConfusionMatrix.java
public static ConfusionMatrix loadLibSVM(String goldPath, String predPath, double... cutoffs) { int[] gold = readAllLines(goldPath).stream().mapToInt(line -> new Integer(line.split("\\s+")[0])).toArray(); IntSummaryStatistics stats = Arrays.stream(gold).summaryStatistics(); double cutoff = stats.getMin() == stats.getMax() ? cutoffs[0] : ((stats.getMax() + stats.getMin()) / 2); List<Boolean> goldList = Arrays.stream(gold).boxed().map(i -> i > cutoff).collect(toList()); List<Boolean> predList = readAllLines(predPath).stream().map(pred -> new Double(pred) > cutoff) .collect(toList());// w w w.ja va 2 s . c o m return new ConfusionMatrix(goldList, predList); }
From source file:org.openmrs.module.kenyaemr.wrapper.EncounterWrapperTest.java
/** * @see EncounterWrapper#firstObs(org.openmrs.Concept) *//*from w w w .j ava2 s. c o m*/ @Test public void firstObs_shouldFindFirstObsWithConcept() { Encounter e = new Encounter(); EncounterWrapper wrapper = new EncounterWrapper(e); // Test empty encounter Assert.assertNull(wrapper.firstObs(Dictionary.getConcept(Dictionary.CD4_COUNT))); // Add obs to encounter Obs obs0 = new Obs(); obs0.setConcept(Dictionary.getConcept(Dictionary.CD4_PERCENT)); obs0.setValueNumeric(50.0); e.addObs(obs0); Obs obs1 = new Obs(); obs1.setConcept(Dictionary.getConcept(Dictionary.CD4_COUNT)); obs1.setValueNumeric(123.0); e.addObs(obs1); Assert.assertEquals(new Double(123.0), wrapper.firstObs(Dictionary.getConcept(Dictionary.CD4_COUNT)).getValueNumeric()); }
From source file:ejp.examples.InDepthExample.java
public InDepthExample(DatabaseManager dbm) throws DatabaseException { // Clean out customers dbm.executeUpdate("delete from customers"); // Inserting customer with associations Customer customer = new Customer("deisenhower", "mypasswd5", "Dwight", "Eisenhower", "United States", "deisenhower@unitedstates.gov"); customer.getSupport().add(new Support("Request", "New", "no phone", "deisenhower@unitedstates.gov", "Can I have my bust on a dollar, please.")); customer.getSupport().add(new Support("Response", "Pending", "no phone", "deisenhower@unitedstates.gov", "Yes, but you may have to share it.")); customer.getSupport().add(/*from w w w . j av a2 s .c o m*/ new Support("Request", "New", "no phone", "deisenhower@unitedstates.gov", "Share it with who?")); customer.getOrders() .add(new Order("Dwight D. Eisenhower Dollar", new Integer(100), new Double(1.00), "unverified")); customer.getOrders() .add(new Order("Susan B. Anthony Dollar", new Integer(100), new Double(1.00), "unverified")); // Saving within an automatic transaction (covers all relationships) dbm.saveObject(customer); // Add an associated record and update customer.getSupport().add(new Support("Response", "Closed", "no phone", "deisenhower@unitedstates.gov", "You'll have to share with Susan Anthony.")); dbm.saveObject(customer); /* * Saving within a transaction manager */ new TransactionManager(dbm) { public void run() throws DatabaseException { // Inserting customer with support and orders Customer customer = new Customer("alincoln", "mypasswd1", "Abraham", "Lincoln", null, "alincoln@unitedstates.gov"); customer.getSupport().add(new Support("Request", "New", "no phone", "alincoln@unitedstates.gov", "Can I have my bust on a penny, please.")); customer.getOrders() .add(new Order("Abraham Lincoln Penny", new Integer(100), new Double(.01), "unverified")); saveObject(customer); customer = new Customer("tjefferson", "mypasswd2", "Thomas", "Jefferson", "United States", "tjefferson@unitedstates.gov"); customer.getSupport().add(new Support("Request", "New", "no phone", "tjefferson@unitedstates.gov", "Can I have my bust on a nickel, please.")); customer.getOrders() .add(new Order("Thomas Jefferson Nickel", new Integer(100), new Double(.05), "unverified")); saveObject(customer); // Insert new customer only customer = new Customer("fdroosevelt", "mypasswd3", "Franklin", "Roosevelt", "United States", "fdroosevelt@unitedstates.gov"); saveObject(customer); // Add associated records and update customer.getSupport().add(new Support("Request", "New", "no phone", "fdroosevelt@unitedstates.gov", "Can I have my bust on a dime, please.")); customer.getOrders().add(new Order("Franklin Delano Roosevelt Dime", new Integer(100), new Double(.10), "unverified")); saveObject(customer); // can still freely use commit, savepoint and rollback commit(); Savepoint savepoint = null; if (supportsSavepoints()) savepoint = setSavepoint(); saveObject(customer = new Customer("gwashington", "mypasswd4", "George", "Washington", "United States", "gwashington@unitedstates.gov")); customer.getSupport().add(new Support("Request", "New", "no phone", "gwashington@unitedstates.gov", "Can I have my bust on a quarter, please.")); customer.getOrders().add( new Order("George Washington Quarter", new Integer(100), new Double(.25), "unverified")); saveObject(customer); if (supportsSavepoints()) { System.out.println("rolling back gwashington"); rollback(savepoint); } // same as this.saveObject getDatabase().saveObject(customer = new Customer("jkennedy", "mypasswd4", "John", "Kennedy", "United States", "gwashington@unitedstates.gov")); customer.getSupport().add(new Support("Request", "New", "no phone", "gwashington@unitedstates.gov", "Can I have my bust on the half dollar, please.")); customer.getSupport().add(new Support("Response", "Pending", "no phone", "nobody@unitedstates.gov", "Yes, we'll let you know")); customer.getOrders().add(new Order("John Fitzgerald Kennedy Half Dollar", new Integer(100), new Double(.50), "unverified")); getDatabase().saveObject(customer); } }.executeTransaction(); /* * The ejp.DatabaseManager way to load objects */ // Do not load associations PersistentClassManager.setIgnoreAssociations(Customer.class, true); customer = dbm.loadObject(Customer.class, "where :customerId like 'tjef%'"); // Load associations separately dbm.loadAssociations(customer); System.out.println("\ncustomerId = " + customer.getCustomerId()); // Reset associations PersistentClassManager.setIgnoreAssociations(Customer.class, false); // or Load based on information contained in objects customer = dbm.loadObject(new Customer("tjef%")); System.out.println("customerId = " + customer.getCustomerId()); // or with variable argument parameters customer = dbm.loadObject(Customer.class, "where :customerId like ?", "tjef%"); System.out.println("customerId = " + customer.getCustomerId() + "\n"); Collection<Customer> c = dbm.loadObjects(new ArrayList<Customer>(), Customer.class); for (Customer customer2 : c) System.out.println("customerId = " + customer2.getCustomerId()); System.out.println(); /* * The ejp.Database way to load objects */ Database db = dbm.getDatabase(); try { // Query all Result<Customer> result = db.queryObject(Customer.class, "order by :lastName"); // Result is Iterable for (Customer customer3 : result) { System.out.println(customer3); // Update a couple of mistakes if (customer3.getCustomerId().startsWith("jkennedy")) { customer3.setEmail("jkennedy@unitedstates.gov"); for (Support support : customer3.getSupport()) if (support.getEmail().startsWith("gwash") || support.getEmail().startsWith("nobody")) support.setEmail("jkennedy@unitedstates.gov"); db.saveObject(customer3); } else if (customer3.getCustomerId().startsWith("fdroosevelt")) { customer3.setCompanyName(null); db.saveObject(customer3); } } result.close(); result = db.queryObject(Customer.class, "order by :lastName"); // Print and delete while (result.hasNext() && (customer = result.next()) != null) { System.out.println(customer); db.deleteObject(customer); } result.close(); } finally { // also closes any open results db.close(); } }
From source file:com.appglu.impl.SavedQueriesTemplateTest.java
private void assertRow(Row row) { Assert.assertEquals(true, row.get("first")); Assert.assertEquals(new Integer(10), row.get("second")); Assert.assertEquals("string", row.get("third")); Assert.assertEquals(null, row.get("forth")); Assert.assertEquals(new Double(1.5), row.get("fifth")); }
From source file:net.sourceforge.fenixedu.util.tests.ResponseProcessing.java
public ResponseProcessing(int id) { responseProcessingId = id;/*from ww w .j av a 2 s . c o m*/ this.responseConditions = new ArrayList<ResponseCondition>(); this.responseValue = new Double(0); this.action = ADD; this.feedback = new ArrayList<LabelValueBean>(); this.fenixCorrectResponse = false; this.otherResponseProcessing = false; this.unansweredResponseProcessing = false; }
From source file:at.uni_salzburg.cs.ckgroup.cscpp.mapper.SquareZone.java
@SuppressWarnings("unchecked") @Override/* w ww. ja va 2s . com*/ public String toJSONString() { JSONObject o = new JSONObject(); o.put("type", "square"); JSONObject l = new JSONObject(); l.put("lat", new Double(maxLatitude)); l.put("lon", new Double(minLongitude)); o.put("leftTop", l); JSONObject r = new JSONObject(); r.put("lat", new Double(minLatitude)); r.put("lon", new Double(maxLongitude)); o.put("rightBottom", r); JSONObject d = new JSONObject(); d.put("lat", new Double(getDepotPosition().getLatitude())); d.put("lon", new Double(getDepotPosition().getLongitude())); o.put("depot", d); return null; }
From source file:at.uni_salzburg.cs.ckgroup.cscpp.mapper.CircleZone.java
@SuppressWarnings("unchecked") @Override/*from w w w. j av a 2s.co m*/ public String toJSONString() { JSONObject o = new JSONObject(); o.put("type", "circle"); o.put("radius", new Double(radius)); JSONObject c = new JSONObject(); c.put("lat", new Double(center.getLatitude())); c.put("lon", new Double(center.getLongitude())); o.put("center", c); JSONObject d = new JSONObject(); d.put("lat", new Double(getDepotPosition().getLatitude())); d.put("lon", new Double(getDepotPosition().getLongitude())); o.put("depot", c); return o.toJSONString(); }