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:ai.grakn.graql.internal.template.TemplateVisitor.java

@Override
public Boolean visitLessExpression(GraqlTemplateParser.LessExpressionContext ctx) {
    Object lValue = this.visit(ctx.expr(0));
    Object rValue = this.visit(ctx.expr(1));

    if (!(lValue instanceof Number) || !(rValue instanceof Number)) {
        throw GraqlSyntaxException.parsingTemplateError("LESS THAN", ctx.getText(), originalContext);
    }/*from  w w w. java2s. c  o  m*/

    Number lNumber = (Number) lValue;
    Number rNumber = (Number) rValue;

    return lNumber.doubleValue() < rNumber.doubleValue();
}

From source file:ai.grakn.graql.internal.template.TemplateVisitor.java

@Override
public Boolean visitLessEqExpression(GraqlTemplateParser.LessEqExpressionContext ctx) {
    Object lValue = this.visit(ctx.expr(0));
    Object rValue = this.visit(ctx.expr(1));

    if (!(lValue instanceof Number) || !(rValue instanceof Number)) {
        throw GraqlSyntaxException.parsingTemplateError("LESS THAN EQUALS", ctx.getText(), originalContext);
    }//from  w  w w  .jav a 2s . c  o m

    Number lNumber = (Number) lValue;
    Number rNumber = (Number) rValue;

    return lNumber.doubleValue() <= rNumber.doubleValue();
}

From source file:org.jfree.data.xy.DefaultHighLowDataset.java

/**
 * Returns the volume-value (as a double primitive) for an item within a
 * series.//  w ww .j  a va  2 s . c o m
 *
 * @param series  the series (zero-based index).
 * @param item  the item (zero-based index).
 *
 * @return The volume-value.
 *
 * @see #getVolume(int, int)
 */
@Override
public double getVolumeValue(int series, int item) {
    double result = Double.NaN;
    Number v = getVolume(series, item);
    if (v != null) {
        result = v.doubleValue();
    }
    return result;
}

From source file:org.operamasks.faces.render.graph.CurveAndShapeRenderer.java

private void drawSeriesCurve(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis,
        ValueAxis rangeAxis, CategoryDataset dataset, int series) {
    // do nothing if item is not visible
    if (!(getItemVisible(series, 0) && (getItemLineVisible(series, 0) || drawArea))) {
        return;/*from w  w  w.  j a  va 2 s .c  o  m*/
    }

    RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
    PlotOrientation orientation = plot.getOrientation();

    int itemCount = dataset.getColumnCount();
    double[][] points = new double[itemCount][2];
    int count = 0;

    // get data points
    for (int i = 0; i < itemCount; i++) {
        Number value = dataset.getValue(series, i);
        if (value != null) {
            points[count][0] = domainAxis.getCategoryMiddle(i, itemCount, dataArea, xAxisLocation);
            points[count][1] = rangeAxis.valueToJava2D(value.doubleValue(), dataArea, yAxisLocation);
            count++;
        }
    }

    if (count < 2) {
        return;
    }

    // draw curve
    CubicSplineFunction2D f = new CubicSplineFunction2D(points, count);
    GeneralPath path = new GeneralPath();

    double startX = points[0][0];
    double startY = points[0][1];
    double endX = points[count - 1][0];
    double endY = points[count - 1][1];
    double yz = rangeAxis.valueToJava2D(0.0, dataArea, yAxisLocation);

    if (orientation == PlotOrientation.HORIZONTAL) {
        if (drawArea) {
            path.moveTo((float) yz, (float) startX);
            path.lineTo((float) startY, (float) startX);
            for (double x = Math.floor(startX) + 1.0; x < endX; x += 1.0) {
                path.lineTo((float) f.getValue(x), (float) x);
            }
            path.lineTo((float) endY, (float) endX);
            path.lineTo((float) yz, (float) endX);
            path.closePath();
        } else {
            path.moveTo((float) startY, (float) startX);
            for (double x = Math.floor(startX) + 1.0; x < endX; x += 1.0) {
                path.lineTo((float) f.getValue(x), (float) x);
            }
            path.lineTo((float) endY, (float) endX);
        }
    } else {
        if (drawArea) {
            path.moveTo((float) startX, (float) yz);
            path.lineTo((float) startX, (float) startY);
            for (double x = Math.floor(startX) + 1.0; x < endX; x += 1.0) {
                path.lineTo((float) x, (float) f.getValue(x));
            }
            path.lineTo((float) endX, (float) endY);
            path.lineTo((float) endX, (float) yz);
            path.closePath();
        } else {
            path.moveTo((float) startX, (float) startY);
            for (double x = Math.floor(startX) + 1.0; x < endX; x += 1.0) {
                path.lineTo((float) x, (float) f.getValue(x));
            }
            path.lineTo((float) endX, (float) endY);
        }
    }

    Paint paint = getSeriesPaint(series);
    Stroke stroke = getSeriesStroke(series);

    if (drawArea) {
        g2.setPaint(paint);
        g2.fill(path);

        // create paint for outline
        if (paint instanceof Color) {
            paint = ((Color) paint).darker();
        } else if (paint instanceof GradientPaint) {
            paint = ((GradientPaint) paint).getColor1().darker();
        }
    }

    if (getItemLineVisible(series, 0)) {
        g2.setPaint(paint);
        g2.setStroke(stroke);
        g2.draw(path);
    }
}

