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.primefaces.showcase.view.multimedia.GraphicImageView.java

private PieDataset createDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("New York", new Double(45.0));
    dataset.setValue("London", new Double(15.0));
    dataset.setValue("Paris", new Double(25.2));
    dataset.setValue("Berlin", new Double(14.8));

    return dataset;
}

From source file:test.gov.nih.nci.cacoresdk.domain.other.primarykey.DoublePrimitiveKeyResourceTest.java

/**
 * Uses Nested Search Criteria for search
 * Verifies that the results are returned 
 * Verifies size of the result set/*w  ww .  jav a 2 s. co  m*/
 * Verifies that none of the attributes are null
 * 
 * @throws Exception
 */
public void testGet() throws Exception {

    try {

        DoublePrimitiveKey searchObject = new DoublePrimitiveKey();
        Collection results = getApplicationService()
                .search("gov.nih.nci.cacoresdk.domain.other.primarykey.DoublePrimitiveKey", searchObject);
        String id = "";

        if (results != null && results.size() > 0) {
            DoublePrimitiveKey obj = (DoublePrimitiveKey) ((List) results).get(0);

            Double idVal = obj.getId();
            id = new Double(idVal).toString();

        } else
            return;

        if (id.equals(""))
            return;

        String url = baseURL + "/rest/DoublePrimitiveKey/" + id;

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("DoublePrimitiveKey" + "XML.xml");

        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }

}

From source file:org.hazelcast.cloudfoundry.servicebroker.config.HazelcastCatalogConfig.java

private List<Map<String, Object>> getCosts() {
    Map<String, Object> costsMap = new HashMap<String, Object>();

    Map<String, Object> amount = new HashMap<String, Object>();
    amount.put("usd", new Double(0));

    costsMap.put("amount", amount);
    costsMap.put("unit", "MONTHLY");

    return Arrays.asList(costsMap);
}

From source file:com.bstek.dorado.data.variant.LinkedMetaData.java

public void setDouble(String key, double d) {
    put(key, new Double(d));
}

From source file:com.brsanthu.dataexporter.DataExporterTestBase.java

@Before
public void setup() {
    if (exporter == null) {
        return;/*from w w w.  ja  v  a2s  .c  o m*/
    }
    exporter.addColumns(new LineNumberColumn("lineNo", "Line No", 5),
            new DateColumn("datePurchased", "Date Purchased", 23, "yyyy/MM/dd hh:mm:ss a"),
            new NumberColumn("itemNo", "Item No", 10, 0), new StringColumn("itemName", "Item Name", 15),
            new BooleanColumn("shipped", "Shipped?", 10), new NumberColumn("quantity", "Quantity", 10, 0),
            new CurrencyColumn("unitPrice", "Unit Price", 10, "$"),
            new CurrencyColumn("price", "Price", 10, "$").setGeneratesOwnData(true)
                    .setCellValueGenerator(new CellValueGenerator() {
                        @Override
                        public Object generateCellValue(CellDetails cellDetails) {
                            return new Double(((Integer) cellDetails.getRow().getCellValue(5))
                                    * ((Double) cellDetails.getRow().getCellValue(6)));
                        }
                    }));
}

From source file:org.jfree.data.general.DefaultKeyedValues2DDatasetTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *///from   w w  w .  ja v  a2s .  c o m
public void testSerialization() {
    DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset();
    d1.addValue(new Double(234.2), "Row1", "Col1");
    d1.addValue(null, "Row1", "Col2");
    d1.addValue(new Double(345.9), "Row2", "Col1");
    d1.addValue(new Double(452.7), "Row2", "Col2");

    DefaultKeyedValues2DDataset d2 = (DefaultKeyedValues2DDataset) TestUtilities.serialised(d1);
    assertEquals(d1, d2);
}

From source file:playground.wrashid.tryouts.mess.Boxplot.java

