Example usage for java.lang Double doubleValue

List of usage examples for java.lang Double doubleValue

Introduction

In this page you can find the example usage for java.lang Double doubleValue.

Prototype

@HotSpotIntrinsicCandidate
public double doubleValue() 

Source Link

Document

Returns the double value of this Double object.

Usage

From source file:edu.cmu.cs.hcii.cogtool.model.CachedTermSimilarity.java

/**
 * Look up the word pair in the cache; if there, return the associated
 * similarity.  If not there, fetch it.//from   www  .ja  va 2s  .  c  o m
 */
protected double getWordSimilarity(String goalWord, String searchWord, List<String> errors) {
    if ((goalWord == null) || (searchWord == null)) {
        return UNKNOWN;
    }

    WordPair.SEARCH_KEY.goalWord = goalWord.toLowerCase();
    WordPair.SEARCH_KEY.searchWord = searchWord.toLowerCase();

    if (similarityTable.containsKey(WordPair.SEARCH_KEY)) {
        Double cachedSimilarity = similarityTable.get(WordPair.SEARCH_KEY);

        if (cachedSimilarity != null) {
            return cachedSimilarity.doubleValue();
        }

        throw new IllegalStateException(
                "Similarity table contains a null similarity for pair: " + goalWord + ", " + searchWord);
    }

    Double similarity = fetchWordSimilarity(goalWord, searchWord, errors);

    if (similarity != null) {
        WordPair newEntry = new WordPair(goalWord, searchWord);

        similarityTable.put(newEntry, similarity);

        return similarity.doubleValue();
    }

    return UNKNOWN;
}

From source file:net.sourceforge.eclipsetrader.core.CurrencyConverter.java

public double convert(Date date, double amount, String from, String to) {
    double result = amount;

    if (from == null || to == null || from.equals(to))
        return result;

    Double ratio = null;//from  w ww.  j av a 2 s  .  c  o m
    if (date != null) {
        ratio = getExchangeRatio(date, from, to);
        if (ratio == null) {
            Double r = getExchangeRatio(date, to, from);
            if (r != null)
                ratio = new Double(1 / r.doubleValue());
        }
    }
    if (ratio == null)
        ratio = getExchangeRatio(from, to);

    if (ratio != null)
        result = amount * ratio.doubleValue();

    if (date != null && ratio != null)
        setExchangeRatio(date, from, to, ratio.doubleValue());

    return result;
}

From source file:org.polymap.kaps.ui.form.WohnungVertragsdatenFormEditorPage.java

