List of usage examples for java.lang Number doubleValue
public abstract double doubleValue();
From source file:net.bioclipse.model.ScatterPlotMouseHandler.java
private double rangeValueTo2D(ChartPanel chartPanel, XYPlot plot, double value) { ChartRenderingInfo info = chartPanel.getChartRenderingInfo(); Rectangle2D dataArea = info.getPlotInfo().getDataArea(); Number y = plot.getRangeAxis().valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); return y.doubleValue(); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.PieChartExpression.java
protected void configureExplode(final PiePlot pp) { final PieDataset pieDS = pp.getDataset(); final int explodeType = computeExplodeType(); if (explodeType == EXPLODE_VALUE) { try {/*from w w w . j a v a2 s .c o m*/ final int actualSegment = Integer.parseInt(explodeSegment); if (actualSegment >= 0) { pp.setExplodePercent(pieDS.getKey(actualSegment), explodePct.doubleValue()); } } catch (Exception ignored) { } return; } // Calculate min and max... if (pieDS != null) { final int itemCount = pieDS.getItemCount(); Number maxNum = new Double(Integer.MIN_VALUE); Number minNum = new Double(Integer.MAX_VALUE); int maxSegment = -1; int minSegment = -1; for (int i = 0; i < itemCount; i++) { final Number nbr = pieDS.getValue(i); if (nbr.doubleValue() > maxNum.doubleValue()) { maxNum = nbr; maxSegment = i; } if (nbr.doubleValue() < minNum.doubleValue()) { minNum = nbr; minSegment = i; } } if (explodeType == EXPLODE_MIN) { //$NON-NLS-1$ if (minSegment >= 0) { pp.setExplodePercent(pieDS.getKey(minSegment), explodePct.doubleValue()); } } else { if (maxSegment >= 0) { pp.setExplodePercent(pieDS.getKey(maxSegment), explodePct.doubleValue()); } } } }
From source file:com.redhat.lightblue.crud.validator.MinMaxChecker.java
private int cmp(JsonNode node, Number value) { if (value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof Long) { return cmp(node.asLong(), value.longValue()); } else if (value instanceof Float || value instanceof Double) { return cmp(node.asDouble(), value.doubleValue()); } else if (value instanceof BigInteger) { return cmp(node.bigIntegerValue(), (BigInteger) value); } else {/* w w w. j a va 2 s.c om*/ return cmp(node.decimalValue(), (BigDecimal) value); } }
From source file:io.coala.time.SimTime.java
/** @see Instant#plus(Number) */ @Override/*ww w. j a v a 2 s. c o m*/ public SimTime plus(final Number value) { return new SimTime( // getBaseUnit(), getClockID(), getValue().doubleValue() + value.doubleValue(), getUnit(), calcOffset()); }
From source file:net.bioclipse.model.ScatterPlotMouseHandler.java
private double domainValueTo2D(ChartPanel chartPanel, XYPlot plot, double value) { ChartRenderingInfo info = chartPanel.getChartRenderingInfo(); Rectangle2D dataArea = info.getPlotInfo().getDataArea(); Number x = plot.getDomainAxis().valueToJava2D(value, dataArea, plot.getDomainAxisEdge()); return x.doubleValue(); }
From source file:ro.nextreports.engine.util.chart.CylinderRenderer.java
/** * Draws a cylinder to represent one data item. * // w ww . j a v a 2s .c o m * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area for plotting the data. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // check the value we are plotting... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { return; } double value = dataValue.doubleValue(); Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); PlotOrientation orientation = plot.getOrientation(); double barW0 = calculateBarW0(plot, orientation, adjusted, domainAxis, state, row, column); double[] barL0L1 = calculateBarL0L1(value); if (barL0L1 == null) { return; // the bar is not visible } RectangleEdge edge = plot.getRangeAxisEdge(); float transL0 = (float) rangeAxis.valueToJava2D(barL0L1[0], adjusted, edge); float transL1 = (float) rangeAxis.valueToJava2D(barL0L1[1], adjusted, edge); float barL0 = Math.min(transL0, transL1); float barLength = Math.abs(transL1 - transL0); // draw the bar... GeneralPath bar = new GeneralPath(); if (orientation == PlotOrientation.HORIZONTAL) { bar.moveTo(barL0, (float) barW0); bar.lineTo(barL0, (float) (barW0 + state.getBarWidth())); bar.lineTo(barL0 + barLength, (float) (barW0 + state.getBarWidth())); bar.lineTo(barL0 + barLength, (float) barW0); bar.closePath(); } else { bar.moveTo((float) barW0, (float) (barL0 - getYOffset() / 2)); bar.lineTo((float) barW0, (float) (barL0 + barLength - getYOffset() / 2)); Arc2D arc = new Arc2D.Double(barW0, (barL0 + barLength - getYOffset()), state.getBarWidth(), getYOffset(), 180, 180, Arc2D.OPEN); bar.append(arc, true); bar.lineTo((float) (barW0 + state.getBarWidth()), (float) (barL0 - getYOffset() / 2)); arc = new Arc2D.Double(barW0, (barL0 - getYOffset()), state.getBarWidth(), getYOffset(), 0, -180, Arc2D.OPEN); bar.append(arc, true); bar.closePath(); } Paint itemPaint = getItemPaint(row, column); if (getGradientPaintTransformer() != null && itemPaint instanceof GradientPaint) { GradientPaint gp = (GradientPaint) itemPaint; itemPaint = getGradientPaintTransformer().transform(gp, bar); } g2.setPaint(itemPaint); g2.fill(bar); Shape bar3dTop = new Ellipse2D.Double(barW0, barL0 - getYOffset(), state.getBarWidth(), getYOffset()); if (itemPaint instanceof GradientPaint) { g2.setPaint(((GradientPaint) itemPaint).getColor2()); } g2.fill(bar3dTop); if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { g2.setStroke(getItemOutlineStroke(row, column)); g2.setPaint(getItemOutlinePaint(row, column)); g2.draw(bar); if (bar3dTop != null) { g2.draw(bar3dTop); } } CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar.getBounds2D(), (value < 0.0)); } // collect entity and tool tip information... if (state.getInfo() != null) { EntityCollection entities = state.getEntityCollection(); if (entities != null) { String tip = null; CategoryToolTipGenerator tipster = getToolTipGenerator(row, column); if (tipster != null) { tip = tipster.generateToolTip(dataset, row, column); } String url = null; if (getItemURLGenerator(row, column) != null) { url = getItemURLGenerator(row, column).generateURL(dataset, row, column); } CategoryItemEntity entity = new CategoryItemEntity(bar.getBounds2D(), tip, url, dataset, dataset.getRowKey(row), dataset.getColumnKey(column)); entities.add(entity); } } }
From source file:fr.ens.transcriptome.aozan.util.StatisticsUtils.java
/** * Public constructor, build a list of values used for compute statistics. * Infinity values are ignored./*ww w .j a v a2 s .co m*/ * @param list values */ public StatisticsUtils(final List<? extends Number> list) { this.ds = new DescriptiveStatistics(); for (final Number n : list) { final Double val = n.doubleValue(); if (val != null) { if (!val.isInfinite()) { this.ds.addValue(val); } } } }
From source file:hudson.util.StackedAreaRenderer2.java
@Override public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // plot non-null values... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { return;//from ww w . ja v a 2 s .c om } double value = dataValue.doubleValue(); // leave the y values (y1, y0) untranslated as it is going to be be // stacked up later by previous series values, after this it will be // translated. double xx1 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); double previousHeightx1 = getPreviousHeight(dataset, row, column); double y1 = value + previousHeightx1; RectangleEdge location = plot.getRangeAxisEdge(); double yy1 = rangeAxis.valueToJava2D(y1, dataArea, location); g2.setPaint(getItemPaint(row, column)); g2.setStroke(getItemStroke(row, column)); // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); // in column zero, the only job to do is draw any visible item labels // and this is done in the second pass... if (column == 0) { if (pass == 1) { // draw item labels, if visible if (isItemLabelVisible(row, column)) { drawItemLabel(g2, plot.getOrientation(), dataset, row, column, xx1, yy1, (y1 < 0.0)); } } } else { Number previousValue = dataset.getValue(row, column - 1); if (previousValue != null) { double xx0 = domainAxis.getCategoryMiddle(column - 1, getColumnCount(), dataArea, plot.getDomainAxisEdge()); double y0 = previousValue.doubleValue(); // Get the previous height, but this will be different for both // y0 and y1 as the previous series values could differ. double previousHeightx0 = getPreviousHeight(dataset, row, column - 1); // Now stack the current y values on top of the previous values. y0 += previousHeightx0; // Now translate the previous heights double previousHeightxx0 = rangeAxis.valueToJava2D(previousHeightx0, dataArea, location); double previousHeightxx1 = rangeAxis.valueToJava2D(previousHeightx1, dataArea, location); // Now translate the current y values. double yy0 = rangeAxis.valueToJava2D(y0, dataArea, location); if (pass == 0) { // left half Polygon p = new Polygon(); p.addPoint((int) xx0, (int) yy0); p.addPoint((int) (xx0 + xx1) / 2, (int) (yy0 + yy1) / 2); p.addPoint((int) (xx0 + xx1) / 2, (int) (previousHeightxx0 + previousHeightxx1) / 2); p.addPoint((int) xx0, (int) previousHeightxx0); g2.setPaint(getItemPaint(row, column - 1)); g2.setStroke(getItemStroke(row, column - 1)); g2.fill(p); if (entities != null) addItemEntity(entities, dataset, row, column - 1, p); // right half p = new Polygon(); p.addPoint((int) xx1, (int) yy1); p.addPoint((int) (xx0 + xx1) / 2, (int) (yy0 + yy1) / 2); p.addPoint((int) (xx0 + xx1) / 2, (int) (previousHeightxx0 + previousHeightxx1) / 2); p.addPoint((int) xx1, (int) previousHeightxx1); g2.setPaint(getItemPaint(row, column)); g2.setStroke(getItemStroke(row, column)); g2.fill(p); if (entities != null) addItemEntity(entities, dataset, row, column, p); } else { if (isItemLabelVisible(row, column)) { drawItemLabel(g2, plot.getOrientation(), dataset, row, column, xx1, yy1, (y1 < 0.0)); } } } } }
From source file:com.alibaba.jstorm.utils.JStormUtils.java
public static Double parseDouble(Object o) { if (o == null) { return null; }//from ww w . jav a2 s .com if (o instanceof String) { return Double.valueOf(String.valueOf(o)); } else if (o instanceof Integer) { Number value = (Integer) o; return value.doubleValue(); } else if (o instanceof Long) { Number value = (Long) o; return value.doubleValue(); } else if (o instanceof Double) { return (Double) o; } else { throw new RuntimeException("Invalid value " + o.getClass().getName() + " " + o); } }
From source file:gov.va.med.pharmacy.peps.presentation.common.displaytag.DefaultHssfExportView.java
/** * doExport creates excel file for download * @param out OutputStream// w w w . jav a2s. c om * @see org.displaytag.export.BinaryExportView#doExport(java.io.OutputStream) * @throws IOException IOException * @throws JspException JspException */ public void doExport(OutputStream out) throws IOException, JspException { try { HSSFWorkbook wb = new HSSFWorkbook(); sheet = wb.createSheet("Table_Export"); int rowNum = 0; int colNum = 0; //Create a header row HSSFRow xlsRow = sheet.createRow(rowNum++); HSSFCellStyle headerStyle = wb.createCellStyle(); headerStyle.setFillPattern(HSSFCellStyle.FINE_DOTS); headerStyle.setFillBackgroundColor(HSSFColor.BLUE_GREY.index); HSSFFont bold = wb.createFont(); bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); bold.setColor(HSSFColor.WHITE.index); headerStyle.setFont(bold); Iterator iterator = this.model.getHeaderCellList().iterator(); while (iterator.hasNext()) { HeaderCell headerCell = (HeaderCell) iterator.next(); String columnHeader = headerCell.getTitle(); if (columnHeader == null) { columnHeader = StringUtils.capitalize(headerCell.getBeanPropertyName()); } HSSFCell cell = xlsRow.createCell(colNum++); cell.setCellValue(columnHeader); cell.setCellStyle(headerStyle); } RowIterator rowIterator = this.model.getRowIterator(this.exportFull); while (rowIterator.hasNext()) { Row row = rowIterator.next(); xlsRow = sheet.createRow(rowNum++); colNum = 0; // iterate on columns ColumnIterator columnIterator = row.getColumnIterator(this.model.getHeaderCellList()); while (columnIterator.hasNext()) { Column column = columnIterator.nextColumn(); Object value = column.getValue(this.decorated); HSSFCell cell = xlsRow.createCell(colNum++); if (value instanceof Number) { Number num = (Number) value; cell.setCellValue(num.doubleValue()); } else if (value instanceof Date) { cell.setCellValue((Date) value); } else if (value instanceof Calendar) { cell.setCellValue((Calendar) value); } else { cell.setCellValue(escapeColumnValue(value)); } } } wb.write(out); // new HssfTableWriter(wb).writeTable(this.model, "-1"); // wb.write(out); } catch (Exception e) { throw new HssfGenerationException(e); } }