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:MyComparator.java

public static void main(String[] args) {
    TreeMap tm = new TreeMap();
    tm.put(1, new Double(344.34));
    tm.put(0, new Double(123.22));
    tm.put(4, new Double(138.00));
    tm.put(2, new Double(919.22));
    tm.put(3, new Double(-119.08));

    List<Map.Entry> valueList = new ArrayList(tm.entrySet());
    Collections.sort(valueList, new MyComparator());

    Iterator<Map.Entry> iterator = valueList.iterator();
    while (iterator.hasNext()) {
        Map.Entry entry = iterator.next();
        System.out.println("Value: " + entry.getValue());
    }/*from   ww  w.j  a  v a  2 s.  c  o  m*/
}

From source file:chart.PieChart3D.java

public static void main(String[] args) throws Exception {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("IPhone 5s", new Double(20));
    dataset.setValue("SamSung Grand", new Double(20));
    dataset.setValue("MotoG", new Double(40));
    dataset.setValue("Nokia Lumia", new Double(10));

    JFreeChart chart = ChartFactory.createPieChart3D("Mobile Sales", // chart title                   
            dataset, // data 
            true, // include legend                   
            true, false);/*from ww w.j  a  va  2 s  .  com*/

    final PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(270);
    plot.setForegroundAlpha(0.60f);
    plot.setInteriorGap(0.02);
    int width = 640; /* Width of the image */
    int height = 480; /* Height of the image */
    File pieChart3D = new File("pie_Chart3D.jpeg");
    ChartUtilities.saveChartAsJPEG(pieChart3D, chart, width, height);
}

From source file:statistique.PieChart3D.java

public static void main(String[] args) throws Exception {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("IPhone 5s", new Double(20));
    dataset.setValue("SamSung Grand", new Double(20));
    dataset.setValue("MotoG", new Double(40));
    dataset.setValue("Nokia Lumia", new Double(10));

    JFreeChart chart = ChartFactory.createPieChart3D("Mobile Sales", // chart title                   
            dataset, // data 
            true, // include legend                   
            true, false);// www. j ava  2 s  . c  o  m

    final PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(270);
    plot.setForegroundAlpha(0.60f);
    plot.setInteriorGap(0.02);
    int width = 640; /* Width of the image */
    int height = 480; /* Height of the image */
    File pieChart3D = new File("pie_Chart3D.png");
    ChartUtilities.saveChartAsPNG(pieChart3D, chart, width, height);
}

From source file:urbanchart.java