From source file:org.jfree.data.category.DefaultCategoryDataset.java

/**
 * Adds the specified value to an existing value in the dataset (if the
 * existing value is <code>null</code>, it is treated as if it were 0.0).
 *
 * @param value  the value./*from   w w w  .java2s  .  co m*/
 * @param rowKey  the row key (<code>null</code> not permitted).
 * @param columnKey  the column key (<code>null</code> not permitted).
 *
 * @throws UnknownKeyException if either key is not defined in the dataset.
 */
public void incrementValue(double value, Comparable rowKey, Comparable columnKey) {
    double existing = 0.0;
    Number n = getValue(rowKey, columnKey);
    if (n != null) {
        existing = n.doubleValue();
    }
    setValue(existing + value, rowKey, columnKey);
}

From source file:org.jfree.data.xy.DefaultHighLowDataset.java

/**
 * Returns the open-value (as a double primitive) for an item within a
 * series.//from  ww  w .j a va  2 s .c  o  m
 *
 * @param series  the series (zero-based index).
 * @param item  the item (zero-based index).
 *
 * @return The open-value.
 *
 * @see #getOpen(int, int)
 */
@Override
public double getOpenValue(int series, int item) {
    double result = Double.NaN;
    Number open = getOpen(series, item);
    if (open != null) {
        result = open.doubleValue();
    }
    return result;
}

From source file:nz.co.senanque.rules.OperationsImpl.java

@InternalFunction(operator = "*", precedence = 21)
public Number mul(Number value, Number value2) {
    return value.doubleValue() * value2.doubleValue();
}

From source file:be.ovam.art46.decorator.TotalTableDecorator.java

public String startRow() {
    String subtotalRow = null;//from w  ww.j a v a  2 s  .  c  o  m

    if (groupPropertyName != null) {
        Object groupedPropertyValue = evaluate(groupPropertyName);
        Object previousGroupedPropertyValue = previousValues.get(groupPropertyName);
        // subtotals
        if (previousGroupedPropertyValue != null
                && !ObjectUtils.equals(previousGroupedPropertyValue, groupedPropertyValue)) {
            subtotalRow = createTotalRow(false);
        }
        previousValues.put(groupPropertyName, groupedPropertyValue);
    }

    for (Iterator it = tableModel.getHeaderCellList().iterator(); it.hasNext();) {
        HeaderCell cell = (HeaderCell) it.next();
        if (cell.isTotaled()) {
            String totalPropertyName = cell.getBeanPropertyName();
            Number amount = (Number) evaluate(totalPropertyName);

            Number previousSubTotal = (Number) subTotals.get(totalPropertyName);
            Number previousGrandTotals = (Number) grandTotals.get(totalPropertyName);

            subTotals.put(totalPropertyName,
                    new Double((previousSubTotal != null ? previousSubTotal.doubleValue() : 0)
                            + (amount != null ? amount.doubleValue() : 0)));

            grandTotals.put(totalPropertyName,
                    new Double((previousGrandTotals != null ? previousGrandTotals.doubleValue() : 0)
                            + (amount != null ? amount.doubleValue() : 0)));
        }
    }

    return subtotalRow;
}

From source file:org.jfree.data.DefaultMeterDataset.java

/**
 * Sets the value for the dataset./* www .j  a  v  a 2s. c om*/
 * 
 * @param value
 *           the new value.
 */
public void setValue(final Number value) {

    if (value != null && this.min != null && this.max != null) {
        if (value.doubleValue() < this.min.doubleValue() || value.doubleValue() > this.max.doubleValue()) {

            throw new IllegalArgumentException("Value is out of range for min/max");

        }
    }
    this.value = value;
    if (value != null && this.min != null && this.max != null) {
        if (this.min.doubleValue() == this.max.doubleValue()) {
            this.min = new Double(value.doubleValue() - DEFAULT_ADJ);
            this.max = new Double(value.doubleValue() + DEFAULT_ADJ);
        }
    }
    fireDatasetChanged();

}

From source file:calendarioSeries.vistas.MainViewController.java

@FXML
public void initialize() {
    next = new Button();
    next.setId("next");
    previous = new Button();
    previous.setId("previous");
    imagenes.widthProperty().addListener(new ChangeListener<Number>() {
        @Override//from w  ww. j  a  v  a  2 s. co m
        public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth,
                Number newSceneWidth) {
            imagenes.hgapProperty().set(newSceneWidth.doubleValue() / 88);
        }
    });
    populateImagenes();
    showDetallesMes(mesActual);
}