List of usage examples for java.lang Double Double
@Deprecated(since = "9") public Double(String s) throws NumberFormatException
From source file:Visuals.BarChart.java
public ChartPanel drawBarChart() { DefaultCategoryDataset bardataset = new DefaultCategoryDataset(); bardataset.addValue(new Double(low), "Low (" + low + ")", lowValue); bardataset.addValue(new Double(medium), "Medium (" + medium + ")", mediumValue); bardataset.addValue(new Double(high), "High (" + high + ")", highValue); bardataset.addValue(new Double(critical), "Critical (" + critical + ")", criticalValue); JFreeChart barchart = ChartFactory.createBarChart(title, // Title riskCategory, riskCountTitle, bardataset // Dataset );//from ww w. j ava2 s.c om final CategoryPlot plot = barchart.getCategoryPlot(); CategoryItemRenderer renderer = new CustomRenderer(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setBaseItemLabelGenerator( new StandardCategoryItemLabelGenerator(riskCountTitle, NumberFormat.getInstance())); DecimalFormat df = new DecimalFormat("##"); renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", df)); Font m1Font; m1Font = new Font("Cambria", Font.BOLD, 16); renderer.setItemLabelFont(m1Font); renderer.setItemLabelPaint(null); //barchart.removeLegend(); plot.setRenderer(renderer); //renderer.setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE5, TextAnchor.CENTER)); //renderer.setItemLabelsVisible(true); barchart.getCategoryPlot().setRenderer(renderer); LegendItemCollection chartLegend = new LegendItemCollection(); Shape shape = new Rectangle(10, 10); chartLegend.add(new LegendItem("Low (" + low + ")", null, null, null, shape, new Color(230, 219, 27))); chartLegend .add(new LegendItem("Medium (" + medium + ")", null, null, null, shape, new Color(85, 144, 176))); chartLegend.add(new LegendItem("High (" + high + ")", null, null, null, shape, new Color(230, 90, 27))); chartLegend.add( new LegendItem("Critical (" + critical + ")", null, null, null, shape, new Color(230, 27, 27))); plot.setFixedLegendItems(chartLegend); plot.setBackgroundPaint(new Color(210, 234, 243)); ChartPanel chartPanel = new ChartPanel(barchart); return chartPanel; }
From source file:edu.ucla.stat.SOCR.chart.demo.PieChartDemo1.java
/** * // w ww .ja va2s.co m */ protected DefaultPieDataset createDataset(boolean isDemo) { if (isDemo) { 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)); pulloutFlag = new String[6]; for (int i = 0; i < 6; i++) pulloutFlag[i] = "0"; pulloutFlag[2] = "1"; return dataset; } else return super.createDataset(false); }
From source file:no.met.jtimeseries.chart.Utility.java
/** * Calculate the time at the threshold value * //from ww w . j a v a 2s . c om * @param time1 * The first time string * @param value1 * The first value * @param time2 * The second time String * @param value2 * The second value * @param value3 * The threshold value * @return The time at the threshold */ public static Date timeOfThreshold(Date time1, double value1, Date time2, double value2, double value3) { DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); long date3 = 0; long date1 = time1.getTime(); long date2 = time2.getTime(); double slope = (date2 - date1) / (value2 - value1); double bias = date2 - slope * value2; date3 = new Double(slope * value3 + bias).longValue(); return new Date(date3); }
From source file:fr.univrouen.poste.services.ExcelParser.java
public List<List<String>> getCells(InputStream xslFileInput) { List<List<String>> cellVectorHolder = new Vector<List<String>>(); try {//from ww w.j a va 2 s . c om POIFSFileSystem fileSystem = new POIFSFileSystem(xslFileInput); HSSFWorkbook workBook = new HSSFWorkbook(fileSystem); HSSFSheet sheet = workBook.getSheetAt(0); Iterator<Row> rowIter = sheet.rowIterator(); while (rowIter.hasNext()) { HSSFRow myRow = (HSSFRow) rowIter.next(); List<String> cellStoreVector = new Vector<String>(); // take care of blank cell ! // @see http://stackoverflow.com/questions/4929646/how-to-get-an-excel-blank-cell-value-in-apache-poi int max = myRow.getLastCellNum(); for (int i = 0; i < max; i++) { HSSFCell myCell = (HSSFCell) myRow.getCell(i, Row.CREATE_NULL_AS_BLANK); if (Cell.CELL_TYPE_STRING == myCell.getCellType()) cellStoreVector.add(myCell.getStringCellValue()); else if ((Cell.CELL_TYPE_NUMERIC == myCell.getCellType())) cellStoreVector.add(Long.toString(new Double(myCell.getNumericCellValue()).longValue())); else if ((Cell.CELL_TYPE_BLANK == myCell.getCellType())) cellStoreVector.add(""); else { logger.debug("This cell is not numeric or string ... : " + myCell + " \n ... cellType : " + myCell.getCellType()); cellStoreVector.add(""); } } cellVectorHolder.add(cellStoreVector); } } catch (Exception e) { logger.error("Error during parsing the XSL File", e); throw new RuntimeException("Error during parsing the XSL File", e); } return cellVectorHolder; }
From source file:org.jfree.data.category.DefaultCategoryDatasetTest.java
/** * Some checks for the getValue() method. *///from w w w . j av a2 s . c o m @Test 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:nz.co.senanque.listfunctions.ListFunctionTest.java
@Test public void test1() throws Exception { ValidationSession validationSession = m_validationEngine.createSession(); Customer customer = m_customerDAO.createCustomer(); validationSession.bind(customer);/* w w w .ja v a 2 s . c o m*/ Invoice invoice = new Invoice(); invoice.setAmount(130); customer.getInvoices().add(invoice); invoice = new Invoice(); invoice.setAmount(130); customer.getInvoices().add(invoice); invoice = new Invoice(); invoice.setAmount(130); customer.getInvoices().add(invoice); invoice = new Invoice(); invoice.setAmount(200); invoice.setTestBoolean(true); customer.getInvoices().add(invoice); assertEquals(new Double(590.0), new Double(customer.getAmount())); assertEquals(true, customer.isAnytrue()); assertEquals(false, customer.isAlltrue()); assertEquals(1, customer.getCount()); for (Invoice inv : customer.getInvoices()) { inv.setTestBoolean(true); } assertEquals(true, customer.isAnytrue()); assertEquals(4, customer.getCount()); assertEquals(true, customer.isAlltrue()); for (Invoice inv : customer.getInvoices()) { inv.setTestBoolean(false); } assertEquals(false, customer.isAnytrue()); assertEquals(false, customer.isAlltrue()); assertEquals(0, customer.getCount()); assertEquals(4, customer.getInvoiceCount()); assertEquals(590L, new Double(customer.getAmount()).longValue()); Invoice inv = customer.getInvoices().get(0); customer.getInvoices().remove(inv); long j = customer.getInvoiceCount(); assertEquals(3, j); // Proves the amount was re-evaluated on removal of one of the invoices assertEquals(590L - 130L, new Double(customer.getAmount()).longValue()); customer.getInvoices().clear(); j = customer.getInvoiceCount(); assertEquals(0, j); }
From source file:de.openali.odysseus.chart.framework.model.data.DataRange.java
@Deprecated public static <T> DataRange<T> create(final T min, final T max) { if (min instanceof Number && max instanceof Number) { final Double minNum = ((Number) min).doubleValue(); final Double maxNum = ((Number) max).doubleValue(); // Beide gleich => dataRange automatisch so anpassen, dass der Wert // in der Intervallmitte liegt if (minNum.compareTo(maxNum) == 0) { final double doubleValue = minNum.doubleValue(); // falls != 0 werden einfach 10% addiert oder subtrahiert if (doubleValue != 0) { final T minExpanded = (T) new Double(doubleValue - doubleValue * 0.1); final T maxExpanded = (T) new Double(doubleValue + doubleValue * 0.1); return new DataRange<>(minExpanded, maxExpanded); }/*from w w w . j a v a 2 s . c om*/ // falls == 0 wird 1 addiert oder subtrahiert else { final T min_1 = (T) new Double(doubleValue - 1); final T max_1 = (T) new Double(doubleValue + 1); return new DataRange<>(min_1, max_1); } } if (minNum.compareTo(maxNum) > 0) return new DataRange<>(max, min); else return new DataRange<>(min, max); } else if (min instanceof Comparable && max instanceof Comparable && (min.getClass().isInstance(max) || max.getClass().isInstance(min))) { // FIXME: this is nonsense! REMOVE final Comparable<Comparable<?>> minComp = (Comparable<Comparable<?>>) min; final Comparable<?> maxComp = (Comparable<?>) max; if (minComp.compareTo(maxComp) == 0) { // kann leider nicht automatisch angepasst werden; das muss // jemand anders abfangen } if (minComp.compareTo(maxComp) > 0) return new DataRange<>(max, min); else return new DataRange<>(min, max); } /* * das wre dann der ungnstigste Fall: nicht vergleichbar und nicht numerisch TODO: berlegen, ob dieser Fall * berhaupt zugelassen werden soll; alternativ sollte eine InvalidRangeIntervalObjectsException */ else { return new DataRange<>(min, max); } }
From source file:org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDatasetTest.java
/** * Confirm that the equals method can distinguish all the required fields. *//* w ww . j a v a 2 s . c om*/ @Test public void testEquals() { DefaultBoxAndWhiskerCategoryDataset d1 = new DefaultBoxAndWhiskerCategoryDataset(); d1.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()), "ROW1", "COLUMN1"); DefaultBoxAndWhiskerCategoryDataset d2 = new DefaultBoxAndWhiskerCategoryDataset(); d2.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()), "ROW1", "COLUMN1"); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); }
From source file:com.sigma.applet.GraphsApplet.java
private TimeSeriesCollection createTimeSeriesCollection1(double d) { TimeSeries t1 = new TimeSeries("Realtime", "time", "Value", Minute.class); try {//from w ww . j av a 2 s . c o m long t = System.currentTimeMillis(); if (d > 1) { t1.add(new Minute(new Date(t)), new Double(50.1 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(12.3 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(23.9 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(83.4 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(-34.7 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(76.5 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(10.0 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(-14.7 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(43.9 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(49.6 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(37.2 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(17.1 * d)); } else { t1.add(new Minute(new Date(t)), new Double(43.9 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(49.6 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(37.2 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(17.1 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(-34.7 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(76.5 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(10.0 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(-14.7 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(50.1 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(12.3 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(23.9 * d)); t += 300000; t1.add(new Minute(new Date(t)), new Double(83.4 * d)); } } catch (Exception e) { System.err.println(e.getMessage()); } return new TimeSeriesCollection(t1); }
From source file:com.saba.CalendarDemo.java
public static void prepareXLSDynamicValues(Map<String, Object> data) { data.put(contactDetails[0], "Columbus Health care Hospital"); data.put(contactDetails[1], "Sabari nathan"); data.put(contactDetails[2], "Purchasing Unit Head"); data.put(contactDetails[3], "sabar@yopmail.com"); data.put(contactDetails[4], "+91-908-765-4321"); data.put(awardedBidDetails[0],/* w w w . j a v a 2s . co m*/ "Cardiology, Administration, Admissions, Behavioral Health, Bloodborne Pathogen, Safety Device."); data.put(awardedBidDetails[1], "PeachCare Medical Center, Unicol Country Memorial Hospital, Brandon Ambulatory Surgery Center"); data.put(awardedBidDetails[2], new Date()); data.put(awardedBidDetails[3], new Date()); data.put(awardedBidDetails[4], new Double("1234.00")); Map<String, Object[]> productDetailsMap = new HashMap<String, Object[]>(); productDetailsMap.put("0", new Object[] { "Cardiology, Administration, Safety Device ", "91101501-Health or fitness clubs", "EA", "100", "flipfort logic tech", "10", "9", "45", "450" }); productDetailsMap.put("1", new Object[] { "Admissions, Behavioral Health, Bloodborne Pathogen, Safety Device ", "91101501-fitness clubs", "EA", "100", "lupanisa", "10", "9", "45", "450" }); productDetailsMap.put("2", new Object[] { "Behavioral Health, Bloodborne Pathogen, Safety Device ", "91101501-Health or fitness clubs", "EA", "100", "Tech mahe logistics", "10", "9", "45", "450" }); productDetailsMap.put("3", new Object[] { "Safety Device ", "91101501-Health or fitness clubs", "EA", "100", " first choice", "10", "9", "45", "450" }); productDetailsMap.put("4", new Object[] { "Bloodborne Pathogen, Safety Device ", "91101598- lubs", "EA", "100", " Dlhivery", "10", "9", "45", "450" }); data.put(awardHeaders[2], productDetailsMap); }