Example usage for java.lang Double floatValue

List of usage examples for java.lang Double floatValue

Introduction

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

Prototype

public float floatValue() 

Source Link

Document

Returns the value of this Double as a float after a narrowing primitive conversion.

Usage

From source file:de.jaetzold.philips.hue.HueLightGroup.java

@Override
public void setCieXY(Double ciex, Double ciey) {
    if (ciex < 0 || ciex > 1 || ciey < 0 || ciey > 1) {
        throw new IllegalArgumentException("A cie coordinate must be between 0.0-1.0");
    }/*from  w  w  w.j a  va 2 s .  co m*/
    stateChange("xy", new JSONArray(Arrays.asList(ciex.floatValue(), ciey.floatValue())));
    for (HueLightBulb light : getLights()) {
        light.ciex = ciex;
        light.ciey = ciey;
    }
}

From source file:opennlp.tools.jsmlearning.FeatureSpaceCoverageProcessor.java

public Float calcDistance(String[][] seed, String[] candidate) throws Exception {
    if (paramMap.isEmpty())
        throw new Exception("paramMap.isEmpty()");

    Float score = 0f, catScore = 10000f, currCatScore = 10000000f;

    int p1 = paramMap.get("First Level Category");
    int p2 = paramMap.get("Second Level Category");
    for (int v = 0; v < seed[0].length; v++) {
        if (seed[p1][v].equals(candidate[p1])) {
            if (seed[p2][v].equals(candidate[p2]))
                currCatScore = 0.0000001f;
            else//from w  ww  .jav a  2  s .  c  om
                currCatScore = 0.01f;
        }
        if (catScore > currCatScore) // if found closer, update
            catScore = currCatScore;
    }
    score = catScore;
    if (score > 1000000f)
        return 10000000f;

    Float latLongScore = 100000f, currLatLongScore = 10000000f;
    for (int v = 0; v < seed[0].length; v++) {
        try {
            int p3 = paramMap.get("Latitude");
            int p4 = paramMap.get("Longitude");
            if (seed[p3][v].equals("") || seed[p4][v].equals("") || candidate[p3].equals("")
                    || candidate[p4].equals(""))
                continue;
            Double latDiff = Math.abs(Double.parseDouble(seed[p3][v]) - Double.parseDouble(candidate[p3]));
            Double longDiff = Math.abs(Double.parseDouble(seed[p4][v]) - Double.parseDouble(candidate[p4]));
            if (!(latDiff > 1 || longDiff > 1))
                currLatLongScore = latDiff.floatValue() / 100.0f + longDiff.floatValue() / 100.0f;
        } catch (Exception e) {
            //return 1000000f;
        }
        if (latLongScore > currLatLongScore)
            latLongScore = currLatLongScore;

    }
    if (latLongScore > 10000)
        return 10000f;
    score += latLongScore;
    return score;
}

From source file:opennlp.tools.jsmlearning.FeatureSpaceCoverageProcessor.java

public Float calcDistance(String[] seed, String[] candidate) throws Exception {
    if (paramMap.isEmpty())
        throw new Exception("paramMap.isEmpty()");

    Float score = 0f;//w w  w  .ja  va 2 s . co m
    int p1 = paramMap.get("First Level Category");
    int p2 = paramMap.get("Second Level Category");
    if (seed[p1].equals(candidate[p1])) {
        if (seed[p2].equals(candidate[p2]))
            score = score + 0.0000001f;
        else
            score = score + 0.01f;
    } else
        return 100000f;

    try {
        int p3 = paramMap.get("Latitude");
        int p4 = paramMap.get("Longitude");
        Double latDiff = Math.abs(Double.parseDouble(seed[p3]) - Double.parseDouble(candidate[p3]));
        Double longDiff = Math.abs(Double.parseDouble(seed[p4]) - Double.parseDouble(candidate[p4]));
        if (latDiff > 1 || longDiff > 1)
            return 1000000f;
        else
            score += latDiff.floatValue() / 100.0f + longDiff.floatValue() / 100.0f;
    } catch (Exception e) {
        return 1000000f;
    }

    return score;
}

From source file:uk.ac.diamond.scisoft.ncd.calibration.rcp.views.AbsoluteIntensityCalibration.java

@Override
public void saveState(IMemento memento) {
    if (memento != null) {
        Double sampleThicknessVal = getSampleThickness();
        if (sampleThicknessVal != null) {
            memento.putFloat(NcdPreferences.NCD_SAMPLETHICKNESS, sampleThicknessVal.floatValue());
        }//  w w w.  j  a  v a  2 s.co m
        Double absScaleVal = getAbsScale();
        if (absScaleVal != null) {
            memento.putFloat(NcdPreferences.NCD_ABSOLUTESCALE, absScaleVal.floatValue());
        }
        Double absScaleStdDevVal = getAbsScaleStdDev();
        if (absScaleStdDevVal != null) {
            memento.putFloat(NcdPreferences.NCD_ABSOLUTESCALESTDDEV, absScaleStdDevVal.floatValue());
        }
    }
}

From source file:net.solarnetwork.node.power.impl.XantrexGtViewPowerDatumDataSource.java

