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.springmodules.validation.util.condition.range.AbstractBetweenConditionTests.java

public void testCheck_WithDifferentNumberTypes() {
    AbstractBetweenCondition cond = createBetweenCondition(new Integer(3), new Double(2.0));
    try {/*from  w  ww.jav a 2s  . co m*/
        cond.check(new Double(2.5));
    } catch (ClassCastException cce) {
        fail("Comparing numbers of different types sould be possible");
    }
}

From source file:org.openmrs.module.imbmetadata.deploy.bundle.CoreMetadataBundle.java

private void installPersonAttributeTypes() {
    log.info("Installing Person Attribute Types");

    install(personAttributeType(PersonAttributeType.TEST_PATIENT.NAME,
            PersonAttributeType.TEST_PATIENT.DESCRIPTION, Boolean.class, null,
            new Boolean(PersonAttributeType.TEST_PATIENT.SEARCHABLE).booleanValue(),
            new Double(PersonAttributeType.TEST_PATIENT.SORT_WEIGHT), PersonAttributeType.TEST_PATIENT.UUID));

    install(personAttributeType(PersonAttributeType.UNKNOWN_PATIENT.NAME,
            PersonAttributeType.UNKNOWN_PATIENT.DESCRIPTION, String.class, null,
            new Boolean(PersonAttributeType.UNKNOWN_PATIENT.SEARCHABLE).booleanValue(),
            new Double(PersonAttributeType.UNKNOWN_PATIENT.SORT_WEIGHT),
            PersonAttributeType.UNKNOWN_PATIENT.UUID));
}

From source file:charts.PieChart3D.java

/**
 * Creates a sample dataset./*w  ww.j a  v a2  s  .c o m*/
 * 
 * Source: http://www.bbc.co.uk/news/business-15489523
 *
 * @return A sample dataset.
 */
private static PieDataset createDataset(PieChartModel model) {
    DefaultPieDataset dataset = new DefaultPieDataset();
    if (model.getDataList() == null || model.getDataList().isEmpty()) {
        dataset.setValue("FCH", new Double(400));
        dataset.setValue("FCA", new Double(1500));
        dataset.setValue("FCG", new Double(204));
        dataset.setValue("FCS", new Double(430));
        dataset.setValue("FCJ", new Double(40));
    } else {
        model.getDataList().forEach(data -> dataset.setValue(data.getKey(), data.getValue()));
    }
    return dataset;
}

From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreeBarTimeChartData.java

@Override
public JFreeChart getJFreeChart() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    double counts[] = ds.getCounts();
    String legends[] = ds.getLegends();
    int max_len = 0;
    for (int i = 0; i < ds.getNumSets(); i++) {
        if (legends != null && legends.length > i) {
            dataset.addValue(new Double(counts[i]), "Series-1", legends[i]);
            int leg_len = legends[i].length();
            if (leg_len > max_len) {
                max_len = leg_len;//from   w  w  w .j  a va 2 s.co  m
            }
            //System.out.println(legends[i] + counts[i]);
        } else {
            dataset.addValue(new Double(counts[i]), "Series-1", Integer.toString(i));
        }
    }
    CategoryDataset data = dataset;

    JFreeChart chart = ChartFactory.createBarChart(title, null, quantity, data, PlotOrientation.VERTICAL, false, // include legends
            false, // tooltips
            false // urls
    );

    CategoryPlot categoryPlot = chart.getCategoryPlot();
    CategoryAxis axis = categoryPlot.getDomainAxis();
    if (max_len > 8 || ds.getNumSets() > 16 || (max_len * ds.getNumSets()) > 50) {
        axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    }
    Font tickLabelFont = axis.getTickLabelFont();
    if (ds.getNumSets() > 24) {
        axis.setTickLabelFont(tickLabelFont.deriveFont(tickLabelFont.getSize() - 2.0F));
    }
    Font labelFont = axis.getLabelFont();
    axis.setMaximumCategoryLabelLines(3);
    //axis.setLabelFont(labelFont.d);
    // axis.setLabel("Pingu"); This works so we can modify

    return chart;

}

From source file:com.cloudera.recordbreaker.learnstructure.test.GenerateRandomData.java

Object generateData(Schema s) {
    Schema.Type stype = s.getType();
    if (stype == Schema.Type.ARRAY) {
        Schema arrayS = s.getElementType();
        int numElts = 1 + r.nextInt(100);
        GenericData.Array result = new GenericData.Array(numElts, arrayS);
        for (int i = 0; i < numElts; i++) {
            result.add(generateData(arrayS));
        }/*  w ww  .jav  a 2 s.co m*/
        return arrayS;
    } else if (stype == Schema.Type.BOOLEAN) {
        return r.nextInt(2) == 0 ? new Boolean(true) : new Boolean(false);
    } else if (stype == Schema.Type.BYTES) {
        return ByteBuffer.wrap(new byte[16]);
    } else if (stype == Schema.Type.DOUBLE) {
        return new Double(r.nextDouble());
    } else if (stype == Schema.Type.ENUM) {
        List<String> symbols = s.getEnumSymbols();
        return symbols.get(r.nextInt(symbols.size()));
    } else if (stype == Schema.Type.FIXED) {
        return new GenericData.Fixed(s, new byte[16]);
    } else if (stype == Schema.Type.FLOAT) {
        return new Float(r.nextFloat());
    } else if (stype == Schema.Type.INT) {
        return new Integer(r.nextInt());
    } else if (stype == Schema.Type.LONG) {
        return new Long(r.nextLong());
    } else if (stype == Schema.Type.MAP) {
        HashMap<Utf8, Object> result = new HashMap<Utf8, Object>();
        Schema valType = s.getValueType();
        int maxElts = 1 + r.nextInt(100);
        for (int i = 0; i < maxElts; i++) {
            result.put(new Utf8("label-" + i), generateData(valType));
        }
        return result;
    } else if (stype == Schema.Type.NULL) {
        return null;
    } else if (stype == Schema.Type.RECORD) {
        GenericData.Record result = new GenericData.Record(s);
        for (Schema.Field f : s.getFields()) {
            result.put(f.name(), generateData(f.schema()));
        }
        return result;
    } else if (stype == Schema.Type.STRING) {
        return new Utf8("Rand-" + r.nextInt());
    } else if (stype == Schema.Type.UNION) {
        List<Schema> types = s.getTypes();
        return generateData(types.get(r.nextInt(types.size())));
    }
    return null;
}

