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.pureinfo.srm.view.function.GetNationTeam.java

public Object perform(Object[] _s_args, IDVContext _s_context) throws PureException {
    PingGuParameterVO vo = (PingGuParameterVO) LocalContextHelper
            .getAttribute(PingGuConstants.ATTRIBUTE_NAME_OF_PARAMETER);
    if (vo == null) {
        return "";
    }/* w  w w  .  j  av  a  2 s . c  om*/
    IObjects objs = null;
    IStatement query = null;
    Organization org = (Organization) _s_context.getObject();
    double totalScale = 0;

    try {
        objs = TeamPingGuHelper.getObjs(org.getCode(), vo.getStartDate(), vo.getEndDate());
        Team team = null;
        while ((team = (Team) objs.next()) != null) {

            String teamHonor = team.getTeamHonor();
            if (StringUtils.isNotEmpty(teamHonor) && teamHonor.indexOf("01") != -1) {// 3
                List deptList = team.getDeptList();
                for (Iterator iterator = deptList.iterator(); iterator.hasNext();) {
                    ObjDeptMapping deptMapping = (ObjDeptMapping) iterator.next();
                    if (deptMapping.getDeptId() == org.getId()) {
                        totalScale += deptMapping.getWeightScale();
                        break;
                    }
                }
            } else {
                continue;
            }
        }

        return new Double(SCORE * totalScale);
    } finally {
        if (objs != null)
            objs.clear();
        if (query != null)
            query.clear();
    }
}

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

/**
 * Creates a new dataset.//from  ww  w. j  a  v  a  2s  .com
 */
public SimpleIntervalXYDataset() {

    this.xStart[0] = new Double(0.0);
    this.xStart[1] = new Double(2.0);
    this.xStart[2] = new Double(3.5);

    this.xEnd[0] = new Double(2.0);
    this.xEnd[1] = new Double(3.5);
    this.xEnd[2] = new Double(4.0);

    this.yValues[0] = new Double(3.0);
    this.yValues[1] = new Double(4.5);
    this.yValues[2] = new Double(2.5);
}

From source file:agilejson.JSON.java

/**
 * This method takes in a primitive that has been converted to an object
 * and creates a copy of it so that .equals results in different objects.
 * @param v/* w w w .  ja v a 2s. c  o m*/
 * @throws java.lang.Exception
 */
private static Object getObjectForPrimitive(Object v) throws Exception {
    Class c = v.getClass();
    if (c == Byte.class) {
        return new String(new byte[] { ((Byte) v).byteValue() });
    } else if (c == Boolean.class) {
        return new Boolean((Boolean) v);
    } else if (c == Character.class) {
        return new Character((Character) v);
    } else if (c == Short.class) {
        return new Short((Short) v);
    } else if (c == Integer.class) {
        return new Integer((Integer) v);
    } else if (c == Long.class) {
        return new Long((Long) v);
    } else if (c == Float.class) {
        return new Float((Float) v);
    } else if (c == Double.class) {
        return new Double((Double) v);
    } else {
        throw new Exception("Unknown Primitive");
    }
}

From source file:Main.java

/**
 * Casts an object to the specified type
 *
 * @param var/*from   w ww .  j  a  v  a  2s .c o  m*/
 * @param type
 *
 */
static Object convert(Object var, Class type) {
    if (var instanceof Number) { //use number conversion

        Number newNum = (Number) var;

        if (type == Integer.class) {
            return new Integer(newNum.intValue());
        } else if (type == Long.class) {
            return new Long(newNum.longValue());
        } else if (type == Float.class) {
            return new Float(newNum.floatValue());
        } else if (type == Double.class) {
            return new Double(newNum.doubleValue());
        } else if (type == String.class) {
            return new String(newNum.toString());
        }
    } else { //direct cast

        if (type == Integer.class) {
            return new Integer(((Integer) var).intValue());
        } else if (type == Long.class) {
            return new Long(((Long) var).longValue());
        } else if (type == Float.class) {
            return new Float(((Float) var).floatValue());
        } else if (type == Double.class) {
            return new Double(((Double) var).doubleValue());
        } else if (type == String.class) {
            return new String(var.toString());
        }
    }

    return null;
}