@SuppressWarnings("unchecked")
@Override/*from w ww. jav  a2  s . c  o m*/
public void createFormContent(final IFormEditorPageSite site) {
    super.createFormContent(site);

    Control newLine, lastLine = null;
    Composite parent = pageSite.getPageBody();

    int ONE = 15;
    int TWO = 40;
    int THREE = 50;
    int FOUR = 80;

    final VertragComposite vertrag = wohnung.flurstueck().get() != null
            ? wohnung.flurstueck().get().vertrag().get()
            : null;
    final boolean keinVertragZugeordnet = vertrag == null;
    String label = keinVertragZugeordnet ? "Kein Vertrag zugewiesen"
            : "Vertrag " + EingangsNummerFormatter.format(vertrag.eingangsNr().get()) + " ffnen";
    final ActionButton openErweiterteDaten = new ActionButton(parent, new Action(label) {

        @Override
        public void run() {
            KapsPlugin.openEditor(fs, VertragComposite.NAME, vertrag);
        }
    });
    openErweiterteDaten.setLayoutData(left().left(ONE).right(TWO).height(25).create());
    openErweiterteDaten.setEnabled(vertrag != null);
    newLine = openErweiterteDaten;

    if (vertrag != null) {
        lastLine = newLine;
        ActionButton delete = new ActionButton(parent, new Action(
                "Vertrag " + EingangsNummerFormatter.format(vertrag.eingangsNr().get()) + " entfernen") {

            @Override
            public void run() {
                queue(new UpdateCommand() {

                    @Override
                    public void execute() {
                        // create new flurstueck ohne Vertrag
                        // flurstueck suchen ohne vertrag, wenn es nicht
                        // existiert, neu anlegen
                        FlurstueckComposite current = wohnung.flurstueck().get();
                        FlurstueckComposite ohneVertrag = null;
                        for (FlurstueckComposite found : FlurstueckSearcher.findFlurstuecke(
                                current.gemarkung().get(), current.flur().get(), current.hauptNummer().get(),
                                current.unterNummer().get())) {
                            if (found.vertrag().get() == null) {
                                ohneVertrag = found;
                                break;
                            }
                        }
                        if (ohneVertrag == null) {
                            ohneVertrag = repository.newEntity(FlurstueckComposite.class, null);
                            ohneVertrag.flur().set(repository.findSchlNamed(FlurComposite.class, "000"));
                            // zum Gebude ergnzen
                            GebaeudeComposite gebaeude = GebaeudeComposite.Mixin
                                    .forKeys(wohnung.objektNummer().get(), wohnung.gebaeudeNummer().get());
                            if (gebaeude != null) {
                                gebaeude.flurstuecke().add(ohneVertrag);
                            }
                            ohneVertrag.gemarkung().set(current.gemarkung().get());
                            ohneVertrag.gemarkungWA().set(current.gemarkung().get().schl().get());

                            ohneVertrag.hauptNummer().set(current.hauptNummer().get());
                            ohneVertrag.unterNummer().set(current.unterNummer().get());
                            ohneVertrag.strasse().set(current.strasse().get());
                            ohneVertrag.hausnummer().set(current.hausnummer().get());
                            ohneVertrag.hausnummerZusatz().set(current.hausnummerZusatz().get());
                            ohneVertrag.richtwertZone().set(current.richtwertZone().get());
                            ohneVertrag.kartenBlatt().set(current.kartenBlatt().get());
                            ohneVertrag.baublock().set(current.baublock().get());
                            ohneVertrag.nutzung().set(current.nutzung().get());
                            ohneVertrag.gebaeudeArt().set(current.gebaeudeArt().get());
                            ohneVertrag.artDesBaugebiets().set(current.artDesBaugebiets().get());
                            ohneVertrag.flaeche().set(current.flaeche().get());
                            ohneVertrag.flaechenAnteilZaehler().set(current.flaechenAnteilZaehler().get());
                            ohneVertrag.flaechenAnteilNenner().set(current.flaechenAnteilNenner().get());
                            ohneVertrag.verkaufteFlaeche().set(current.verkaufteFlaeche().get());
                            ohneVertrag.erbbaurecht().set(current.erbbaurecht().get());
                            for (BelastungComposite belastung : current.belastungen().toList()) {
                                ohneVertrag.belastungen().add(belastung);
                            }
                        }
                        wohnung.flurstueck().set(ohneVertrag);
                        //
                        openErweiterteDaten.setEnabled(false);
                        setEnabled(false);
                        openErweiterteDaten.setText("Kein Vertrag zugewiesen");
                    }
                });
            }
        });
        delete.setLayoutData(left().left(ONE).right(TWO).height(25).top(lastLine).create());
        delete.setEnabled(true);
        newLine = delete;
    }

    if (keinVertragZugeordnet) {
        wohnung.kaufpreis().set(null);
        wohnung.bereinigterVollpreis().set(null);
        wohnung.vollpreisWohnflaeche().set(null);
        wohnung.bodenpreis().set(null);
    }

    lastLine = newLine;
    newLine = createLabel(parent, "Vollpreis", left().right(ONE).top(lastLine), SWT.RIGHT);
    createPreisField(wohnung.kaufpreis(), left().left(ONE).right(TWO).top(lastLine), parent, false);

    lastLine = newLine;
    newLine = createLabel(parent, "Abschlag in ", left().right(TWO).top(lastLine, 22), SWT.CENTER);
    createLabel(parent, "geschtzt", left().left(TWO).right(THREE).top(lastLine), SWT.CENTER);
    createLabel(parent, "Beschreibung", left().left(THREE).right(FOUR).top(lastLine), SWT.CENTER);
    createLabel(parent, "Anzahl", left().left(FOUR).right(100).top(lastLine), SWT.CENTER);

    lastLine = newLine;
    newLine = createLabel(parent, "Garage", left().right(ONE).top(lastLine), SWT.RIGHT);
    createPreisField(wohnung.abschlagGarage(), left().left(ONE).right(TWO).top(lastLine), parent, true);
    newFormField(IFormFieldLabel.NO_LABEL).setProperty(new PropertyAdapter(wohnung.schaetzungGarage()))
            .setField(new CheckboxFormField())
            .setLayoutData(left().left(TWO).right(THREE).top(lastLine).create()).create();
    newFormField(IFormFieldLabel.NO_LABEL)
            .setProperty(new AssociationAdapter<GebaeudeArtComposite>(wohnung.gebaeudeArtGarage()))
            .setField(namedAssocationsPicklist(GebaeudeArtComposite.class))
            .setLayoutData(left().left(THREE).right(FOUR).top(lastLine).create()).create();
    newFormField(IFormFieldLabel.NO_LABEL).setProperty(new PropertyAdapter(wohnung.anzahlGaragen()))
            .setField(new StringFormField(StringFormField.Style.ALIGN_RIGHT))
            .setValidator(new MyNumberValidator(Integer.class))
            .setLayoutData(left().left(FOUR).right(100).top(lastLine).create()).create();

    lastLine = newLine;
    newLine = createLabel(parent, "Stellplatz", left().right(ONE).top(lastLine), SWT.RIGHT);
    createPreisField(wohnung.abschlagStellplatz(), left().left(ONE).right(TWO).top(lastLine), parent, true);
    newFormField(IFormFieldLabel.NO_LABEL).setProperty(new PropertyAdapter(wohnung.schaetzungStellplatz()))
            .setField(new CheckboxFormField())
            .setLayoutData(left().left(TWO).right(THREE).top(lastLine).create()).create();
    newFormField(IFormFieldLabel.NO_LABEL)
            .setProperty(new AssociationAdapter<GebaeudeArtComposite>(wohnung.gebaeudeArtStellplatz()))
            .setField(namedAssocationsPicklist(GebaeudeArtComposite.class))
            .setLayoutData(left().left(THREE).right(FOUR).top(lastLine).create()).create();
    newFormField(IFormFieldLabel.NO_LABEL).setProperty(new PropertyAdapter(wohnung.anzahlStellplatz()))
            .setField(new StringFormField(StringFormField.Style.ALIGN_RIGHT))
            .setValidator(new MyNumberValidator(Integer.class))
            .setLayoutData(left().left(FOUR).right(100).top(lastLine).create()).create();

    lastLine = newLine;
    newLine = createLabel(parent, "Anderes", left().right(ONE).top(lastLine), SWT.RIGHT);
    createPreisField(wohnung.abschlagAnderes(), left().left(ONE).right(TWO).top(lastLine), parent, true);
    newFormField(IFormFieldLabel.NO_LABEL).setProperty(new PropertyAdapter(wohnung.schaetzungAnderes()))
            .setField(new CheckboxFormField())
            .setLayoutData(left().left(TWO).right(THREE).top(lastLine).create()).create();
    newFormField(IFormFieldLabel.NO_LABEL)
            .setProperty(new AssociationAdapter<GebaeudeArtComposite>(wohnung.gebaeudeArtAnderes()))
            .setField(namedAssocationsPicklist(GebaeudeArtComposite.class))
            .setLayoutData(left().left(THREE).right(FOUR).top(lastLine).create()).create();
    newFormField(IFormFieldLabel.NO_LABEL).setProperty(new PropertyAdapter(wohnung.anzahlAnderes()))
            .setField(new StringFormField(StringFormField.Style.ALIGN_RIGHT))
            .setValidator(new MyNumberValidator(Integer.class))
            .setLayoutData(left().left(FOUR).right(100).top(lastLine).create()).create();

    lastLine = newLine;
    newLine = newFormField(IFormFieldLabel.NO_LABEL).setToolTipText("Zusatz")
            .setProperty(new PropertyAdapter(wohnung.abschlagBemerkung())).setField(new StringFormField())
            .setLayoutData(left().left(THREE).right(FOUR).top(lastLine).create()).create();

    lastLine = newLine;
    newLine = createLabel(parent, "bereinigter Vollpreis", left().right(ONE).top(lastLine, 12), SWT.RIGHT);
    createPreisField(wohnung.bereinigterVollpreis(), left().left(ONE).right(TWO).top(lastLine), parent, false);
    site.addFieldListener(
            vollpreis = new FieldCalculation(pageSite, 2, wohnung.bereinigterVollpreis(), wohnung.kaufpreis(),
                    wohnung.abschlagGarage(), wohnung.abschlagStellplatz(), wohnung.abschlagAnderes()) {

                @Override
                protected Double calculate(ValueProvider values) {
                    Double kaufpreis = values.get(wohnung.kaufpreis());
                    if (kaufpreis != null) {
                        Double ag = values.get(wohnung.abschlagGarage());
                        if (ag != null) {
                            kaufpreis += ag;
                        }
                        ag = values.get(wohnung.abschlagStellplatz());
                        if (ag != null) {
                            kaufpreis += ag;
                        }
                        ag = values.get(wohnung.abschlagAnderes());
                        if (ag != null) {
                            kaufpreis += ag;
                        }
                    }
                    return kaufpreis;
                }
            });

    lastLine = newLine;
    newLine = createLabel(parent, "Vollpreis Wohnflche", left().right(ONE).top(lastLine), SWT.RIGHT);
    createPreisField(wohnung.vollpreisWohnflaeche(), left().left(ONE).right(TWO).top(lastLine), parent, false);
    site.addFieldListener(vollpreisWohnflaeche = new FieldCalculation(pageSite, 2,
            wohnung.vollpreisWohnflaeche(), wohnung.bereinigterVollpreis(), wohnung.wohnflaeche()) {

        @Override
        protected Double calculate(ValueProvider values) {
            Double bereinigterVollpreis = values.get(wohnung.bereinigterVollpreis());
            if (bereinigterVollpreis != null) {
                Double wfl = values.get(wohnung.wohnflaeche());
                if (wfl != null && wfl.doubleValue() != 0.0d) {
                    bereinigterVollpreis /= wfl;
                }
            }
            return MathUtil.round(bereinigterVollpreis);
        }
    });

    lastLine = newLine;
    newLine = newFormField("vermietet?").setProperty(new PropertyAdapter(wohnung.vermietet()))
            .setField(new BooleanFormField()).setLayoutData(left().top(lastLine).create()).create();
    newLine = newFormField("geeignet?").setToolTipText("zur Auswertung geeignet?")
            .setProperty(new PropertyAdapter(wohnung.zurAuswertungGeeignet())).setField(new CheckboxFormField())
            .setLayoutData(right().top(lastLine).create()).create();

    lastLine = newLine;
    newLine = createFlaecheField("Gewichtung", "Gewichtung (Norm = 1,0)", wohnung.gewichtung(),
            left().top(lastLine), parent, true);

    lastLine = newLine;
    newLine = newFormField("Bemerkung").setProperty(new PropertyAdapter(wohnung.bemerkungVertragsdaten()))
            .setField(new TextFormField()).setLayoutData(left().right(RIGHT).height(50).top(lastLine).create())
            .setParent(parent).create();

}

