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:xdevs.lib.util.ScopeMultiView.java

public void addPoint(String serieName, Number x, Number y) {
    seriesMap.get(serieName).add(x.doubleValue(), y.doubleValue());
}

From source file:org.javarebel.chart.generator.DefaultChartLabelGenerator.java

@Override
public String generateLabel(CategoryDataset arg0, int arg1, int arg2) {
    Number val = arg0.getValue(arg1, arg2);
    return (val != null && val.doubleValue() != 0.0D) ? numFrmt.format(val) : "";
}

From source file:com.flexive.shared.FxFormatUtils.java

/**
 * Convert a String to Integer//from   ww  w  . j ava2 s. co m
 *
 * @param value value to convert
 * @return Integer
 */
public static Integer toInteger(String value) {
    if (StringUtils.isBlank(value))
        return null;
    final ParsePosition pos = new ParsePosition(0);
    final String _value = value.trim();
    try {
        final Number parse = FxValueRendererFactory.getNumberFormatInstance().parse(unquote(_value), pos);
        if (pos.getErrorIndex() >= 0 || pos.getIndex() != _value.length()
                || parse.doubleValue() != (double) parse.intValue() /*truncation*/)
            throw new FxConversionException("ex.conversion.value.error", FxNumber.class.getCanonicalName(),
                    value, "Failed to parse " + value).asRuntimeException();
        return parse.intValue();
    } catch (NumberFormatException e) {
        throw new FxConversionException("ex.conversion.value.error", FxLargeNumber.class.getCanonicalName(),
                value,
                "Failed to parse [" + value + "] using dec.sep. [" + FxContext.get().getDecimalSeparator()
                        + "] and grouping sep. [" + FxContext.get().getDecimalSeparator() + "]")
                                .asRuntimeException();
    }
}

From source file:com.flexive.shared.FxFormatUtils.java

/**
 * Convert a String to Long/*from  ww  w. j av  a 2s.c  o  m*/
 *
 * @param value value to convert
 * @return Long
 */
public static Long toLong(String value) {
    if (StringUtils.isBlank(value))
        return null;
    final ParsePosition pos = new ParsePosition(0);
    final String _value = value.trim();
    try {
        final Number parse = FxValueRendererFactory.getNumberFormatInstance().parse(unquote(_value), pos);
        if (pos.getErrorIndex() >= 0 || pos.getIndex() != _value.length()
                || parse.doubleValue() != (double) parse.longValue() /*truncation*/)
            throw new FxConversionException("ex.conversion.value.error", FxLargeNumber.class.getCanonicalName(),
                    value, "Failed to parse " + value).asRuntimeException();
        return parse.longValue();
    } catch (NumberFormatException e) {
        throw new FxConversionException("ex.conversion.value.error", FxLargeNumber.class.getCanonicalName(),
                value,
                "Failed to parse [" + value + "] using dec.sep. [" + FxContext.get().getDecimalSeparator()
                        + "] and grouping sep. [" + FxContext.get().getDecimalSeparator() + "]")
                                .asRuntimeException();
    }
}

From source file:com.att.aro.main.PercentLabelGenerator.java

/**
 * Returns a percentage label string using the data in the specified row and
 * column of the dataset.//from   www  .j  ava 2s.  c o  m
 * 
 * @param dataset
 *            The dataset containing the data for the chart.
 * 
 * @param row
 *            The row of data in the dataset.
 * 
 * @param column
 *            The column of data in the dataset.
 * 
 * @return A string that is the percentage label.
 */
@Override
public String generateLabel(CategoryDataset dataset, int row, int column) {
    Number value = dataset.getValue(row, column);
    return value != null ? formatter.format(value.doubleValue()) : "";
}

From source file:net.sf.jasperreports.engine.util.JRFloatLocaleConverter.java

@Override
protected Object parse(Object value, String pattern) throws ParseException {
    final Number parsed = (Number) super.parse(value, pattern);
    double doubleValue = parsed.doubleValue();
    double posDouble = (doubleValue >= 0) ? doubleValue : (doubleValue * -1);
    if ((posDouble > 0 && posDouble < Float.MIN_VALUE) || posDouble > Float.MAX_VALUE) {
        throw new ConversionException("Supplied number is not of type Float: " + parsed);
    }/*  w  w w . jav  a  2  s.co  m*/
    return parsed.floatValue(); // unlike superclass it returns Float type
}

From source file:com.mgmtp.perfload.loadprofiles.ui.component.DoubleCellEditor.java

@Override
public boolean stopCellEditing() {
    String s = (String) super.getCellEditorValue();
    JTextField textField = (JTextField) getComponent();

    if (isBlank(s)) {
        textField.setBorder(new LineBorder(Color.red));
        return false;
    }/*from  w ww  .jav  a2  s.  c  o  m*/

    try {
        value = Double.valueOf(s);
    } catch (NumberFormatException ex2) {
        try {
            Number n = FORMAT.parse(s);
            value = n.doubleValue();
        } catch (ParseException ex1) {
            textField.setBorder(new LineBorder(Color.red));
            textField.selectAll();
            return false;
        }
    }

    return super.stopCellEditing();
}

From source file:griffon.javafx.editors.ColorPropertyEditor.java

private double parse(Number val) {
    return val.doubleValue();
}

From source file:gedi.util.FileUtils.java

public static void writeNumber(BinaryWriter out, Number d) throws IOException {
    if (d instanceof Byte)
        out.putByte(d.intValue());/*w  ww .  java2 s.co  m*/
    else if (d instanceof Short)
        out.putShort(d.shortValue());
    else if (d instanceof Integer)
        out.putInt(d.intValue());
    else if (d instanceof Long)
        out.putLong(d.longValue());
    else if (d instanceof Float)
        out.putFloat(d.floatValue());
    else
        out.putDouble(d.doubleValue());
}

From source file:edu.uci.ics.jung.visualization.decorators.InterpolatingVertexSizeTransformer.java

public Integer transform(V v) {
    Number n = values.transform(v);
    double value = min;
    if (n != null)
        value = n.doubleValue();
    min = Math.min(this.min, value);
    max = Math.max(this.max, value);

    if (min == max)
        return min_size;

    // interpolate between min and max sizes based on how big value is 
    // with respect to min and max values
    return min_size + (int) (((value - min) / (max - min)) * size_diff);
}