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:RMOS.PieChartCash.java

/**
 * Creates a sample dataset.//ww  w  .  j av a  2s. co m
 * 
 * Source: http://www.bbc.co.uk/news/business-15489523
 *
 * @return A sample dataset.
 */
private static PieDataset createDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    ArrayList<String> s1 = new ArrayList<String>();
    s1 = f1.getStationInGroup();

    for (int i = 0; i < s1.size(); i++) {
        //System.out.println(f1.getStationInGroup().get(i));
        //System.out.println(u.getInCapacity().get(i));
        dataset.setValue(f1.getStationInGroup().get(i),
                new Double(f2.getCashDispatched(f1.getStationInGroup().get(i).toString())));

    }

    /* dataset.setValue("Samsung", new Double(27.8));
     dataset.setValue("Others", new Double(55.3));
     dataset.setValue("Nokia", new Double(16.8));
     dataset.setValue("Apple", new Double(17.1));*/
    return dataset;
}

From source file:grafici.MediciPieChart.java

/**
 * Creates a sample dataset.//  ww  w . j  ava  2s  . c  om
 * 
 * @return A sample dataset.
 */
private static PieDataset createDataset(int tipo) {
    DefaultPieDataset dataset = new DefaultPieDataset();

    // Tipologia visita
    ArrayList<Tipologiavisita> tipiVisite = VisitaDAO.getTipologVisita();

    for (Tipologiavisita tipologia : tipiVisite) {
        Double percentuale = new Double(
                MedicoDAO.getPrestazioniNmrPerTipologia(tipologia.getIdTipologiaVisita()));
        dataset.setValue(tipologia.getTipologia(), percentuale);
    }

    return dataset;
}

From source file:aplicacion.gestion.tablero.logic.PieChart3DDemo1.java

/**
 * Creates a sample dataset for the demo.
 * /*from www  .ja  v a2 s.  c o  m*/
 * @return A sample dataset.
 */
private PieDataset createSampleDataset() {

    final DefaultPieDataset result = new DefaultPieDataset();
    result.setValue("Antonio Freifer", new Double(43.2));
    result.setValue("Ariel Vazquez", new Double(10.0));
    result.setValue("Mauro Abraham", new Double(17.5));
    result.setValue("Nicolas Leiva", new Double(32.5));
    result.setValue("Martin Lucero", new Double(1.0));
    return result;

}

From source file:at.tuwien.minimee.migration.parser.TIME_Parser.java

/**
 * The line is supposed to look like that: 
 * pCpu:0%,sys:0.00,user:0.00,real:1.00,exit:0
 * @param line//from   w ww  .j  av a2 s  . c om
 */
private void parseLine(String line) {

    StringTokenizer tokenizer = new StringTokenizer(line, ",");

    while (tokenizer.hasMoreTokens()) {
        String token = tokenizer.nextToken();

        int colon = token.indexOf(':');
        if (colon == -1) {
            continue;
        }

        if ("pCpu".compareTo(token.substring(0, colon)) == 0) {

            int pSign = token.indexOf('%');
            if (pSign == -1) {
                continue;
            }

            pCpu = (new Double(token.substring(colon + 1, pSign)));
        } else if ("sys".compareTo(token.substring(0, colon)) == 0) {

            sys = (new Double(token.substring(colon + 1)));

        } else if ("user".compareTo(token.substring(0, colon)) == 0) {

            user = (new Double(token.substring(colon + 1)));

        } else if ("real".compareTo(token.substring(0, colon)) == 0) {

            real = (new Double(token.substring(colon + 1)));

        } else if ("exit".compareTo(token.substring(0, colon)) == 0) {

            exitCode = (new Integer(token.substring(colon + 1)));
        }
    }
}

From source file:net.sourceforge.fenixedu.domain.Professorship.java