From source file:ch.epfl.lsir.xin.algorithm.core.UserBasedCF.java

public double getPredictionRanking(int userIndex, int itemIndex) {
    ArrayList<SUser> similarUsers = new ArrayList<SUser>();

    //find the similar users
    for (int i = 0; i < this.ratingMatrix.getRow(); i++) {
        //get the similarity information
        if (i == userIndex)
            continue;
        Double rating = this.ratingMatrix.getRatingMatrix().get(i).get(itemIndex);
        if (rating == null)
            continue;
        SUser su = new SUser(i, rating.doubleValue(), this.similarityMatrix[userIndex][i]);
        similarUsers.add(su);//ww w .  j a  va2 s  .co  m

    }
    Collections.sort(similarUsers);
    if (similarUsers.size() < 1 || similarUsers.get(similarUsers.size() - 1).getSimilarity() == 0) {
        return 0;
    }
    int count = 0;
    int neighbors = this.config.getInt("NEIGHBOUR_SIZE");
    int c = 0;
    for (int i = similarUsers.size() - 1; i >= 0; i--) {
        if (this.ratingMatrix.getRatingMatrix().get(similarUsers.get(i).getUserIndex())
                .get(itemIndex) != null) {
            count++;
        }
        c++;
        if (c == neighbors)
            break;
    }
    return (double) count / neighbors;
}