private static BoxAndWhiskerCategoryDataset createSampleDataset() {

    final int seriesCount = 3;
    final int categoryCount = 4;
    final int entityCount = 22;

    final DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    for (int i = 0; i < seriesCount; i++) {
        for (int j = 0; j < categoryCount; j++) {
            final List list = new ArrayList();
            // add some values...
            for (int k = 0; k < entityCount; k++) {
                final double value1 = 10.0 + Math.random() * 3;
                list.add(new Double(value1));
                final double value2 = 11.25 + Math.random(); // concentrate values in the middle
                list.add(new Double(value2));
            }//from  ww  w  . j a  va2s .  c  o  m
            dataset.add(list, "Series " + i, " Type " + j);
        }

    }

    return dataset;
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.ExecutionDashboard.java

private void init() {
    setCaption(TRANSLATOR.translate("execution.dash"));
    setHeight(100, Unit.PERCENTAGE);/*w  w  w  . j a v  a2 s . c  om*/
    setWidth(100, Unit.PERCENTAGE);
    //Gather stats
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    extractions.forEach((e) -> {
        ExecutionStats es = new ExecutionStats(e);
        es.stats.entrySet().forEach((entry) -> {
            //This is for the whole execution
            ExecutionResultServer.getResults().forEach((er) -> {
                if (e.getTestCase() == null || e.getTestCase().getName().equals(entry.getKey())) {
                    dataset.addValue(new Double(entry.getValue().get(er.getResultName())), entry.getKey(),
                            Lookup.getDefault().lookup(InternationalizationProvider.class)
                                    .translate(er.getResultName()));
                }
            });
        });
    });
    //Build bar graph
    JFreeChart chart = ChartFactory.createBarChart(TRANSLATOR.translate("execution.progress"), // chart title
            TRANSLATOR.translate("test.case"), TRANSLATOR.translate("general.amount"), dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, false);
    setContent(new JFreeChartWrapper(chart));
}

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

/**
 * Some checks for the getValue() method.
 *///from w  ww .jav  a  2  s  . c om
@Test
public void testGetValue() {
    DefaultKeyedValues2D d = new DefaultKeyedValues2D();
    d.addValue(new Double(1.0), "R1", "C1");
    assertEquals(new Double(1.0), d.getValue("R1", "C1"));
    boolean pass = false;
    try {
        d.getValue("XX", "C1");
    } catch (UnknownKeyException e) {
        pass = true;
    }
    assertTrue(pass);

    pass = false;
    try {
        d.getValue("R1", "XX");
    } catch (UnknownKeyException e) {
        pass = true;
    }
    assertTrue(pass);
}

From source file:jcalccalculator.TaskClient.java

public boolean cmdOperation(Request rq) throws ComputeEngineException {
    Response rs = new Response();

    Operation op = (Operation) rq.getData().get(0);
    if (op.getType().compareTo("x+y") == 0) {
        Float[] numeros = new Float[op.getInputData().size()];
        for (int i = 0; i < numeros.length; i++) {
            numeros[i] = (Float) op.getInputData().get(i).value;
        }/*from   ww  w .  ja va 2 s  .  c o  m*/
        float[] datos = ArrayUtils.toPrimitive(numeros);
        Double res = new Double(fengine.sumar(datos));
        op.setResult(res);

        rs.setSubtype("_JCALC_OPERATION_OK_");
        rs.addData(op);
        return ccp.sendResponse(rs);
    } else if (op.getType().compareTo("x-y") == 0) {

        Float[] numeros = new Float[op.getInputData().size()];
        for (int i = 0; i < numeros.length; i++) {
            numeros[i] = (Float) op.getInputData().get(i).value;
        }
        float[] datos = ArrayUtils.toPrimitive(numeros);
        Double res = new Double(fengine.restar(datos));
        op.setResult(res);

        rs.setSubtype("_JCALC_OPERATION_OK_");
        rs.addData(op);
        return ccp.sendResponse(rs);
    }

    else if (op.getType().compareTo("media") == 0) {
        Float[] numeros = (Float[]) op.getInputData().get(0).value;

        float[] datos = ArrayUtils.toPrimitive(numeros);
        Double res = new Double(fengine.media(datos));
        op.setResult(res);

        rs.setSubtype("_JCALC_OPERATION_OK_");
        rs.addData(op);
        return ccp.sendResponse(rs);
    } else if (op.getType().compareTo("varianza") == 0) {
        Float[] numeros = (Float[]) op.getInputData().get(0).value;

        float[] datos = ArrayUtils.toPrimitive(numeros);
        Double res = new Double(fengine.varianza(datos));
        op.setResult(res);

        rs.setSubtype("_JCALC_OPERATION_OK_");
        rs.addData(op);
        return ccp.sendResponse(rs);
    } else if (op.getType().compareTo("desviacion") == 0) {
        Float[] numeros = (Float[]) op.getInputData().get(0).value;

        float[] datos = ArrayUtils.toPrimitive(numeros);
        Double res = null;
        try {
            res = new Double(fengine.desviacion(datos));
        } catch (ComputeEngineException ex) {
            Logger.getLogger(TaskClient.class.getName()).log(Level.SEVERE, null, ex);
        }
        op.setResult(res);

        rs.setSubtype("_JCALC_OPERATION_OK_");
        rs.addData(op);
        return ccp.sendResponse(rs);
    } else if (op.getType().compareTo("moda") == 0) {
        Float[] numeros = (Float[]) op.getInputData().get(0).value;

        float[] datos = ArrayUtils.toPrimitive(numeros);
        Double res = null;
        res = new Double(fengine.moda(datos));
        op.setResult(res);

        rs.setSubtype("_JCALC_OPERATION_OK_");
        rs.addData(op);
        return ccp.sendResponse(rs);
    } else if (op.getType().compareTo("mediana") == 0) {
        Float[] numeros = (Float[]) op.getInputData().get(0).value;

        float[] datos = ArrayUtils.toPrimitive(numeros);
        Double res = null;
        res = new Double(fengine.mediana(datos));
        op.setResult(res);

        rs.setSubtype("_JCALC_OPERATION_OK_");
        rs.addData(op);
        return ccp.sendResponse(rs);
    } else if (op.getType().compareTo("mediaGeometrica") == 0) {
        Float[] numeros = (Float[]) op.getInputData().get(0).value;

        float[] datos = ArrayUtils.toPrimitive(numeros);
        try {
            Double res = fengine.mediaGeometrica(datos);
            op.setResult(res);
            rs.setSubtype("_JCALC_OPERATION_OK_");
        } catch (ComputeEngineException ex) {
            protocol.common.Error err = new protocol.common.Error();
            err.type = ex.getMessage();
            err.msg = "Raz cuadrada negativa";
            op.setResult(err);
            rs.setSubtype("_JCALC_OPERATION_ERROR_");
        }

        rs.addData(op);
        return ccp.sendResponse(rs);
    } else if (op.getType().compareTo("aproximacionE") == 0) {
        Float n = (Float) op.getInputData().get(0).value;
        double rss = fengine.aproximacionE(n.floatValue());
        Double res = new Double(rss);
        // Double res = new Double(fengine.x2(n.floatValue()));
        op.setResult(res);
        rs.setSubtype("_JCALC_OPERATION_OK_");
        rs.addData(op);
        return ccp.sendResponse(rs);
    }

    else if (op.getType().compareTo("x*y") == 0) {

        Float[] numeros = new Float[op.getInputData().size()];
        for (int i = 0; i < numeros.length; i++) {
            numeros[i] = (Float) op.getInputData().get(i).value;
        }
        float[] datos = ArrayUtils.toPrimitive(numeros);
        Double res = new Double(fengine.multiplicar(datos));
        op.setResult(res);

        rs.setSubtype("_JCALC_OPERATION_OK_");
        rs.addData(op);
        return ccp.sendResponse(rs);
    }

    else if (op.getType().compareTo("x/y") == 0) {
        Float[] numeros = new Float[op.getInputData().size()];
        for (int i = 0; i < numeros.length; i++) {
            numeros[i] = (Float) op.getInputData().get(i).value;
        }
        float[] datos = ArrayUtils.toPrimitive(numeros);
        try {
            Double res = new Double(fengine.dividir(datos));
            op.setResult(res);

            rs.setSubtype("_JCALC_OPERATION_OK_");
            rs.addData(op);
        } catch (ComputeEngineException ex) {
            protocol.common.Error err = new protocol.common.Error();
            err.type = ex.getMessage();
            err.msg = "Divisor 0";
            op.setResult(err);
            rs.setSubtype("_JCALC_OPERATION_ERROR_");
        }
        rs.addData(op);
        return ccp.sendResponse(rs);
    } else if (op.getType().compareTo("x2") == 0) {

        Float n = (Float) op.getInputData().get(0).value;
        double rss = fengine.x2(n.floatValue());
        Double res = new Double(rss);
        // Double res = new Double(fengine.x2(n.floatValue()));
        op.setResult(res);
        rs.setSubtype("_JCALC_OPERATION_OK_");
        rs.addData(op);
        return ccp.sendResponse(rs);
    } else if (op.getType().compareTo("cambioSigno") == 0) {

        Float n = (Float) op.getInputData().get(0).value;
        double rss = fengine.cambioSigno(n.floatValue());
        Double res = new Double(rss);
        // Double res = new Double(fengine.x2(n.floatValue()));
        op.setResult(res);
        rs.setSubtype("_JCALC_OPERATION_OK_");
        rs.addData(op);
        return ccp.sendResponse(rs);
    }

    else if (op.getType().compareTo("raiz2") == 0) {

        Float n = (Float) op.getInputData().get(0).value;
        double rss = 0;
        try {
            rss = fengine.raiz2(n.floatValue());
            Double res = new Double(rss);
            op.setResult(res);
            rs.setSubtype("_JCALC_OPERATION_OK_");
        } catch (ComputeEngineException ex) {
            protocol.common.Error err = new protocol.common.Error();
            err.type = ex.getMessage();
            err.msg = "Raz cuadrada negativa";
            op.setResult(err);
            rs.setSubtype("_JCALC_OPERATION_ERROR_");
        }

        rs.addData(op);
        return ccp.sendResponse(rs);
    } else if (op.getType().compareTo("segundoGrado") == 0) {
        Float[] numeros = new Float[op.getInputData().size()];
        for (int i = 0; i < numeros.length; i++) {
            numeros[i] = (Float) op.getInputData().get(i).value;
        }
        float[] datos = ArrayUtils.toPrimitive(numeros);
        float[] resta = new float[2];
        float[] suma = new float[2];
        resta[0] = datos[0];
        resta[1] = datos[2];
        suma[0] = datos[1];
        suma[1] = datos[2];
        try {
            Double[] res = new Double[2];
            res[0] = new Double(fengine.dividir(suma));
            res[1] = new Double(fengine.dividir(resta));
            op.setResult(res);

            rs.setSubtype("_JCALC_OPERATION_OK_");
            rs.addData(op);
        } catch (ComputeEngineException ex) {
            if (ex.getMessage() == "DIVIDE_BY_ZERO") {
                protocol.common.Error err = new protocol.common.Error();
                err.type = ex.getMessage();
                err.msg = "Divisor 0";
                op.setResult(err);
                rs.setSubtype("_JCALC_OPERATION_ERROR_");
            }
            if (ex.getMessage() == "SQUAREROOT_NEGATIVE") {
                protocol.common.Error err = new protocol.common.Error();
                err.type = ex.getMessage();
                err.msg = "Raz cuadrada negativa";
                op.setResult(err);
                rs.setSubtype("_JCALC_OPERATION_ERROR_");
            }
            rs.addData(op);
            return ccp.sendResponse(rs);
        }
        return ccp.sendResponse(rs);
    }

    return true;
}