@SuppressWarnings("deprecation")
private PowerDatum getPowerDatumInstance(String data) {
    if (log.isDebugEnabled()) {
        log.debug("Raw last sample data in file: " + data);
    }//ww w. ja va 2s  .co  m

    String[] tokens = data.split("\t");

    // only use this if DC watts is non-zero. Some junk is
    // left over from previous day in other fields
    Double d = getFrameDouble(tokens, FRAME_IDX_PV_WATTS);

    if (d == null || d.doubleValue() == 0.0) {
        return null;
    }

    PowerDatum datum = new PowerDatum();

    // Field 0: Date: unused

    // Field 1: Time: unused

    // Field 2: DC Volts
    d = getFrameDouble(tokens, FRAME_IDX_PV_VOLTS);
    if (d != null) {
        datum.setPvVolts(d.floatValue());
        if (log.isDebugEnabled()) {
            log.debug("DC Volts: " + d);
        }
    }

    // Field 3: DC Amps
    d = getFrameDouble(tokens, FRAME_IDX_PV_AMPS);
    if (d != null) {
        datum.setPvAmps(d.floatValue());
        if (log.isDebugEnabled()) {
            log.debug("DC Amps: " + d);
        }
    }

    // Field 4: MPPT: unused

    // Field 5: DC Watts: already parsed above

    // Field 7: Efficiency: unused

    // Field 8: AC Volts: unused
    d = getFrameDouble(tokens, FRAME_IDX_AC_VOLTS);
    if (d != null) {
        datum.setAcOutputVolts(d.floatValue());
        if (log.isDebugEnabled()) {
            log.debug("AC Volts: " + d);
        }
    }

    // Field 6: AC Watts: used to set AC amps
    d = getFrameDouble(tokens, FRAME_IDX_AC_WATTS);
    if (d != null) {
        if (datum.getAcOutputVolts() > 0) {
            datum.setAcOutputAmps(d.floatValue() / datum.getAcOutputVolts());
        }
        if (log.isDebugEnabled()) {
            log.debug("AC Amps: " + d);
        }
    }

    // Field 9: Cumulative AC Watts
    d = getFrameDouble(tokens, FRAME_IDX_WH);
    if (d != null) {
        // store Wh as kWh
        datum.setKWattHoursToday(d.doubleValue() / 1000);
        if (log.isDebugEnabled()) {
            log.debug("WH: " + d);
        }
    }

    return datum;

}

From source file:org.openfaces.component.chart.impl.renderers.LineFillRenderer.java

private Paint getAreaFillPaint(CategoryPlot plot, Double plotWidth, Double plotHeight, Color mainColor,
        Color secondaryColor) {/*from   w  w  w . j  av  a 2s .c  o m*/
    return (plot.getOrientation() == PlotOrientation.VERTICAL)
            ? new GradientPaint(0.0f, 0.0f, mainColor, 0.0f, plotHeight.floatValue(), secondaryColor, true)
            : new GradientPaint(plotWidth.floatValue(), 0.0f, mainColor, 0.0f, 0.0f, secondaryColor, true);
}

From source file:servlet.F_Function.java

public String[] SetTempData(String Query) {
    String[] cm;//w  ww .  ja va  2  s. c o m
    Object[] rs = Select(Query);
    if (rs != null) {
        List<String> dokumenList = new ArrayList<>();
        for (Object r : rs) {
            Double nile = Double.valueOf(r.toString());
            dokumenList.add(Integer.toString(round(nile.floatValue())));
        }
        cm = new String[dokumenList.size()];
        cm = dokumenList.toArray(cm);
    } else {
        List<String> dokumenList = new ArrayList<>();
        dokumenList.add("0");
        cm = new String[dokumenList.size()];
        cm = dokumenList.toArray(cm);
    }
    return cm;
}

From source file:servlet.F_Function.java

public boolean SetTempData(String Query, int colCount, String Static, boolean[] fromDouble) {
    Object[][] rs = Select(Query, colCount);
    try {//ww  w.j  a  va  2 s .com
        List<String> dokumenList = new ArrayList<>();
        dokumenList.add(Static);
        for (int i = 0; i < colCount; i++) {
            if (fromDouble != null && fromDouble[i]) {
                Double nile = Double.valueOf(String.valueOf(rs[0][i]));
                dokumenList.add(Integer.toString(round(nile.floatValue())));
            } else {
                dokumenList.add(rs[0][i].toString());
            }
        }
        TempData = new String[dokumenList.size()];
        TempData = dokumenList.toArray(TempData);
        return true;
    } catch (ArrayIndexOutOfBoundsException e) {
        return false;
    }
}

From source file:de.jaetzold.philips.hue.HueLightBulb.java

@Override
public void setCieXY(Double ciex, Double ciey) {
    if (ciex < 0 || ciex > 1 || ciey < 0 || ciey > 1) {
        throw new IllegalArgumentException("A cie coordinate must be between 0.0-1.0");
    }/*from  www  .  j  a v a  2  s  .co  m*/
    stateChange("xy", new JSONArray(Arrays.asList(ciex.floatValue(), ciey.floatValue())));
    this.ciex = ciex;
    this.ciey = ciey;
    colorMode = ColorMode.XY;
}

From source file:org.openfaces.component.chart.impl.renderers.LineFillRenderer.java

private void configureSolidAreaFill(Graphics2D g2, Paint itemPaint, SolidLineAreaFill solidLineAreaFill) {
    final Double transparency = solidLineAreaFill.getTransparency();

    if (itemPaint instanceof Color && transparency >= 0.0 && transparency <= 1.0) {
        Color itemColor = (Color) itemPaint;
        int alpha = transparency >= 0.0 && transparency <= 1.0 ? Math.round(255 * transparency.floatValue())
                : 255;/*ww  w .  ja v a 2s  .co  m*/
        g2.setPaint(new Color(itemColor.getRed(), itemColor.getGreen(), itemColor.getBlue(), alpha));
    } else {
        g2.setPaint(itemPaint);
    }
}