From source file:org.apache.hadoop.hive.ql.udf.generic.NGramEstimator.java

/**
 * Returns the final top-k n-grams in a format suitable for returning to Hive.
 *//*  w w w. ja v a2 s  . c  om*/
public ArrayList<Object[]> getNGrams() throws HiveException {
    trim(true);
    if (ngrams.size() < 1) { // SQL standard - return null for zero elements
        return null;
    }

    // Sort the n-gram list by frequencies in descending order
    ArrayList<Object[]> result = new ArrayList<Object[]>();
    ArrayList<Map.Entry<ArrayList<String>, Double>> list = new ArrayList(ngrams.entrySet());
    Collections.sort(list, new Comparator<Map.Entry<ArrayList<String>, Double>>() {
        public int compare(Map.Entry<ArrayList<String>, Double> o1, Map.Entry<ArrayList<String>, Double> o2) {
            int result = o2.getValue().compareTo(o1.getValue());
            if (result != 0)
                return result;

            ArrayList<String> key1 = o1.getKey();
            ArrayList<String> key2 = o2.getKey();
            for (int i = 0; i < key1.size() && i < key2.size(); i++) {
                result = key1.get(i).compareTo(key2.get(i));
                if (result != 0)
                    return result;
            }

            return key1.size() - key2.size();
        }
    });

    // Convert the n-gram list to a format suitable for Hive
    for (int i = 0; i < list.size(); i++) {
        ArrayList<String> key = list.get(i).getKey();
        Double val = list.get(i).getValue();

        Object[] curGram = new Object[2];
        ArrayList<Text> ng = new ArrayList<Text>();
        for (int j = 0; j < key.size(); j++) {
            ng.add(new Text(key.get(j)));
        }
        curGram[0] = ng;
        curGram[1] = new DoubleWritable(val.doubleValue());
        result.add(curGram);
    }

    return result;
}