public static Professorship create(Boolean responsibleFor, ExecutionCourse executionCourse, Teacher teacher,
        Double hours) throws MaxResponsibleForExceed, InvalidCategory {

    for (final Professorship otherProfessorship : executionCourse.getProfessorshipsSet()) {
        if (teacher == otherProfessorship.getTeacher()) {
            throw new DomainException("error.teacher.already.associated.to.professorship");
        }//w  ww  . ja  v a2  s . c  om
    }

    if (responsibleFor == null || executionCourse == null || teacher == null) {
        throw new NullPointerException();
    }

    Professorship professorShip = new Professorship();
    professorShip.setHours((hours == null) ? new Double(0.0) : hours);
    professorShip.setExecutionCourse(executionCourse);
    professorShip.setPerson(teacher.getPerson());
    professorShip.setCreator(AccessControl.getPerson());

    professorShip.setResponsibleFor(responsibleFor);
    executionCourse.moveSummariesFromTeacherToProfessorship(teacher, professorShip);

    return professorShip;
}

From source file:uk.org.funcube.fcdw.server.extract.csv.HighResCsvExtractor.java

@Transactional(readOnly = true, propagation = Propagation.REQUIRED)
public void extract(long satelliteId) {

    Timestamp latestSatelliteTime = highResolutionDao.getLatestSatelliteTime(satelliteId);

    Timestamp since = new Timestamp(latestSatelliteTime.getTime() - (60 * 60 * 1000));

    List<HighResolutionEntity> highResOneHour = highResolutionDao.getSinceSatelliteTime(satelliteId, since);

    if (highResOneHour.size() == 0) {
        return;/*  w  w  w .j  a va 2 s .  c  o  m*/
    }

    File fileLocation = new File(System.getProperty("csv.hires"));

    if (fileLocation.exists()) {
        fileLocation.delete();
    }

    try {
        // use FileWriter constructor that specifies open for appending
        CsvWriter csvOutput = new CsvWriter(new FileWriter(fileLocation, true), ',');

        // write out the headers
        csvOutput.write("Satellite Date/Time UTC");
        csvOutput.write("Sun Sensor +X log Lux");
        csvOutput.write("Sun Sensor +Y log Lux");
        csvOutput.write("Sun Sensor -Y log Lux");
        csvOutput.write("Sun Sensor +Z log Lux");
        csvOutput.write("Sun Sensor -Z log Lux");
        csvOutput.write("Tot. Photo Curr. mA");
        csvOutput.write("Battery mV");
        csvOutput.endRecord();

        long tsLong = 0;
        String c1 = "";
        String c2 = "";
        String c3 = "";
        String c4 = "";
        String c5 = "";
        String c6 = "";
        String c7 = "";

        for (HighResolutionEntity entity : highResOneHour) {

            Timestamp satelliteTime = entity.getSatelliteTime();

            if (tsLong == 0) {
                tsLong = satelliteTime.getTime();
                c1 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC1().intValue()]));
                c2 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC2().intValue()]));
                c3 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC3().intValue()]));
                c4 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC4().intValue()]));
                c5 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC5().intValue()]));
                c6 = String.format("%4.0f", new Double(entity.getC6() * 2.0));
                c7 = String.format("%3.0f", new Double(entity.getC7() * 2.0));

                writeRecord(csvOutput, satelliteTime, c1, c2, c3, c4, c5, c6, c7);
            } else {

                final long timeDiff = satelliteTime.getTime() - tsLong;
                if (timeDiff > 1000) {
                    // fill in the gaps
                    long gaps = (timeDiff / 1000);
                    for (long i = 1; i < gaps; i++) {
                        Timestamp intervalTime = new Timestamp(tsLong + (1000 * i));
                        writeRecord(csvOutput, intervalTime, c1, c2, c3, c4, c5, c6, c7);
                    }
                }

                c1 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC1().intValue()]));
                c2 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC2().intValue()]));
                c3 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC3().intValue()]));
                c4 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC4().intValue()]));
                c5 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC5().intValue()]));
                c6 = String.format("%4.0f", new Double(entity.getC6() * 2.0));
                c7 = String.format("%3.0f", new Double(entity.getC7() * 2.0));

                writeRecord(csvOutput, satelliteTime, c1, c2, c3, c4, c5, c6, c7);

                tsLong = satelliteTime.getTime();
            }
        }

        csvOutput.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:nz.co.senanque.directed.DirectedRulesTest.java

