Example usage for java.lang Double Double

List of usage examples for java.lang Double Double

Introduction

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

Prototype

@Deprecated(since = "9")
public Double(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Double object that represents the floating-point value of type double represented by the string.

Usage

From source file:org.jfree.chart.demo.BoxAndWhiskerChartDemo1.java

@SuppressWarnings("rawtypes")
private static List createValueList(double d, double d1, int i) {
    ArrayList<Double> arraylist = new ArrayList<Double>();
    for (int j = 0; j < i; j++) {
        double d2 = d + Math.random() * (d1 - d);
        arraylist.add(new Double(d2));
    }/*from  w  ww .  j a v a 2  s.com*/

    return arraylist;
}

From source file:Util.java

/**
 * Returns an array of indices indicating the order the data should be sorted
 * in. Duplicate values are discarded with the first one being kept. This method
 * is useful when a number of data arrays have to be sorted based on the values in
 * some coordinate array, such as time./* w w w . j a  va 2 s. co m*/
 *
 * To convert a array of values to a sorted monooic array try: <br>
 *    double[] x;  // some 1-D array of data <br>
 *    int[] i = MathUtilities.uniqueSort(x); <br>
 *    double[] xSorted = MathUtilities.orderVector(x, i);<br><br>
 *
 * @param x An array of data that is to be sorted.
 * @return order An array of indexes such that y = Array.sort(x) and
 * y = x(order) are the same.
 */
public static final synchronized int[] uniqueSort(double[] x) {
    TreeMap tm = new TreeMap();
    for (int i = 0; i < x.length; i++) {
        Double key = new Double(x[i]);
        boolean exists = tm.containsKey(key);
        if (exists) {
            // Do nothing. Ignore duplicate keys
        } else {
            tm.put(key, new Integer(i));
        }
    }
    Object[] values = tm.values().toArray();
    int[] order = new int[values.length];
    for (int i = 0; i < values.length; i++) {
        Integer tmp = (Integer) values[i];
        order[i] = tmp.intValue();
    }
    return order;
}

From source file:com.bstek.dorado.data.type.PrimitiveDoubleDataType.java

@Override
public Object fromText(String text) {
    if (StringUtils.isEmpty(text)) {
        return new Double(0);
    }/*  w ww.  j ava 2 s .co  m*/
    return super.fromText(text);
}

From source file:com.orca.app.LicenseTests.java

@Test
public void calculatedValueTests() {
    License license = new License();
    license.populate();/*from w w  w.j ava  2s.  c o  m*/
    assertTrue(license.getCalculatedValue() == new Double(10));
}

From source file:NumberFormatDemo.java

static public void displayNumber(Locale currentLocale) {

    Integer quantity = new Integer(123456);
    Double amount = new Double(345987.246);
    NumberFormat numberFormatter;
    String quantityOut;/*from   ww  w.java2  s .  co  m*/
    String amountOut;

    numberFormatter = NumberFormat.getNumberInstance(currentLocale);
    quantityOut = numberFormatter.format(quantity);
    amountOut = numberFormatter.format(amount);
    System.out.println(quantityOut + "   " + currentLocale.toString());
    System.out.println(amountOut + "   " + currentLocale.toString());
}

From source file:nl.ortecfinance.opal.jacksonweb.SimulationResponseTest.java

@Test
public void testJsonIgnore() throws IOException {

    SimulationResponse resp = new SimulationResponse();

    resp.setCapitalGoalProbabilities(Arrays.asList(new Double(10), null, new Double(33)));

    StringWriter sr = new StringWriter();
    ObjectMapper om = new ObjectMapper();

    SimpleModule module = new SimpleModule();
    //      module.addSerializer(List<Double[]>.class, new ListOfDoubleArraySerializer());
    module.addSerializer(Double[].class, new MyDoubleArraySerializer());
    om.registerModule(module);/*from  w w w.j av  a 2 s.  com*/
    om.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    om.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);

    om.writeValue(sr, resp);

    System.out.println("SimulationResponse=" + sr);

}

From source file:org.jfree.chart.demo.SampleXYZDataset2.java

public Number getX(int i, int j) {
    return new Double(xVal[i][j]);
}

From source file:TimeFormatUtil.java

public static String getTimeLabel(double seconds, boolean longFormat) {
    int secs = new Double(Math.floor(seconds)).intValue();

    int hours = secs / 3600;
    secs = secs % 3600;/* w w  w .j av  a 2 s  .  c o  m*/

    int minutes = secs / 60;
    secs = secs % 60;

    StringBuilder b = new StringBuilder();

    if (hours > 0) {
        if (hours < 10)
            b.append(0);

        b.append(hours);
        b.append(longFormat ? "h " : ":");
    }

    if (minutes < 10)
        b.append(0);

    b.append(minutes);
    b.append(longFormat ? "m " : ":");

    if (secs < 10)
        b.append(0);

    b.append(secs);

    if (longFormat) {
        int hundreths = Double.valueOf((seconds - secs) * 100).intValue();
        b.append(".");
        b.append(hundreths);
        b.append("s");
    }

    return b.toString();
}

From source file:net.sourceforge.fenixedu.presentationTier.validator.form.GreaterThen.java

public static boolean validateFloat(Object bean, ValidatorAction va, Field field, ActionMessages errors,
        HttpServletRequest request, ServletContext application) {

    String inputString = ValidatorUtils.getValueAsString(bean, field.getProperty());
    String lowerValueString = field.getVarValue("value");

    if ((inputString == null) || (inputString.length() == 0)) {
        return true;
    }//from   w w  w. j av  a2 s . c  om
    Double input = null;
    Double lowerValue = null;

    try {
        input = new Double(inputString);
        lowerValue = new Double(lowerValueString);
    } catch (NumberFormatException e) {
        errors.add(field.getKey(), Resources.getActionMessage(request, va, field));
        return false;
    }

    if (!GenericValidator.isBlankOrNull(inputString)) {
        if (input.floatValue() <= lowerValue.floatValue()) {
            errors.add(field.getKey(), Resources.getActionMessage(request, va, field));
        }
        return false;
    }

    return true;
}

From source file:org.jfree.chart.demo.SampleXYZDataset2.java

public Number getY(int i, int j) {
    return new Double(yVal[i][j]);
}