List of usage examples for java.lang Number doubleValue
public abstract double doubleValue();
From source file:no.met.jtimeseries.chart.XYCloudSymbolRenderer.java
/** * Draws the visual representation of a single symbol. */// w w w .j a v a2 s .c om @Override public void drawItem(Graphics2D g2d, XYItemRendererState state, Rectangle2D plotArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // Needs a new graphics object to use translate() and rotate() Graphics2D g2 = (Graphics2D) g2d.create(); g2.setRenderingHints(renderHints); double middleY = plotArea.getCenterY(); CloudDataset cloudData = (CloudDataset) dataset; Number x = cloudData.getX(series, item); double middleX = domainAxis.valueToJava2D(x.doubleValue(), plotArea, plot.getDomainAxisEdge()); g2.translate((int) middleX, (int) middleY); // make x=0, y=0 the middle of the symbol g2.setStroke(new BasicStroke()); double height = plotArea.getHeight() - 2; // we set the width to be 20 which is the same as the weather symbols double width = calculateWidth(plotArea.getWidth()); double startX = -(width / 2); double startY[] = { -(height / 2), -(height / 4), 0, (height / 4) }; double values[] = { (cloudData.getHighClouds(series, item).doubleValue() / 100.0), (cloudData.getMediumClouds(series, item).doubleValue() / 100.0), (cloudData.getLowClouds(series, item).doubleValue() / 100.0), (cloudData.getFog(series, item).doubleValue() / 100.0) }; for (int i = 0; i < values.length; i++) { // for each cloud type g2.setColor(new Color(96, 96, 96)); g2.fill(new Rectangle2D.Double(startX, startY[i], (width * values[i]), (height / 4 - 1))); // plot could g2.setColor(new Color(97, 204, 247)); g2.fill(new Rectangle2D.Double(startX + (width * values[i]), startY[i], (width * (1 - values[i])), (height / 4 - 1))); // plot sky } }
From source file:com.haulmont.chile.core.datatypes.impl.AdaptiveNumberDatatype.java
protected void checkLongRange(String value, Number result) throws ParseException { if (result instanceof Double && (result.doubleValue() > Long.MAX_VALUE || result.doubleValue() < Long.MIN_VALUE)) throw new ParseException(String.format("Long range exceeded: \"%s\"", value), 0); }
From source file:com.ocs.dynamo.ui.converter.BigDecimalConverter.java
@Override public BigDecimal convertToModel(String value, Class<? extends BigDecimal> targetType, Locale locale) { // the original Vaadin code curiously returns a Double here and casts // that to a BigDecimal. // That is not correct, so we use this additional step here Number number = convertToNumber(value, BigDecimal.class, locale); return number == null ? null : BigDecimal.valueOf(number.doubleValue()).setScale(precision, RoundingMode.HALF_UP); }
From source file:io.coala.dsol.util.TreatmentBuilder.java
public TreatmentBuilder withRunLength(final Number runLength) { setRunLength(runLength.doubleValue()); return this; }
From source file:edu.emory.library.tast.database.graphs.GraphTypeScatter.java
public JFreeChart createChart(Object[] data) { CategoryTableXYDataset dataset = new CategoryTableXYDataset(); JFreeChart chart = ChartFactory.createScatterPlot(null, getSelectedIndependentVariable().getLabel(), TastResource.getText("components_charts_barvalue"), dataset, PlotOrientation.VERTICAL, true, true, false);//from w w w .j a v a 2 s. c om //getSelectedIndependentVariable().getFormat(); XYPlot plot = chart.getXYPlot(); ((NumberAxis) plot.getDomainAxis()).setNumberFormatOverride(new DecimalFormat("0")); chart.setBackgroundPaint(Color.white); List allDataSeries = getDataSeries(); for (int j = 0; j < allDataSeries.size(); j++) { DataSeries dataSearies = (DataSeries) allDataSeries.get(j); String dataSeriesLabel = dataSearies.formatForDisplay(); for (int i = 0; i < data.length; i++) { Object[] row = (Object[]) data[i]; Number x = (Number) row[0]; Number y = (Number) row[j + 1]; if (x != null && y != null) dataset.add(x.doubleValue(), y.doubleValue(), dataSeriesLabel); } } return chart; }
From source file:de.jfachwert.pruefung.NumberValidator.java
/** * Verifiziert die uebergebene Nummer, ob sie eine gueltige Nummer und * nicht unendlich oder 'NaN' ist. Falls die Nummer unendlich oder 'NaN' * ist, wird eine {@link ArithmeticException} geworfen. * * @param number zu pruefende Nummer//w w w . ja v a 2s .c o m * @return die Nummer selbst zur Weiterverarbeitung */ public Number verifyNumber(Number number) { if ((number instanceof Double) || (number instanceof Float)) { double dValue = number.doubleValue(); if (Double.isNaN(dValue) || Double.isInfinite(dValue)) { throw new LocalizedArithmeticException(dValue, NUMBER); } } return number; }
From source file:alma.acs.monitoring.blobber.BlobData.java
/** * Calculates the statistics and stores it in {@link #statistics} * if our monitor point data is represented as Number objects; * otherwise this call is ignored.//ww w . j av a2 s. c om * * @param inDataList */ void calculateStatistics() { if (getDataSize() > 0) { // We trust that the data is homogeneous and check only the first MonitorPointValue MonitorPointValue sampleMonitorPointValue = mpTs.getDataList().get(0); if (sampleMonitorPointValue.getData().isEmpty()) { logger.finer( "Ignoring calculateStatistics() call for a time series of MonitorPointValue objects that hold no data."); return; } // TODO: Should we also compute statistics for multi-valued properties? // This was not done in the original (= pre-ACS 12.0) implementation of BlobberWorker#calculateStatistics // and so far we keep this behavior. if (sampleMonitorPointValue.isMultiValued()) { logger.finer( "Ignoring calculateStatistics() call for a time series of multi-valued MonitorPointValue objects."); return; } // After the above checks, there should be a single data item in our sampleMonitorPointValue // We now verify that it has one of the expected numeric types. Object sampleData = sampleMonitorPointValue.getData().get(0); if (!(sampleData instanceof Integer || sampleData instanceof Long || sampleData instanceof Float || sampleData instanceof Double)) { logger.finer( "Ignoring calculateStatistics() call for data type " + sampleData.getClass().getName()); return; } // Now we calculate the statistics, // using apache math lib that works only with 'double' type SummaryStatistics stat = new SummaryStatistics(); for (MonitorPointValue blobData : mpTs.getDataList()) { Number value = (Number) blobData.getData().get(0); stat.addValue(value.doubleValue()); } statistics = new ComponentStatistics(); // We store the results in a ComponentStatistics object, // converting to original data types where it makes sense if (sampleData instanceof Integer) { statistics.min = new Integer((int) Math.round(stat.getMin())); statistics.max = new Integer((int) Math.round(stat.getMax())); statistics.mean = new Double(stat.getMean()); // or Float, to indicate lower precision? statistics.stdDev = new Double(stat.getStandardDeviation()); // or Float, to indicate lower precision? } else if (sampleData instanceof Long) { statistics.min = new Long(Math.round(stat.getMin())); statistics.max = new Long(Math.round(stat.getMax())); statistics.mean = new Double(stat.getMean()); statistics.stdDev = new Double(stat.getStandardDeviation()); } else if (sampleData instanceof Float) { statistics.min = new Float(stat.getMin()); statistics.max = new Float(stat.getMax()); statistics.mean = new Float(stat.getMean()); statistics.stdDev = new Float(stat.getStandardDeviation()); } else if (sampleData instanceof Double) { statistics.min = new Double(stat.getMin()); statistics.max = new Double(stat.getMax()); statistics.mean = new Double(stat.getMean()); statistics.stdDev = new Double(stat.getStandardDeviation()); } } }
From source file:io.coala.dsol.util.TreatmentBuilder.java
public TreatmentBuilder withWarmupPeriod(final Number warmupPeriod) { setWarmupPeriod(warmupPeriod.doubleValue()); return this; }
From source file:com.graphhopper.apache.commons.collections.IntDoubleBinaryHeap.java
@Override public void update(Number key, Integer element) { update_(key.doubleValue(), element); }
From source file:com.graphhopper.apache.commons.collections.IntDoubleBinaryHeap.java
@Override public void insert(Number key, Integer element) { insert_(key.doubleValue(), element); }