From source file:it.proximacentauri.ienergy.da.dao.impl.ConfortDaoImpl.java

@Override
public Double computeResult(Indicator indicator, Date start, Date end) {
    log.info("compute the result of indicator {} from date {} to date {}", indicator.getName(), start, end);
    Query query = null;//  w w w . ja va 2s. co  m

    switch (indicator.getFunction()) {
    case AVG:
        query = em.createQuery(
                "SELECT AVG(v.value) FROM Vote as v JOIN v.indicator as i where i.name = :name and v.time >= :start and v.time <= :end");
        break;
    case LOGABSSUM:
        query = em.createQuery(
                "SELECT SUM(v.value) FROM Vote as v JOIN v.indicator as i where i.name = :name and v.time >= :start and v.time <= :end");
        break;
    case LOGSUM:
    case SUM:
    default:
        query = em.createQuery(
                "SELECT SUM(v.value) FROM Vote as v JOIN v.indicator as i where i.name = :name and v.time >= :start and v.time <= :end");
        break;

    }
    query.setParameter("name", indicator.getName());
    query.setParameter("start", start);
    query.setParameter("end", end);

    final Object object = query.getResultList().get(0);
    Double result = null;
    if (object == null)
        return null;
    if (object instanceof Long) {
        result = new Double(object.toString());
    } else {
        result = (Double) object;
    }

    // post selection computing
    log.debug("result of database group by is {}", result);

    switch (indicator.getFunction()) {
    case LOGABSSUM:
        if (result.doubleValue() > 0.0)
            return Math.log10(result);
        if (result.doubleValue() < 0.0)
            return -Math.log10(-result);
        return result;

    case LOGSUM:
        if (result.doubleValue() == 0.0)
            return result;
        return Math.log10(result);
    default:
        return result;

    }
}

