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:thesisdata.PieChartDemo1.java

/**
 * Creates a sample dataset.// w w  w  .j av a  2  s.c o  m
 * 
 * @return A sample dataset.
 */
private static PieDataset createDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    try (BufferedReader br = new BufferedReader(new FileReader("summery.txt"))) {
        String line;

        while ((line = br.readLine()) != null) {
            String st[];
            st = line.split(" ");

            dataset.setValue(st[0], new Double(st[1]));

        }
    } catch (Exception ex) {
        // return dataset;
    }
    return dataset;
}

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

public static JPanel createDemoPanel() {
    JFreeChart jfreechart = createChart(new DefaultValueDataset(new Double(45D)));
    return new ChartPanel(jfreechart);
}

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

public CompassDemo1(String s) {
    super(s);/*from  ww w  .  j  a va 2  s . c  o m*/
    DefaultValueDataset defaultvaluedataset = new DefaultValueDataset(new Double(45D));
    JFreeChart jfreechart = createChart(defaultvaluedataset);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setPreferredSize(new Dimension(500, 270));
    chartpanel.setEnforceFileExtensions(false);
    setContentPane(chartpanel);
}

From source file:gov.nih.nci.caintegrator.application.zip.FileNameGenerator.java

public static String generateFileNameFromEmail(String userEmail) throws ValidationException {
    String fileName = null;//  w w  w.j  av a 2s  . c  o  m
    if (userEmail != null && EmailValidator.getInstance().isValid(userEmail)) {
        // Get a random number of up to 7 digits      
        int sevenDigitRandom = new Double(Math.random() * 10000000).intValue();

        // Get the last 7 digits of the Java timestamp
        String s = String.valueOf(System.currentTimeMillis());
        String lastSevenOfTimeStamp = s.substring(s.length() - 7, s.length());

        // Get the string before the @ sign in the user's email address
        String userEmailBeforeAtSign = userEmail.substring(0, userEmail.indexOf('@'));

        // Put it all together
        fileName = userEmailBeforeAtSign + "_" + sevenDigitRandom + lastSevenOfTimeStamp;
    } else {
        throw new ValidationException("Invalid Email Address");
    }
    return fileName;
}

From source file:Main.java

/**
 * convert str to a double. Return defaultValue number if empty. 
 * /*from  w w w.  ja va 2 s  . c  o  m*/
 * @param str input string
 * @return the number
 */
public static double getDouble(String str, double defaultValue) {
    try {
        return new Double(str.trim()).doubleValue();
    } catch (Exception e) {
        return defaultValue;
    }
}

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

public MouseListenerDemo1(String s) {
    super(s);/*  w  w w.j a va2  s . c  o m*/
    DefaultPieDataset defaultpiedataset = new DefaultPieDataset();
    defaultpiedataset.setValue("Java", new Double(43.200000000000003D));
    defaultpiedataset.setValue("Visual Basic", new Double(0.0D));
    defaultpiedataset.setValue("C/C++", new Double(17.5D));
    org.jfree.chart.JFreeChart jfreechart = ChartFactory.createPieChart("Pie Chart Demo 1", defaultpiedataset,
            true, true, false);
    ChartPanel chartpanel = new ChartPanel(jfreechart, false, false, false, false, false);
    chartpanel.addChartMouseListener(this);
    chartpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(chartpanel);
}

From source file:sr.ifes.edu.br.bd2.util.datafactory.CategoriaData.java

public Categoria criarCategoria(DataFactory df) {
    Categoria categoria = new Categoria();

    categoria.setDescricao(df.getItem(getCategorias()));
    categoria.setPreco(new Double(df.getNumberBetween(1, 50)));

    return categoria;
}

From source file:Main.java

public static double getJavaVersion() {
    if (javaVersion == null) {
        try {//from   w w  w  .j  a va2 s .  com
            String ver = System.getProperties().getProperty("java.version");
            String version = "";
            boolean firstPoint = true;
            for (int i = 0; i < ver.length(); i++) {
                if (ver.charAt(i) == '.') {
                    if (firstPoint) {
                        version += ver.charAt(i);
                    }
                    firstPoint = false;
                } else if (Character.isDigit(ver.charAt(i))) {
                    version += ver.charAt(i);
                }
            }
            javaVersion = new Double(version);
        } catch (Exception ex) {
            javaVersion = 1.3;
        }
    }
    return javaVersion;
}

From source file:sr.ifes.edu.br.bd2.util.datafactory.FilmeData.java

public Filme build(DataFactory df) {

    Filme filme = new Filme();
    filme.setNome("Filme " + df.getRandomWord());
    filme.setPreco(new Double(df.getNumberBetween(2, 70)));
    filme.setCategoria(categoriaData.criarCategoria(df));
    filme.setDataCompra(df.getDateBetween(df.getDate(1960, 1, 1), new Date()));
    return filme;
}

From source file:Main.java

/** Transforms a two-dimensional array of primitives
 * to an array of Numbers.//from w  w w  . ja v  a  2s  . com
 */
public static Number[][] transformArray(double[][] data) {
    Number[][] n = new Number[data.length][data[0].length];

    for (int i = 0; i < data.length; i++)
        for (int j = 0; j < data[0].length; j++)
            n[i][j] = new Double(data[i][j]);

    return n;
}