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.time.AbstractInstant.java

/** @see Instant#multipliedBy(Number) */
@Override//from   ww  w. ja v a  2 s  .c o m
public THIS multipliedBy(final Number factor) {
    return minus((factor.doubleValue() - 1) * getValue().doubleValue());
}

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

@Override
public RandomNumberDistribution<Double> getLevy(final RandomNumberStream rng, final Number mu, final Number c) {
    final RealDistribution dist = new LevyDistribution(RandomNumberStream.Util.asCommonsRandomGenerator(rng),
            mu.doubleValue(), c.doubleValue());
    return new RandomNumberDistribution<Double>() {
        @Override/*from  ww w . j av  a2  s  .com*/
        public Double draw() {
            return dist.sample();
        }
    };
}

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

@Override
public RandomNumberDistribution<Integer> getPascal(final RandomNumberStream rng, final Number r,
        final Number p) {
    final IntegerDistribution dist = new PascalDistribution(
            RandomNumberStream.Util.asCommonsRandomGenerator(rng), r.intValue(), p.doubleValue());
    return new RandomNumberDistribution<Integer>() {
        @Override//  w  ww  .  j a v a 2  s. co  m
        public Integer draw() {
            return dist.sample();
        }
    };
}

From source file:main.java.edu.isistan.genCom.redSocial.RedSocial.java

/**
 * Obtiene las distancias no dirigidas para cada combinacin de candidatos
 * /*from w  w  w .j a  v a  2s  .c o m*/
 * @param comisionNodes
 *            coleccion de nodos
 * @return
 */
public List<Double> getDistancesIn(List<Investigador> comisionNodes) {
    List<Double> distancias = new ArrayList<>();
    UnweightedShortestPath<Investigador, String> uWSP = new UnweightedShortestPath(red);

    for (int i = 0; i < comisionNodes.size(); i++) {

        for (int j = (i + 1); j < comisionNodes.size(); j++) {

            Number d = uWSP.getDistance(comisionNodes.get(i), comisionNodes.get(j));

            distancias.add(d.doubleValue());
        }
    }

    return distancias;
}

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

private double drawMean(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea,
        ValueAxis rangeAxis, int row, int column, BoxAndWhiskerCategoryDataset bawDataset, double xx,
        double aRadius, RectangleEdge location) {
    double yyAverage;
    double newARadius = aRadius;
    // draw mean - SPECIAL AIMS REQUIREMENT...
    Number yMean = bawDataset.getMeanValue(row, column);
    if (yMean != null) {
        yyAverage = rangeAxis.valueToJava2D(yMean.doubleValue(), dataArea, location);
        newARadius = state.getBarWidth() / 4;
        Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xx + aRadius, yyAverage - aRadius, aRadius * 2,
                aRadius * 2);/*from w w  w  . j  a  v  a2  s.  c  o  m*/
        g2.fill(avgEllipse);
        g2.draw(avgEllipse);
    }
    return newARadius;
}

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

@Override
public RandomNumberDistribution<Double> getChiSquared(final RandomNumberStream rng,
        final Number degreesOfFreedom) {
    final RealDistribution dist = new ChiSquaredDistribution(
            RandomNumberStream.Util.asCommonsRandomGenerator(rng), degreesOfFreedom.doubleValue());
    return new RandomNumberDistribution<Double>() {
        @Override//w ww  . ja va  2  s.  c o  m
        public Double draw() {
            return dist.sample();
        }
    };
}

From source file:visiopuce.graph.XYFloatingBarDataset.java

private double getItemValue(int series, int item) {
    FloatingBarSeries s = this.underlying.getSeries(series);
    FloatingBar t = s.get(item);//w ww  . java  2s .c  om
    Number start = t.getStart();
    Number end = t.getEnd();
    return (start.doubleValue() + end.doubleValue()) / 2.0;
}

From source file:com.erudika.para.i18n.MockCurrencyConverter.java

@Override
public Double convertCurrency(Number amount, String from, String to) {
    if (amount == null || StringUtils.isBlank(from) || StringUtils.isBlank(to)) {
        return 0.0;
    }// w w w  .ja v a2 s  .co  m
    Double f = rates.containsKey(from) ? rates.get(from) : 1.0;
    Double t = rates.containsKey(to) ? rates.get(to) : 1.0;
    double ratio = t / f;

    return amount.doubleValue() * ratio;
}

