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:com.amazonaws.mturk.cmd.ResetAccount.java

private String[] getHits() {
    HIT[] hits = null;/*from   ww  w.j  a  va2s  .  co m*/
    List<String> ret = new ArrayList<String>();
    SearchHITsResult result = null;
    String[] responseGroup = new String[] { "Minimal", "HITDetail" };
    int pageSize = 50;

    totalNumberOfHits = service.getTotalNumHITsInAccount();

    double numPagesDouble = Math.ceil(new Double(totalNumberOfHits) / new Double(pageSize));
    int numPages = (new Double(numPagesDouble)).intValue();

    for (int i = 1; i <= numPages; i = i + 1) {
        result = service.searchHITs(SortDirection.Ascending, SearchHITsSortProperty.Enumeration, i, pageSize,
                responseGroup);

        hits = result.getHIT();
        if (hits != null) {
            for (HIT h : hits) {
                if (!h.getHITStatus().equals(HITStatus.Unassignable)) {
                    ret.add(h.getHITId());
                } else {
                    unassignableCount++;
                }
            }
        }
    }

    return (String[]) ret.toArray(new String[] {});
}

From source file:org.jfree.data.xy.XYIntervalDataItemTest.java

/**
 * Some checks for the constructor./*from   w  w  w. j  ava  2 s .c om*/
 */
@Test
public void testConstructor1() {
    XYIntervalDataItem item1 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, 1.9, 2.1);
    assertEquals(new Double(1.0), item1.getX());
    assertEquals(0.5, item1.getXLowValue(), EPSILON);
    assertEquals(1.5, item1.getXHighValue(), EPSILON);
    assertEquals(2.0, item1.getYValue(), EPSILON);
    assertEquals(1.9, item1.getYLowValue(), EPSILON);
    assertEquals(2.1, item1.getYHighValue(), EPSILON);
}

From source file:NumberUtils.java

/**
 * Convert the given number into an instance of the given target class.
 * @param number the number to convert//from  w ww  .j a va  2  s  . c o m
 * @param targetClass the target class to convert to
 * @return the converted number
 * @throws IllegalArgumentException if the target class is not supported
 * (i.e. not a standard Number subclass as included in the JDK)
 * @see java.lang.Byte
 * @see java.lang.Short
 * @see java.lang.Integer
 * @see java.lang.Long
 * @see java.math.BigInteger
 * @see java.lang.Float
 * @see java.lang.Double
 * @see java.math.BigDecimal
 */
public static Number convertNumberToTargetClass(Number number, Class targetClass)
        throws IllegalArgumentException {

    if (targetClass.isInstance(number)) {
        return number;
    } else if (targetClass.equals(Byte.class)) {
        long value = number.longValue();
        if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return new Byte(number.byteValue());
    } else if (targetClass.equals(Short.class)) {
        long value = number.longValue();
        if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return new Short(number.shortValue());
    } else if (targetClass.equals(Integer.class)) {
        long value = number.longValue();
        if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return new Integer(number.intValue());
    } else if (targetClass.equals(Long.class)) {
        return new Long(number.longValue());
    } else if (targetClass.equals(Float.class)) {
        return new Float(number.floatValue());
    } else if (targetClass.equals(Double.class)) {
        return new Double(number.doubleValue());
    } else if (targetClass.equals(BigInteger.class)) {
        return BigInteger.valueOf(number.longValue());
    } else if (targetClass.equals(BigDecimal.class)) {
        // using BigDecimal(String) here, to avoid unpredictability of BigDecimal(double)
        // (see BigDecimal javadoc for details)
        return new BigDecimal(number.toString());
    } else {
        throw new IllegalArgumentException("Could not convert number [" + number + "] of type ["
                + number.getClass().getName() + "] to unknown target class [" + targetClass.getName() + "]");
    }
}

From source file:com.aw.core.format.NumeroEnTextoFormatter.java

/**
*Devuelve en letras un monto determinado.
*@param valor: Objeto Double que ser mostrada en letras.
*@return String: Monto en Letras.//from w  ww  . j  a v  a  2s.co m
*/
private static String valorEnLetras(Double valor) {

    String centavos = "00";
    double doubleValor = valor;
    int numero = valor.intValue();
    int posPunto = String.valueOf(valor).indexOf(".");
    int posComa = String.valueOf(valor).indexOf(",");
    double doubleNumero = Double.parseDouble(String.valueOf(numero));
    if (posPunto > 0 || posComa > 0) {
        if (posPunto > 0)
            centavos = String.valueOf(valor).substring(posPunto + 1);
        if (posComa > 0)
            centavos = String.valueOf(valor).substring(posComa + 1);
    } else
        centavos = "00";

    String cadena = "";
    int millon;
    int cienMil;

    if (numero < 1000000000) {

        if (numero > 999999) {
            millon = (new Double(numero / 1000000)).intValue();
            numero = numero - millon * 1000000;
            cadena += base(millon, true) + (millon > 1 ? " MILLONES " : " MILLON ");
        }
        if (numero > 999) {
            cienMil = (new Double(numero / 1000)).intValue();
            numero = numero - cienMil * 1000;
            cadena += base(cienMil, false) + " MIL ";
        }

        cadena += base(numero, true);

        if (cadena != null && cadena.trim().length() > 0) {
            cadena += " CON ";
        }

        if (centavos.trim().length() == 1)
            centavos += "0";
        cadena += String.valueOf(centavos) + "/100";

    }

    return cadena.trim();
    //return  cadena.trim()+" Nuevos Soles";
}