From source file:net.jofm.format.NumberFormat.java

private Object convert(Number result, Class<?> destinationClazz) {
    if (destinationClazz.equals(BigDecimal.class)) {
        return new BigDecimal(result.doubleValue());
    }//from   ww  w  .  j  a  v  a2 s. c o  m
    if (destinationClazz.equals(Short.class) || destinationClazz.equals(short.class)) {
        return new Short(result.shortValue());
    }
    if (destinationClazz.equals(Integer.class) || destinationClazz.equals(int.class)) {
        return new Integer(result.intValue());
    }
    if (destinationClazz.equals(Long.class) || destinationClazz.equals(long.class)) {
        return new Long(result.longValue());
    }
    if (destinationClazz.equals(Float.class) || destinationClazz.equals(float.class)) {
        return new Float(result.floatValue());
    }
    if (destinationClazz.equals(Double.class) || destinationClazz.equals(double.class)) {
        return new Double(result.doubleValue());
    }

    throw new FixedMappingException("Unable to parse the data to type " + destinationClazz.getName() + " using "
            + this.getClass().getName());
}

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

private static XYZDataset createDataset() {
    return new XYZDataset() {

        public int getSeriesCount() {
            return 1;
        }/*from   w  w w .j a  v  a 2  s .  c  o  m*/

        public int getItemCount(int i) {
            return 10000;
        }

        public Number getX(int i, int j) {
            return new Double(getXValue(i, j));
        }

        public double getXValue(int i, int j) {
            return (double) (j / 100 - 50);
        }

        public Number getY(int i, int j) {
            return new Double(getYValue(i, j));
        }

        public double getYValue(int i, int j) {
            return (double) (j - (j / 100) * 100 - 50);
        }

        public Number getZ(int i, int j) {
            return new Double(getZValue(i, j));
        }

        public double getZValue(int i, int j) {
            double d = getXValue(i, j);
            double d1 = getYValue(i, j);
            return Math.sin(Math.sqrt(d * d + d1 * d1) / 5D);
        }

        public void addChangeListener(DatasetChangeListener datasetchangelistener) {
        }

        public void removeChangeListener(DatasetChangeListener datasetchangelistener) {
        }

        public DatasetGroup getGroup() {
            return null;
        }

        public void setGroup(DatasetGroup datasetgroup) {
        }

        @SuppressWarnings("rawtypes")
        public Comparable getSeriesKey(int i) {
            return "sin(sqrt(x + y))";
        }

        @SuppressWarnings("rawtypes")
        public int indexOf(Comparable comparable) {
            return 0;
        }

        public DomainOrder getDomainOrder() {
            return DomainOrder.ASCENDING;
        }

    };
}

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

/**
 * Confirm that cloning works.//from  w  w w .jav a2 s .c om
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    DefaultKeyedValueDataset d1 = new DefaultKeyedValueDataset("Test", new Double(45.5));
    DefaultKeyedValueDataset d2 = (DefaultKeyedValueDataset) d1.clone();
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));
}

From source file:bigtweet.model.StudyingBeacons.java

@Override
public void loadPreviousBestResults(JSONObject o) {
    experimentWithBestEndorser = new Integer(o.get("experimentWithBestEndorsers").toString());
    experimentWithBestMean = new Integer(o.get("experimentWithBestMean").toString());
    bestEndorser = new Double(o.get("bestEndorsers").toString());
    bestMean = new Double(o.get("bestMean").toString());
}

From source file:Panels.FinanzPanel.java

public void callDb() {

    try {// w ww  .java 2s.com
        st = this.dc.getOracleConnector().dbcon.createStatement();
        result = st.executeQuery("select * from finanzplan where IDFinPlan=" + name + "");
        while (result.next()) {
            System.out.println("Test:" + result.getInt("geplant"));
            dataset.setValue("GEPLANT", new Double(result.getFloat("GEPLANT")));
            dataset.setValue("VORHANDEN", new Double(result.getFloat("VORHANDEN")));

        }

        plot = new PiePlot(dataset);
        chart1 = new JFreeChart(plot);
        chartPanel1 = new ChartPanel(chart1);
        chartPanel1.setMouseWheelEnabled(true);
        this.setLayout(new java.awt.BorderLayout());
        this.add(chartPanel1, BorderLayout.CENTER);
        this.validate();
    } catch (SQLException ex) {
        Logger.getLogger(MitarbeiterPanel.class.getName()).log(Level.SEVERE, null, ex);
    }
}