From source file:org.acmsl.commons.utils.ConversionUtils.java

/**
 * Converts given String to double./*from ww  w.  j a  v  a 2  s  . c om*/
 * @param value the value to convert.
 * @return the converted value.
 */
public double toDouble(@Nullable final String value) {
    double result = 0.0d;

    @Nullable
    final Double t_Result = toDoubleIfNotNull(value);

    if (t_Result != null) {
        result = t_Result.doubleValue();
    }

    return result;
}

From source file:com.att.aro.ui.view.diagnostictab.plot.ThroughputPlot.java

public void populate(XYPlot plot, AROTraceData analysis) {
    XYSeries series = new XYSeries(0);
    if (analysis != null) {

        // Get packet iterators
        List<PacketInfo> packets = analysis.getAnalyzerResult().getTraceresult().getAllpackets();
        final double maxTS = analysis.getAnalyzerResult().getTraceresult().getTraceDuration();

        final List<String> tooltipList = new ArrayList<String>(1000);

        Double zeroTime = null;
        double lastTime = 0.0;
        double startTime = analysis.getAnalyzerResult().getFilter().getTimeRange().getBeginTime();
        for (Throughput t : throughputHelper.calculateThroughput(startTime, maxTS,
                analysis.getAnalyzerResult().getProfile().getThroughputWindow(), packets)) {

            double time = t.getTime();
            double kbps = t.getKbps();
            if (kbps != 0.0) {
                if (zeroTime != null && zeroTime.doubleValue() != lastTime) {
                    series.add(lastTime, 0.0);
                    tooltipList.add(MessageFormat.format(THROUGHPUT_TOOLTIP, 0.0));
                }/*from w w w. j  a  v a 2 s . c om*/
                // Add slot to data set
                series.add(time, kbps);

                tooltipList.add(MessageFormat.format(THROUGHPUT_TOOLTIP, kbps));
                zeroTime = null;
            } else {
                if (zeroTime == null) {
                    // Add slot to data set
                    series.add(time, kbps);

                    tooltipList.add(MessageFormat.format(THROUGHPUT_TOOLTIP, kbps));
                    zeroTime = Double.valueOf(time);
                }
            }

            lastTime = time;
        }
        plot.getRenderer().setBaseToolTipGenerator(new XYToolTipGenerator() {

            @Override
            public String generateToolTip(XYDataset dataset, int series, int item) {

                // Tooltip displays throughput value
                return tooltipList.get(item);
            }

        });
    }

    plot.setDataset(new XYSeriesCollection(series));
    //      return plot;
}

From source file:org.polymap.kaps.ui.form.ErtragswertverfahrenLiegenschaftszinsFormEditorPage.java

