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.SampleXYZDataset.java

/**
 * Returns the x-value for an item within a series.
 * <P>/*  ww w .  ja va  2 s  .c  om*/
 * The implementation is responsible for ensuring that the x-values are
 * presented in ascending order.
 *
 * @param series  the series (zero-based index).
 * @param item  the item (zero-based index).
 *
 * @return the x-value.
 */
public double getXValue(final int series, final int item) {
    return new Double(this.xVal[item]).doubleValue();
}

From source file:org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDatasetTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *///from   ww w.  j  ava 2s .c  om
@Test
public void testSerialization() {
    DefaultBoxAndWhiskerCategoryDataset d1 = new DefaultBoxAndWhiskerCategoryDataset();
    d1.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0),
            new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()), "ROW1",
            "COLUMN1");
    DefaultBoxAndWhiskerCategoryDataset d2 = (DefaultBoxAndWhiskerCategoryDataset) TestUtilities.serialised(d1);
    assertEquals(d1, d2);
}

From source file:net.sourceforge.fenixedu.domain.oldInquiries.StudentInquiriesCourseResult.java

private Double getValueForPresentation(Double value) {
    // TODO: ugly hack, refactor
    if (value == null) {
        return new Double(0);
    }/*from  w ww.j  av  a  2 s  .  co m*/
    BigDecimal round = new BigDecimal(value);
    round.setScale(2, RoundingMode.HALF_EVEN);
    return round.doubleValue();
}

From source file:eagle.log.entity.TestHBaseWriteEntitiesPerformance.java

