Example usage for java.lang Number doubleValue

List of usage examples for java.lang Number doubleValue

Introduction

In this page you can find the example usage for java.lang Number doubleValue.

Prototype

public abstract double doubleValue();

Source Link

Document

Returns the value of the specified number as a double .

Usage

From source file:io.coala.random.impl.RandomDistributionFactoryImpl.java

@Override
public RandomNumberDistribution<Double> getTriangular(final RandomNumberStream rng, final Number a,
        final Number b, final Number c) {
    final RealDistribution dist = new TriangularDistribution(
            RandomNumberStream.Util.asCommonsRandomGenerator(rng), a.doubleValue(), b.doubleValue(),
            c.doubleValue());//from   w  w  w. ja v  a2s. c o m
    return new RandomNumberDistribution<Double>() {
        @Override
        public Double draw() {
            return dist.sample();
        }
    };
}

From source file:org.objectweb.proactive.extensions.timitspmd.util.charts.renderer.HierarchicalBarRenderer.java

/**
 * Returns the bar width for a series, or <code>Double.NaN</code> if no
 * width has been set.//  w  ww. j  av a 2 s . c om
 *
 * @param series
 *            the series index (zero based).
 *
 * @return The width for the series (1.0=100%, it is the maximum).
 */
public double getSeriesBarWidth(int series) {
    double result = Double.NaN;
    Number n = (Number) this.seriesBarWidthList.get(series);
    if (n != null) {
        result = n.doubleValue();
    }
    return result;
}

From source file:org.talend.dataprofiler.chart.preview.DQRuleItemLabelGenerator.java

@Override
protected Object[] createItemArray(CategoryDataset dataset, int row, int column) {

    Object[] result = new Object[4];
    result[0] = dataset.getRowKey(row).toString();
    result[1] = dataset.getColumnKey(column).toString();
    Number value = dataset.getValue(row, column);
    if (value != null && !value.equals(Double.NaN)) {
        if (super.getNumberFormat() != null) {
            result[2] = super.getNumberFormat().format(value);
        } else if (super.getDateFormat() != null) {
            result[2] = super.getDateFormat().format(value);
        }/*  w  w  w.jav a 2s.c  om*/

        double total = DataUtilities.calculateColumnTotal(dataset, column);
        double percent = value.doubleValue() / total;
        // MOD qiongli bug 21589,override for just changeing this line.avoid 99.99% to show 100%
        // result[3] = this.percentFormat.format(percent);
        result[3] = stringformat(percent, 0).toString();
    } else {
        result[2] = "-"; //$NON-NLS-1$
        result[3] = "-"; //$NON-NLS-1$
    }

    return result;

}

From source file:com.anrisoftware.globalpom.measurement.AbstractValue.java

@Override
public int compare(Number value, double dev) {
    return compare(createValue(value.doubleValue()), dev);
}

From source file:com.bdb.weather.display.summary.HiLoItemLabelGenerator.java

@Override
public String generateToolTip(XYDataset dataset, int series, int item) {

    String result = null;/*from   w  w  w  .  j a  v a  2  s .  c  o  m*/

    if (dataset instanceof OHLCDataset) {
        OHLCDataset d = (OHLCDataset) dataset;
        Number high = d.getHigh(series, item);
        Number low = d.getLow(series, item);
        Number open = d.getOpen(series, item);
        Number x = d.getX(series, item);

        result = d.getSeriesKey(series).toString();

        if (x != null) {
            Date date = new Date(x.longValue());
            result = result + "--> Date=" + dateFormat.format(date);

            if (high != null)
                result = result + " High=" + numberFormat.format(high.doubleValue());

            if (low != null)
                result = result + " Low=" + numberFormat.format(low.doubleValue());

            if (open != null)
                result = result + " Avg=" + numberFormat.format(open.doubleValue());

        }

    }

    return result;

}

From source file:io.coala.random.impl.RandomDistributionFactoryImpl.java

@Override
public RandomNumberDistribution<Double> getF(final RandomNumberStream rng,
        final Number numeratorDegreesOfFreedom, final Number denominatorDegreesOfFreedom) {
    final RealDistribution dist = new FDistribution(RandomNumberStream.Util.asCommonsRandomGenerator(rng),
            numeratorDegreesOfFreedom.doubleValue(), denominatorDegreesOfFreedom.doubleValue());
    return new RandomNumberDistribution<Double>() {
        @Override/*from   ww  w .  j  av  a 2  s  . co m*/
        public Double draw() {
            return dist.sample();
        }
    };
}