@SuppressWarnings("unchecked")
@Override/*from  w ww .  j  av a 2 s  .com*/
public void createFormContent(final IFormEditorPageSite site) {
    super.createFormContent(site);

    Control newLine, lastLine = null;
    Composite parent = pageSite.getPageBody();

    // Section section = newSection( parent, "Bodenwertaufteilung" );
    // Composite client = (Composite)section.getClient();
    Composite client = parent;

    newLine = createLabel(client, "Anteil des Gewerbes in %", one().top(lastLine, 20), SWT.RIGHT);
    createFlaecheField(vb.anteilDesGewerbes(), two().top(lastLine, 20), client, true);

    lastLine = newLine;
    newLine = createLabel(client, "Art des Gewerbes", one().top(lastLine), SWT.RIGHT);
    createTextField(vb.artDesGewerbes(), two().right(75).top(lastLine), client);

    lastLine = newLine;
    newLine = createLabel(client, "Grundstckart", one().top(lastLine), SWT.RIGHT);
    createFlaecheField(vb.grundstuecksArt(), two().top(lastLine), client, true);

    lastLine = newLine;
    newLine = createLabel(client, "Liegenschaftszins", one().top(lastLine), SWT.RIGHT);
    createPreisField(vb.liegenschaftsZins(), two().top(lastLine), client, false);

    lastLine = newLine;
    newLine = createLabel(client, "Gewichtung", one().top(lastLine), SWT.RIGHT);
    createFlaecheField(vb.gewichtungLiegenschaftszins(), two().top(lastLine), client, false);
    site.addFieldListener(
            liziListener = new FieldCalculation(site, 2, vb.liegenschaftsZins(), vb.bereinigterKaufpreis(),
                    vb.jahresReinErtrag(), vb.ertragswert(), vb.bodenwertAnteil(), vb.restnutzungsDauer()) {

                @Override
                protected Double calculate(ValueProvider values) {
                    Double re = values.get(vb.jahresReinErtrag());
                    Double kp = values.get(vb.bereinigterKaufpreis());
                    Double ertragsWert = values.get(vb.ertragswert());
                    Double bodenWert = values.get(vb.bodenwertAnteil());
                    Double n = values.get(vb.restnutzungsDauer());
                    if (ertragsWert != null && bodenWert != null && re != null && kp != null
                            && kp.doubleValue() != 0 && n != null) {
                        Double g = ertragsWert - bodenWert;
                        Double f1 = re / kp;
                        Double f2 = g / kp;

                        // vorher
                        Double liziV = f1;
                        // neu
                        Double liziN = f1 - (liziV / (Math.pow(1 + liziV, n) - 1) * f2);

                        int iteration = 1;
                        while (Math.abs(liziN - liziV) > 0.005d) {
                            liziV = liziN;
                            liziN = f1 - (liziV / (Math.pow(1 + liziV, n) - 1) * f2);
                            iteration++;
                        }

                        site.setFieldValue(vb.gewichtungLiegenschaftszins().qualifiedName().name(),
                                NumberFormatter.getFormatter(0).format(iteration));
                        // in % umrechnen
                        return liziN * 100;
                    }
                    return null;
                }
            });

    lastLine = newLine;
    newLine = createLabel(client, "LiZi verwenden?", "Liegenschaftszins fr wertrelevante Daten verwenden?",
            one().top(lastLine), SWT.RIGHT);
    createBooleanField(vb.liziVerwenden(), two().top(lastLine), client);
}

From source file:at.uni_salzburg.cs.ckgroup.cscpp.utils.SensorProxy.java

/**
 * @param values the values to be parsed.
 */// w  w w.j a v  a2 s.  c  om
private void parseValues(String values) {
    String[] lines = values.trim().split("\n");
    for (String l : lines) {
        String[] kv = l.trim().split(":\\s+");
        if (kv.length < 2) {
            continue;
        }

        Double val = Double.parseDouble(kv[1]);

        if ("Latitude".equals(kv[0])) {
            if (currentPosition == null) {
                currentPosition = new PolarCoordinate();
            }
            currentPosition.latitude = val.doubleValue();

        } else if ("Longitude".equals(kv[0])) {
            if (currentPosition == null) {
                currentPosition = new PolarCoordinate();
            }
            currentPosition.longitude = val.doubleValue();

        } else if ("Altitude".equals(kv[0])) {
            if (currentPosition == null) {
                currentPosition = new PolarCoordinate();
            }
            currentPosition.altitude = val.doubleValue();

        } else if ("CourseOverGround".equals(kv[0])) {
            orientationOverGround = val;

        } else if ("SpeedOverGround".equals(kv[0])) {
            speedOverGround = val;

        } else if ("AltitudeOverGround".equals(kv[0])) {
            altitudeOverGround = val;

        } else {
            LOG.error("Can not parse '" + l + "'");
        }
    }

}