private List<String> writeEntities(int count) {
    GenericEntityWriter writer = null;//from  w  w  w  .j  a  va  2  s .com
    try {
        writer = new GenericEntityWriter(ed.getService());
    } catch (InstantiationException e1) {
        Assert.fail(e1.getMessage());
    } catch (IllegalAccessException e1) {
        Assert.fail(e1.getMessage());
    }

    if (LOG.isDebugEnabled())
        LOG.debug("Start to write " + count + " entities");
    int wroteCount = 0;
    List<String> rowkeys = new ArrayList<String>();
    List<TestLogAPIEntity> list = new ArrayList<TestLogAPIEntity>();
    for (int i = 0; i <= count; i++) {
        TestLogAPIEntity e = new TestLogAPIEntity();
        e.setTimestamp(new Date().getTime());
        e.setField1(i);
        e.setField2(i);
        e.setField3(i);
        e.setField4(new Long(i));
        e.setField5(new Double(i));
        e.setField6(new Double(i));
        e.setField7(String.valueOf(i));
        e.setTags(new HashMap<String, String>());
        e.getTags().put("jobID", "index_test_job_id");
        e.getTags().put("hostname", "testhost");
        e.getTags().put("index", String.valueOf(i));
        e.getTags().put("class", e.toString());
        list.add(e);

        if (list.size() >= 1000) {
            try {
                StopWatch watch = new StopWatch();
                watch.start();
                rowkeys.addAll(writer.write(list));
                watch.stop();
                wroteCount += list.size();
                if (LOG.isDebugEnabled())
                    LOG.debug("Wrote " + wroteCount + " / " + count + " entities" + " in " + watch.getTime()
                            + " ms");
                list.clear();
            } catch (Exception e1) {
                Assert.fail(e1.getMessage());
            }
        }
    }

    try {
        rowkeys.addAll(writer.write(list));
        wroteCount += list.size();
        if (LOG.isDebugEnabled())
            LOG.debug("wrote " + wroteCount + " / " + count + " entities");
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    if (LOG.isDebugEnabled())
        LOG.debug("done " + count + " entities");
    return rowkeys;
}

From source file:com.marvelution.jira.plugins.hudson.charts.renderers.BuildResultRenderer.java

/**
 * {@inheritDoc}//from w  w w  . j a v  a 2s.c o m
 */
@Override
public String generateToolTip(XYDataset dataset, int series, int item) {
    final int number = new Double(dataset.getXValue(0, item)).intValue();
    final Build build = builds.get(number);
    return "Build: " + build.getBuildNumber() + " - " + build.getResult().name();
}

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

protected void addDataBeans() {
    List<SampleBean> beans = new ArrayList<SampleBean>();
    beans.add(new SampleBean(new Date(dateReference - 2397984), new Integer(1), "Laptop", new Boolean(false),
            new Integer(1), new Double(799.78)));
    beans.add(new SampleBean(new Date(dateReference - 232042098), new Integer(2), "Mouse", new Boolean(true),
            new Integer(2), new Double(49.30)));
    beans.add(new SampleBean(new Date(dateReference - 234084277), new Integer(3), "Keyboard",
            new Boolean(false), new Integer(5), new Double(75)));

    exporter.addBeanRows(beans);/*from ww  w  .j  a  va 2 s  .  co  m*/
}

From source file:net.sf.jasperreports.charts.base.JRBasePie3DPlot.java

/**
 * @deprecated Replaced by {@link #setDepthFactor(Double)}
 *///ww w .  j  av a2 s  .c  o m
public void setDepthFactor(double depthFactor) {
    setDepthFactor(new Double(depthFactor));
}

From source file:com.tesora.dve.common.TestDataGenerator.java

protected Object getColumnValue(ColumnMetadata cm) {
    Object cv = null;/* ww w.j av  a 2s .  co m*/
    Calendar cal = Calendar.getInstance();

    switch (cm.getDataType()) {
    case Types.BIT:
    case Types.BOOLEAN:
        cv = Boolean.TRUE;
        break;
    case Types.BIGINT:
        cv = Long.MAX_VALUE;
        break;
    case Types.CHAR:
    case Types.VARCHAR:
        cv = StringUtils.left(baseString, cm.getSize());
        break;
    case Types.SMALLINT:
        cv = Short.MAX_VALUE;
        break;
    case Types.TINYINT:
        cv = Byte.MAX_VALUE;
        break;
    case Types.INTEGER:
        cv = Integer.MAX_VALUE;
        break;
    case Types.DOUBLE:
        cv = new Double(1234.5678); // TODO need to handle s,p
        break;
    case Types.FLOAT:
        cv = new Float(123.56); // TODO need to handle s,p
        break;
    case Types.DECIMAL:
        cv = new BigDecimal("12345.6789"); // TODO need to handle s,p
        break;
    case Types.DATE:
        cal.setTimeInMillis(123456789);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        cv = cal.getTime();
        break;
    case Types.TIMESTAMP:
        cal.setTimeInMillis(123456789);
        cv = cal.getTime();
        break;
    case Types.TIME:
        cv = new Time(123456789);
        break;
    default:
        break;
    }

    return cv;
}

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

/**
 * Returns the x-value for the specified series and item.  Series are numbered 0, 1, ...
 *
 * @param series  the index (zero-based) of the series.
 * @param item  the index (zero-based) of the required item.
 *
 * @return the x-value for the specified series and item.
 *//*ww w  . java  2s  . co m*/
public double getXValue(final int series, final int item) {
    return new Double(-10.0 + this.translate + (item / 10.0)).doubleValue();
}

From source file:com.aurel.track.fieldType.fieldChange.apply.DoubleFieldChangeApply.java

/**
 * Sets the workItemBean's attribute/* w  w w . ja v a  2  s.c  o  m*/
 * @param workItemContext
 * @param workItemBean
 * @param fieldID
 * @param parameterCode
 * @param value   
 * @return ErrorData if an error is found
 */
@Override
public List<ErrorData> setWorkItemAttribute(WorkItemContext workItemContext, TWorkItemBean workItemBean,
        Integer parameterCode, Object value) {
    if (getSetter() == FieldChangeSetters.SET_NULL || getSetter() == FieldChangeSetters.SET_REQUIRED) {
        return super.setWorkItemAttribute(workItemContext, workItemBean, parameterCode, value);
    }
    Double doubleValue = null;
    try {
        doubleValue = (Double) value;
    } catch (Exception e) {
        LOGGER.warn("Getting the double value for " + value + " failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    switch (getSetter()) {
    case FieldChangeSetters.SET_TO:
        workItemBean.setAttribute(activityType, parameterCode, doubleValue);
        break;
    case FieldChangeSetters.ADD_IF_SET:
        if (doubleValue != null) {
            Double originalValue = (Double) workItemBean.getAttribute(activityType, parameterCode);
            if (originalValue != null) {
                double newValue = originalValue.doubleValue() + doubleValue.doubleValue();
                workItemBean.setAttribute(activityType, parameterCode, Double.valueOf(newValue));
            }
        }
        break;
    case FieldChangeSetters.ADD_OR_SET:
        if (doubleValue != null) {
            Double originalValue = (Double) workItemBean.getAttribute(activityType, parameterCode);
            if (originalValue != null) {
                double newValue = originalValue.doubleValue() + doubleValue.doubleValue();
                workItemBean.setAttribute(activityType, parameterCode, new Double(newValue));
            } else {
                workItemBean.setAttribute(activityType, parameterCode, doubleValue);
            }
        }
        break;
    }
    return null;
}