From source file:io.coala.time.AbstractInstant.java

/** @see Instant#dividedBy(Number) */
@Override/*from ww w.  j a  va  2s  .com*/
public THIS dividedBy(final Number factor) {
    return multipliedBy(1. / factor.doubleValue());
}

From source file:net.bioclipse.model.ScatterPlotMouseHandler.java

@Override
public void mouseDragged(MouseEvent e) {
    super.mouseDragged(e);

    ChartPanel chartPanel = getChartPanel(e);
    JFreeChart selectedChart = chartPanel.getChart();
    ChartDescriptor cd = ChartUtils.getChartDescriptor(selectedChart);
    int[] indices = cd.getSourceIndices();

    XYPlot plot = (XYPlot) chartPanel.getChart().getPlot();

    //Create double buffer
    Image buffer = chartPanel.createImage(chartPanel.getWidth(), chartPanel.getHeight());
    Graphics bufferGraphics = buffer.getGraphics();
    chartPanel.paint(bufferGraphics);/*  w w w.ja v  a  2s .c  o  m*/

    if (lastX == 0 && lastY == 0) {
        lastX = e.getX();
        lastY = e.getY();
    }

    drawRect = new Rectangle();
    int x1 = Math.min(Math.min(e.getX(), lastX), startX);
    int y1 = Math.min(Math.min(e.getY(), lastY), startY);
    int x2 = Math.max(Math.max(e.getX(), lastX), startX);
    int y2 = Math.max(Math.max(e.getY(), lastY), startY);

    drawRect.x = x1;
    drawRect.y = y1;
    drawRect.width = x2 - drawRect.x;
    drawRect.height = y2 - drawRect.y;

    //Create a clipping rectangle
    Rectangle clipRect = new Rectangle(drawRect.x - 100, drawRect.y - 100, drawRect.width + 200,
            drawRect.height + 200);

    //Check for selected points
    for (int j = 0; j < plot.getDataset().getItemCount(plot.getDataset().getSeriesCount() - 1); j++) {
        for (int i = 0; i < plot.getDataset().getSeriesCount(); i++) {
            Number xK = plot.getDataset().getX(i, j);
            Number yK = plot.getDataset().getY(i, j);
            Point2D datasetPoint2D = new Point2D.Double(domainValueTo2D(chartPanel, plot, xK.doubleValue()),
                    rangeValueTo2D(chartPanel, plot, yK.doubleValue()));

            if (drawRect.contains(datasetPoint2D)) {
                PlotPointData cp = new PlotPointData(indices[j], cd.getXLabel(), cd.getYLabel());
                boolean pointAdded = mouseDragSelection.addPoint(cp);
                if (pointAdded) {
                    ((ScatterPlotRenderer) plot.getRenderer()).addMarkedPoint(j, i);
                    selectedChart.plotChanged(new PlotChangeEvent(plot));
                }
            } else if (!mouseDragSelection.isEmpty()) {
                PlotPointData cp = new PlotPointData(indices[j], cd.getXLabel(), cd.getYLabel());
                boolean pointRemoved = mouseDragSelection.removePoint(cp);
                if (pointRemoved) {
                    ((ScatterPlotRenderer) plot.getRenderer()).removeMarkedPoint(new Point(j, i));
                    selectedChart.plotChanged(new PlotChangeEvent(plot));
                }
            }
        }
    }

    Iterator<PlotPointData> iterator = currentSelection.iterator();
    while (iterator.hasNext()) {
        PlotPointData next = iterator.next();
        Point dataPoint = next.getDataPoint();
        ((ScatterPlotRenderer) plot.getRenderer()).addMarkedPoint(dataPoint);
    }

    lastX = e.getX();
    lastY = e.getY();

    Graphics graphics = chartPanel.getGraphics();
    graphics.setClip(clipRect);

    //Draw selection rectangle
    bufferGraphics.drawRect(drawRect.x, drawRect.y, drawRect.width, drawRect.height);

    graphics.drawImage(buffer, 0, 0, chartPanel.getWidth(), chartPanel.getHeight(), null);
}