From source file:com.facebook.android.Places.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mHandler = new Handler();
    location = new JSONObject();

    setContentView(R.layout.places_list);

    Bundle extras = getIntent().getExtras();
    String default_or_new = extras.getString("LOCATION");
    if (default_or_new.equals("times_square")) {
        try {/*from w w w  . jav a2 s . c  om*/
            location.put("latitude", new Double(TIMES_SQUARE_LAT));
            location.put("longitude", new Double(TIMES_SQUARE_LON));
        } catch (JSONException e) {
        }
        fetchPlaces();
    } else {
        getLocation();
    }
}

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

/**
 * Some checks for the getValue() method.
 *//* w  ww  . jav a  2  s . com*/
@Test
public void testGetValue() {
    DefaultMultiValueCategoryDataset d = new DefaultMultiValueCategoryDataset();
    List values = new ArrayList();
    values.add(new Integer(1));
    values.add(new Integer(2));
    d.add(values, "R1", "C1");
    assertEquals(new Double(1.5), 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:FormatterFactoryDemo.java

public FormatterFactoryDemo() {
    super(new BorderLayout());
    setUpFormats();//  w  w  w .ja  v  a 2s.co  m
    double payment = computePayment(amount, rate, numPeriods);

    // Create the labels.
    amountLabel = new JLabel(amountString);
    rateLabel = new JLabel(rateString);
    numPeriodsLabel = new JLabel(numPeriodsString);
    paymentLabel = new JLabel(paymentString);

    // Create the text fields and set them up.
    amountField = new JFormattedTextField(new DefaultFormatterFactory(new NumberFormatter(amountDisplayFormat),
            new NumberFormatter(amountDisplayFormat), new NumberFormatter(amountEditFormat)));
    amountField.setValue(new Double(amount));
    amountField.setColumns(10);
    amountField.addPropertyChangeListener("value", this);

    NumberFormatter percentEditFormatter = new NumberFormatter(percentEditFormat) {
        public String valueToString(Object o) throws ParseException {
            Number number = (Number) o;
            if (number != null) {
                double d = number.doubleValue() * 100.0;
                number = new Double(d);
            }
            return super.valueToString(number);
        }

        public Object stringToValue(String s) throws ParseException {
            Number number = (Number) super.stringToValue(s);
            if (number != null) {
                double d = number.doubleValue() / 100.0;
                number = new Double(d);
            }
            return number;
        }
    };
    rateField = new JFormattedTextField(new DefaultFormatterFactory(new NumberFormatter(percentDisplayFormat),
            new NumberFormatter(percentDisplayFormat), percentEditFormatter));
    rateField.setValue(new Double(rate));
    rateField.setColumns(10);
    rateField.addPropertyChangeListener("value", this);

    numPeriodsField = new JFormattedTextField();
    numPeriodsField.setValue(new Integer(numPeriods));
    numPeriodsField.setColumns(10);
    numPeriodsField.addPropertyChangeListener("value", this);

    paymentField = new JFormattedTextField(paymentFormat);
    paymentField.setValue(new Double(payment));
    paymentField.setColumns(10);
    paymentField.setEditable(false);
    paymentField.setForeground(Color.red);

    // Tell accessibility tools about label/textfield pairs.
    amountLabel.setLabelFor(amountField);
    rateLabel.setLabelFor(rateField);
    numPeriodsLabel.setLabelFor(numPeriodsField);
    paymentLabel.setLabelFor(paymentField);

    // Lay out the labels in a panel.
    JPanel labelPane = new JPanel(new GridLayout(0, 1));
    labelPane.add(amountLabel);
    labelPane.add(rateLabel);
    labelPane.add(numPeriodsLabel);
    labelPane.add(paymentLabel);

    // Layout the text fields in a panel.
    JPanel fieldPane = new JPanel(new GridLayout(0, 1));
    fieldPane.add(amountField);
    fieldPane.add(rateField);
    fieldPane.add(numPeriodsField);
    fieldPane.add(paymentField);

    // Put the panels in this panel, labels on left,
    // text fields on right.
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    add(labelPane, BorderLayout.CENTER);
    add(fieldPane, BorderLayout.LINE_END);
}

From source file:org.mt4jx.components.visibleComponents.widgets.jfreechart.examples.MTJFreeChartExampleScene.java

public MTJFreeChartExampleScene(MTApplication mtApplication, String name) {
    super(mtApplication, name);
    this.setClearColor(new MTColor(0, 0, 96, 255));
    //Show touches
    this.registerGlobalInputProcessor(new CursorTracer(mtApplication, this));

    // Create Example Data
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int i = 0; i < 10; i++) {
        dataset.addValue(10 * Math.random(), "MySeries", "T" + i);
    }/*  ww w.  jav  a 2 s.  c o  m*/
    // Create a JFreeChart
    JFreeChart chart1 = ChartFactory.createLineChart("Line Chart", "x axis", "y axis", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    // Put the JFreeChart into a MTJFreeChart wrapper
    MTJFreeChart mtChart1 = new MTJFreeChart(800, 600, mtApplication, chart1);

    // Create another chart
    DefaultPieDataset pds = new DefaultPieDataset();

    pds.setValue("Java", new Double(17.773));
    pds.setValue("C", new Double(15.822));
    pds.setValue("C++", new Double(8.783));
    pds.setValue("PHP", new Double(7.835));
    pds.setValue("Python", new Double(6.265));
    pds.setValue("C#", new Double(6.226));
    pds.setValue("(Visual) Basic", new Double(5.867));
    pds.setValue("Objective-C", new Double(3.011));
    pds.setValue("Perl", new Double(2.857));

    JFreeChart chart2 = ChartFactory.createPieChart3D(
            "Top 10: TIOBE Programming Community Index\nfor January 2011 (www.tiobe.com)", pds, true, true,
            Locale.GERMANY);
    PiePlot3D plot = (PiePlot3D) chart2.getPlot();
    plot.setStartAngle(290);

    MTJFreeChart mtChart2 = new MTJFreeChart(800, 600, mtApplication, chart2);
    // enable redraw of the chart when it's scaled by the user
    mtChart2.setRedrawWhenScaled(true);
    this.getCanvas().addChild(mtChart1);
    this.getCanvas().addChild(mtChart2);
    mtChart1.setPositionGlobal(new Vector3D(mtApplication.width / 2f, mtApplication.height / 2f));
    mtChart2.setPositionGlobal(new Vector3D(150 + mtApplication.width / 2f, 150 + mtApplication.height / 2f));
}

From source file:edu.ucla.stat.SOCR.chart.demo.RingChartDemo1.java

/**
 * Creates a sample dataset./*from ww  w . jav  a2  s .  c  o m*/
 * 
 * @return a sample dataset.
 */
protected DefaultPieDataset createDataset(boolean isDemo) {
    if (isDemo) {
        DefaultPieDataset dataset = new DefaultPieDataset();
        dataset.setValue("One", new Double(43.2));
        dataset.setValue("Two", new Double(10.0));
        dataset.setValue("Three", new Double(27.5));
        dataset.setValue("Four", new Double(17.5));
        dataset.setValue("Five", new Double(11.0));
        dataset.setValue("Six", new Double(19.4));
        pulloutFlag = new String[6];
        for (int i = 0; i < 6; i++)
            pulloutFlag[i] = "0";
        pulloutFlag[2] = "1";
        return dataset;
    } else
        return super.createDataset(isDemo);
}

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

/**
 * Serialize an instance, restore it, and check for equality.
 *///from   w w w  .j a  va  2  s .c om
public void testSerialization() {
    DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset();
    d1.setValue("C1", new Double(234.2));
    d1.setValue("C2", null);
    d1.setValue("C3", new Double(345.9));
    d1.setValue("C4", new Double(452.7));

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