From source file:com.hazelcast.monitor.server.MChartGenerator.java

@Override
protected void afterPlot(List<? super InstanceStatistics> list, JFreeChart chart, XYPlot plot) {
    NumberAxis sizeAxis = (NumberAxis) plot.getRangeAxis(0);
    Font labelFont = sizeAxis.getLabelFont();
    Paint labelPaint = sizeAxis.getLabelPaint();
    TimeSeries tm = new TimeSeries("memory");
    for (int i = 0; i < list.size(); i++) {
        double memory = 0;
        MapStatistics mapStatistics = (MapStatistics) list.get(i);
        for (MapStatistics.LocalMapStatistics localMapStatistics : mapStatistics.getListOfLocalStats()) {
            memory = memory + localMapStatistics.ownedEntryMemoryCost + localMapStatistics.backupEntryMemoryCost
                    + localMapStatistics.markedAsRemovedMemoryCost;
        }/*  www  .  java 2 s.  co m*/
        double mem = new Double(memory / (double) (1024 * 1024));
        tm.addOrUpdate(new Second(((MapStatistics) list.get(i)).getCreatedDate()), mem);
    }
    NumberAxis memoryAxis = new NumberAxis("memory (MB)");
    memoryAxis.setAutoRange(true);
    memoryAxis.setAutoRangeIncludesZero(false);
    plot.setDataset(1, new TimeSeriesCollection(tm));
    plot.setRangeAxis(1, memoryAxis);
    plot.mapDatasetToRangeAxis(1, 1);
    plot.setRenderer(1, new StandardXYItemRenderer());
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    increaseRange(memoryAxis);
    memoryAxis.setLabelFont(labelFont);
    memoryAxis.setLabelPaint(labelPaint);
}

From source file:JobBase.java

/**
 * Set the given counter to the given value
 * //w  w w  .java2  s .  c om
 * @param name
 *          the counter name
 * @param value
 *          the value for the counter
 */
protected void setDoubleValue(Object name, double value) {
    this.doubleCounters.put(name, new Double(value));
}

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

/**
 * Creates a new demo application.//  w  w  w  . j  av a 2 s.  c o  m
 *
 * @param title  the frame title.
 */
public CompassDemo2(final String title) {

    super(title);

    final ValueDataset dataset = new DefaultValueDataset(new Double(45.0));
    final JFreeChart chart = createChart(dataset);

    // add the chart to a panel...
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setEnforceFileExtensions(false);
    setContentPane(chartPanel);

}

From source file:io.s4.comm.util.JSONUtil.java

public static Object fixValue(Object originalValue) {
    Object value = null;//from w w  w.  j  a  va 2s .  c o  m
    if (originalValue instanceof Float) {
        value = new Double((Float) originalValue);
    } else if (originalValue instanceof Integer) {
        value = new Long((Integer) originalValue);
    } else if (originalValue instanceof JSONArray) {
        value = getRawList((JSONArray) originalValue);
    } else if (originalValue instanceof JSONObject) {
        value = getRawRecord((JSONObject) originalValue);
    } else {
        value = originalValue;
    }
    return value;
}

From source file:org.catrobat.catroid.HomeController.java

private Map<String, String> createrHeaderMap(XmlHeader header) {
    Map<String, String> headerMap = new TreeMap<String, String>();
    headerMap.put("programName", header.getProgramName());
    headerMap.put("description", header.getDescription());

    headerMap.put("screenWidth", (new Integer(header.getVirtualScreenWidth())).toString());
    headerMap.put("screenHeight", (new Integer(header.getVirtualScreenHeight())).toString());

    headerMap.put("catrobatLanguageVersion", (new Double(header.getCatrobatLanguageVersion())).toString());

    headerMap.put("applicationBuildName", header.getApplicationBuildName());
    headerMap.put("applicationBuildNumber", (new Integer(header.getApplicationBuildNumber())).toString());
    headerMap.put("applicationName", header.getApplicationName());
    headerMap.put("applicationVersion", header.getApplicationVersion());
    headerMap.put("dateTimeUpload", header.getDateTimeUpload());
    headerMap.put("deviceName", header.getDeviceName());
    headerMap.put("mediaLicense", header.getMediaLicense());
    headerMap.put("platform", header.getPlatform());
    headerMap.put("platformVersion", (new Integer(header.getPlatformVersion())).toString());
    headerMap.put("programLicense", header.getProgramLicense());
    headerMap.put("remixOf", header.getRemixOf());
    headerMap.put("tags", header.getTags());
    headerMap.put("url", header.getUrl());
    headerMap.put("userHandle", header.getUserHandle());

    List<String> emptyValues = new ArrayList<String>();
    for (String item : headerMap.keySet())
        if (headerMap.get(item) == null || headerMap.get(item) == "") {
            emptyValues.add(item);//from  w  w  w  .j  a  v a 2  s.  c o m
        }
    for (String item : emptyValues)
        headerMap.remove(item);

    return headerMap;
}

From source file:com.siblinks.ws.common.BaseException.java

/**
 * @param aThrowable/* w  w w  .j a va 2  s.  c o m*/
 * @param aUserMessage
 * @param level
 */
public BaseException(final Throwable aThrowable, final String aUserMessageKey,
        final Serializable[] aValueReplacementArray, final ErrorLevel level) {
    this.throwable = aThrowable;
    this.userMessageKey = aUserMessageKey;
    this.valueReplacementArray = aValueReplacementArray;
    this.errorLevel = level;
    this.uniqueID = new Double(Math.random()).toString();
}