From source file:org.rdv.viz.dial.DialPanel.java

/**
 * Checks the dial value against the warning and critical threshold values. If
 * a threshold is reached, the dial value indicator will change color
 * according to the type of threshold reached.
 *///from   www.  ja  va 2  s.com
private void checkThresholds() {
    Number numberValue = plot.getDataset().getValue();

    if (numberValue == null) {
        dialValueIndicator.setBackgroundPaint(Color.white);
    } else {
        double value = numberValue.doubleValue();

        if (value < criticalMinimumThreshold || value > criticalMaxThreshold) {
            dialValueIndicator.setBackgroundPaint(Color.red);
        } else if (value < warningMinimumThreshold || value > warningMaximumThreshold) {
            dialValueIndicator.setBackgroundPaint(Color.yellow);
        } else {
            dialValueIndicator.setBackgroundPaint(Color.white);
        }
    }
}

From source file:org.envirocar.server.rest.util.GeoJSON.java

protected Coordinate decodeCoordinate(ArrayNode list) throws GeometryConverterException {
    if (list.size() != 2) {
        throw new GeometryConverterException("coordinates may only have 2 dimensions");
    }/*  www.  j  a  va 2s.  c om*/
    Number x = list.get(0).numberValue();
    Number y = list.get(1).numberValue();
    if (x == null || y == null) {
        throw new GeometryConverterException("x and y have to be numbers");
    }
    return new Coordinate(x.doubleValue(), y.doubleValue());
}

From source file:com.github.brandtg.stl.StlDecomposition.java

/**
 * A convenience method to use objects.//from  w ww .  ja  va2  s .  c om
 *
 * @param times
 *  A sequence of time values.
 * @param series
 *  A dependent variable on times.
 * @return
 *  The STL decomposition of the time series.
 */
public StlResult decompose(List<Number> times, List<Number> series) {
    double[] timesArray = new double[times.size()];
    double[] seriesArray = new double[series.size()];

    int idx = 0;
    for (Number time : times) {
        timesArray[idx++] = time.doubleValue();
    }

    idx = 0;
    for (Number value : series) {
        seriesArray[idx++] = value.doubleValue();
    }

    return decompose(timesArray, seriesArray);
}

From source file:gov.nih.nci.caintegrator.application.geneexpression.BoxAndWhiskerCoinPlotRenderer.java

/**
 * {@inheritDoc}//  w  w  w. jav  a2 s.co  m
 */
@Override
public void drawVerticalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea,
        CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row,
        int column) {
    BoxAndWhiskerCategoryDataset bawDataset = (BoxAndWhiskerCategoryDataset) dataset;
    double categoryEnd = domainAxis.getCategoryEnd(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryStart = domainAxis.getCategoryStart(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryWidth = categoryEnd - categoryStart;
    double xx = categoryStart;
    int seriesCount = getRowCount();
    int categoryCount = getColumnCount();
    xx = retrieveXx(state, dataArea, row, categoryWidth, xx, seriesCount, categoryCount);
    Paint p = null;
    if (this.getPlotColor() != null) {
        p = PaintUtilities.stringToColor(getPlotColor()); // coin plot should all be one color
    } else {
        p = getItemPaint(row, column);
    }
    if (p != null) {
        g2.setPaint(p);
    }
    Stroke s = getItemStroke(row, column);
    g2.setStroke(s);
    double aRadius = 0; // average radius
    RectangleEdge location = drawRectangles(g2, state, dataArea, plot, rangeAxis, row, column, bawDataset, xx);
    g2.setPaint(getArtifactPaint());
    if (this.isDisplayMean()) {
        aRadius = drawMean(g2, state, dataArea, rangeAxis, row, column, bawDataset, xx, aRadius, location);
    }
    if (this.isDisplayMedian()) {
        // draw median...
        Number yMedian = bawDataset.getMedianValue(row, column);
        if (yMedian != null) {
            double yyMedian = rangeAxis.valueToJava2D(yMedian.doubleValue(), dataArea, location);
            g2.draw(new Line2D.Double(xx, yyMedian, xx + state.getBarWidth(), yyMedian));
        }
    }
    double maxAxisValue = rangeAxis.valueToJava2D(rangeAxis.getUpperBound(), dataArea, location) + aRadius;
    double minAxisValue = rangeAxis.valueToJava2D(rangeAxis.getLowerBound(), dataArea, location) - aRadius;
    g2.setPaint(p);
    drawOutliers(g2, state, dataArea, rangeAxis, row, column, bawDataset, xx, aRadius, location, maxAxisValue,
            minAxisValue);
}