public static void main(String[] arg) {
    final DefaultPieDataset data = new DefaultPieDataset();
    data.setValue("Housing(35%)($1050)", new Double(35));
    data.setValue("Debt(15%)($450)", new Double(15));
    data.setValue("transportation(15%)($450)", new Double(15));
    data.setValue("Food(15%)($450)", new Double(25));
    data.setValue("Saving(10%)($300)", new Double(10));
    JFreeChart chart = ChartFactory.createPieChart(
            "Average Distribution of expenses on income assuming 3000$/month (Urban areas)", data, true, true,
            false);/*from w  w w. j av  a 2s  . c  o m*/
    final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
    final File file1 = new File("E:\\java projects\\hackathon1\\web\\piecharturban.jpg");
    try {
        ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
    } catch (IOException ex) {
        Logger.getLogger(urbanchart.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Boolean refBoolean = new Boolean(true);
    boolean bool = refBoolean.booleanValue();

    Byte refByte = new Byte((byte) 123);
    byte b = refByte.byteValue();

    Character refChar = new Character('x');
    char c = refChar.charValue();

    Short refShort = new Short((short) 123);
    short s = refShort.shortValue();

    Integer refInt = new Integer(123);
    int i = refInt.intValue();

    Long refLong = new Long(123L);
    long l = refLong.longValue();

    Float refFloat = new Float(12.3F);
    float f = refFloat.floatValue();

    Double refDouble = new Double(12.3D);
    double d = refDouble.doubleValue();
}

From source file:TComp.java

public static void main(String args[]) {
    TreeMap<String, Double> tm = new TreeMap<String, Double>(new TComp());

    tm.put("J D", new Double(3434.34));
    tm.put("T S", new Double(123.22));
    tm.put("J B", new Double(1378.00));
    tm.put("T H", new Double(99.22));
    tm.put("R S", new Double(-19.08));

    Set<Map.Entry<String, Double>> set = tm.entrySet();

    for (Map.Entry<String, Double> me : set) {
        System.out.print(me.getKey() + ": ");
        System.out.println(me.getValue());
    }//from   www.  j a v a 2  s.co  m
    System.out.println();

    double balance = tm.get("A");
    tm.put("A", balance + 1000);

    System.out.println("A's new balance: " + tm.get("A"));
}

From source file:ruralchart.java

public static void main(String[] arg) {
    final DefaultPieDataset data = new DefaultPieDataset();
    data.setValue("Housing(35%)($350)", new Double(35));
    data.setValue("Debt(15%)($150)", new Double(15));
    data.setValue("transportation(15%)($150)", new Double(15));
    data.setValue("Food(15%)($250)", new Double(25));
    data.setValue("Saving(10%)($100)", new Double(10));
    JFreeChart chart = ChartFactory.createPieChart(
            "Average Distribution of expenses on income assuming 1000$/month (Rural areas)", data, true, true,
            false);/*from w ww .j a va 2 s . co m*/
    final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
    final File file1 = new File("E:\\java projects\\hackathon1\\web\\piechartrural.jpg");
    try {
        ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
    } catch (IOException ex) {
        Logger.getLogger(urbanchart.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:json.example.JSONExample.java

/**
 * @param args the command line arguments
 * @throws org.json.JSONException/*from w ww. j  av a 2s  .c  o  m*/
 */
public static void main(String[] args) throws JSONException {
    // Require throws JSONException

    // Encode JSONObject subclass HashMap
    JSONObject person = new JSONObject();

    //Fill HashMap with Objects
    person.put("name", "Cassandra");
    person.put("age", new Integer(26));
    person.put("height", new Double(61.25));
    person.put("married", true);

    System.out.print(person);
}

From source file:Gen.java

public static void main(String args[]) {

    // Create a Gen object for Integers. 
    Gen<Integer> iOb = new Gen<Integer>(88);

    // Create a Gen object for Strings. 
    Gen<String> strOb = new Gen<String>("Generics Test");

    // Create a raw-type Gen object and give it 
    // a Double value. 
    Gen raw = new Gen(new Double(98.6));

    // Cast here is necessary because type is unknown. 
    double d = (Double) raw.getob();
    System.out.println("value: " + d);

    // The use of a raw type can lead to runtime. 
    // exceptions.  Here are some examples. 

    // The following cast causes a runtime error! 
    //    int i = (Integer) raw.getob(); // runtime error 

    // This assigment overrides type safety. 
    strOb = raw; // OK, but potentially wrong 
    //    String str = strOb.getob(); // runtime error  

    // This assignment also overrides type safety. 
    raw = iOb; // OK, but potentially wrong 
    //    d = (Double) raw.getob(); // runtime error 
}

From source file:Main.java

public static void main(String[] argv) {
    DefaultTableModel model = new DefaultTableModel() {
        public Class getColumnClass(int columnIndex) {
            Object o = getValueAt(0, columnIndex);
            if (o == null) {
                return Object.class;
            } else {
                return o.getClass();
            }/*  w ww .  j av a 2  s. c om*/
        }
    };
    JTable table = new JTable(model);

    model.addColumn("Boolean", new Object[] { Boolean.TRUE });
    model.addColumn("Date", new Object[] { new Date() });
    model.addColumn("Double", new Object[] { new Double(Math.PI) });
    model.addColumn("Float", new Object[] { new Float(1.2) });
    model.addColumn("Icon", new Object[] { new ImageIcon("icon.gif") });
    model.addColumn("Number", new Object[] { new Integer(1) });
    model.addColumn("Object", new Object[] { "object" });

    JFrame f = new JFrame();
    f.setSize(300, 300);
    f.add(new JScrollPane(table));
    f.setVisible(true);
}