/**
 * Runs a scenario which tries directed questioning, then resets the values
 * and runs it again, verifying that the same questions are asked.
 * @throws Exception/*from www .j  a  v  a  2s .  c  om*/
 */
@Test
public void testDirectedQuestion1() throws Exception {
    ValidationSession validationSession = m_validationEngine.createSession();
    Customer customer = new Customer();
    validationSession.bind(customer);
    List<FieldMetadata> log1 = tryScenario(customer);
    m_rulesPlugin.clearUnknowns(customer);
    for (FieldMetadata fieldMetadata : log1) {
        dumpObject(customer);
        FieldMetadata fm = m_rulesPlugin.getEmptyField(customer.getMetadata().getFieldMetadata("bmi"));
        String currentName = (fm == null) ? "null" : fm.getName();
        log.debug("{} {}", fieldMetadata.getName(), currentName);
        // this proves we ask the same questions the second time around.
        assertEquals(fieldMetadata.getName(), currentName);
        if (fieldMetadata.getName().equals("heightInches")) {
            fieldMetadata.setValue(new Double(4));
            dumpObject(customer);
            continue;
        }
        if (fieldMetadata.getName().equals("heightMetric")) {
            m_rulesPlugin.setNotKnown(fieldMetadata);
            continue;
        }
        if (fieldMetadata.getName().equals("heightFeet")) {
            fieldMetadata.setValue(new Double(5));
            continue;
        }
        if (fieldMetadata.getName().equals("weightKilos")) {
            dumpObject(customer);
            log.debug("Just before set value");
            fieldMetadata.setValue(new Double(90D));
            log.debug("Just after set value");
            dumpObject(customer);
            log.debug("complete: field=weightKilos");
            continue;
        }

    }
    long bmi = new Double(customer.getBmi()).longValue();
    assertEquals(34L, bmi);
    validationSession.close();
}

From source file:grafici.PrenotazioniPieChart.java

/**
 * Creates a sample dataset.// ww  w  .  j ava  2  s  .c o m
 * 
 * @return A sample dataset.
 */
private static PieDataset createDataset(int tipo) {
    DefaultPieDataset dataset = new DefaultPieDataset();
    if (tipo == 1) {
        // Tipologia visita
        ArrayList<Tipologiavisita> tipiVisite = VisitaDAO.getTipologVisita();

        for (Tipologiavisita tipologia : tipiVisite) {
            Double percentuale = new Double(
                    VisitaDAO.getPrenotazioniNumberPerTipologia(tipologia.getIdTipologiaVisita()));
            dataset.setValue(tipologia.getTipologia(), percentuale);
        }
    } else {
        alertGraficoNonDisp();
    }

    return dataset;
}

From source file:de.hybris.platform.b2b.punchout.populators.impl.DefaultOrderRequestCartPopulator.java

private Double getDeliveryCost(final OrderRequestHeader source) {
    if (source.getShipping() != null) {
        return Double.valueOf(source.getShipping().getMoney().getvalue());
    }//from w  w w .  j av a 2s.  c  o  m
    return new Double(0D);
}

From source file:grafici.FatturePieChart.java

/**
 * Creates a sample dataset.//w w  w.java2 s .  c  o  m
 * 
 * @return A sample dataset.
 */
private static PieDataset createDataset(int tipo) {
    DefaultPieDataset dataset = new DefaultPieDataset();
    System.out.println("Data set");
    try {
        for (int i = 1; i < 13; i++) {
            Double importo = new Double(FatturaDAO.getFatturatoMese(i));
            dataset.setValue(mesi[i - 1] + ":" + importo, importo);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return dataset;
}