Example usage for java.lang Float toString

List of usage examples for java.lang Float toString

Introduction

In this page you can find the example usage for java.lang Float toString.

Prototype

public static String toString(float f) 

Source Link

Document

Returns a string representation of the float argument.

Usage

From source file:com.aimfire.demo.CamcorderActivity.java

/**
 * report our camera parameters to the other device. 
 *//*from w w  w. j  av a  2  s.  c  om*/
private void sendCamParams() {
    if (BuildConfig.DEBUG)
        Log.d(TAG, "sendCamParams");

    if (!mP2pConnected) {
        if (BuildConfig.DEBUG)
            Log.d(TAG, "sendCamParams: P2P not connected");
        return;
    }

    if (mCamParamsSent) {
        if (BuildConfig.DEBUG)
            Log.d(TAG, "sendCamParams: camera parameter already sent");
        return;
    }

    int[] maxXYResolution = CameraUtils.getMaxXYResolution();
    float[] viewAnglesFocusLen = CameraUtils.getViewAngleFocusLen();

    if (mAimfireService != null) {
        mAimfireService.sendStringToPeer(true, MainConsts.CMD_DEMO_CAMERA_REPORT_PARAMETERS + ":" + mPosPref
                + ":" + Integer.toString(mQualityPref) + ":" + Integer.toString(mSupportedVideoQualities) + ":"
                + Integer.toString(maxXYResolution[0]) + ":" + Integer.toString(maxXYResolution[1]) + ":"
                + Float.toString(viewAnglesFocusLen[0]) + ":" + Float.toString(viewAnglesFocusLen[1]) + ":"
                + Float.toString(viewAnglesFocusLen[2]));
    } else {
        if (BuildConfig.DEBUG)
            Log.e(TAG, "sendCamParams: mAimfireService is null");
        FirebaseCrash.report(new Exception("CamcorderActivity sendCamParams: mAimfireService is null"));
    }

    mCamParamsSent = true;
}

From source file:org.fhaes.neofhchart.svg.FireChartSVG.java

/**
 * Draws a line on the annotation grouper.
 * /*from   w  ww  .j  ava  2 s .com*/
 * @param x
 * @return
 */
public String drawAnnoteLine(int x) {

    if (annotemode == AnnoteMode.LINE) {
        Element annote_g = doc.getElementById("annote_g");
        Element annote_canvas = doc.getElementById("annote_canvas");
        Element annote_line = doc.createElementNS(svgNS, "line");
        SVGRect annote_canvas_rc = SVGLocatableSupport.getBBox(annote_canvas);

        String id = "annote_line_" + (lineGensym++);
        annote_line.setAttributeNS(null, "id", id);
        annote_line.setAttributeNS(null, "x1", Float.toString(x - chartXOffset));
        annote_line.setAttributeNS(null, "y1", "0");
        annote_line.setAttributeNS(null, "x2", Float.toString(x - chartXOffset));
        annote_line.setAttributeNS(null, "y2", Float.toString(annote_canvas_rc.getHeight()));
        annote_line.setAttributeNS(null, "stroke", "black");
        annote_line.setAttributeNS(null, "stroke-width", "3");
        annote_line.setAttributeNS(null, "opacity", "0.5");
        annote_line.setAttributeNS(null, "onmousedown",
                "FireChartSVG.getChart(chart_num).deleteAnnoteLine('" + id + "')");

        annote_g.appendChild(annote_line);
        annotemode = AnnoteMode.NONE;

        return id;
    }

    return "wrong_annotemode";
}

From source file:forseti.JUtil.java

public static synchronized String CantEnLetra(float cant, String id_moneda, String moneda) {
    String MONEDA = (moneda == null) ? "" : moneda;
    String MN;/*from   ww w .j av  a 2 s . co  m*/
    if (id_moneda == null || !id_moneda.equals("1"))
        MN = "";
    else
        MN = "m.n.";

    if (cant == 0.00)
        return "cero " + MONEDA + " 00/100 " + MN;

    StringBuffer sCant;
    String sDec = "", sCen = "", sMil = "", s10Mil = "", s100Mil = "", sMillon = "", s10Millon = "",
            s100Millon = "", s1000Millon = "";
    String str, decim;
    str = Float.toString(redondear(cant, 2));

    int index = str.indexOf('.');
    if (index == -1)
        decim = "00/100";
    else {
        decim = str.substring(index + 1);
        if (decim.length() == 1)
            decim = decim + "0/100";
        else
            decim = decim + "/100";

    }

    int cantent = (int) Math.floor((double) redondear(cant, (byte) 2));
    int dec = 0, cen = 0, mil = 0, diezmil = 0, cienmil = 0, millon = 0, diezmillon = 0, cienmillon = 0,
            milmillon = 0;

    sCant = new StringBuffer(Integer.toString(cantent));
    sCant.reverse();

    int len = sCant.length();

    if (len > 0) {
        dec = Integer.parseInt(sCant.substring(0, 1));
        switch (dec) {
        case 1:
            sDec = "un";
            break;
        case 2:
            sDec = "dos";
            break;
        case 3:
            sDec = "tres";
            break;
        case 4:
            sDec = "cuatro";
            break;
        case 5:
            sDec = "cinco";
            break;
        case 6:
            sDec = "seis";
            break;
        case 7:
            sDec = "siete";
            break;
        case 8:
            sDec = "ocho";
            break;
        case 9:
            sDec = "nueve";
            break;
        default:
            sDec = "";
            break;
        }
    }

    if (len > 1) {
        cen = Integer.parseInt(sCant.substring(1, 2));
        switch (cen) {
        case 1:
            if (dec == 0)
                sCen = "diez";
            else if (dec == 1) {
                sCen = "once";
                sDec = "";
            } else if (dec == 2) {
                sCen = "doce";
                sDec = "";
            } else if (dec == 3) {
                sCen = "trece";
                sDec = "";
            } else if (dec == 4) {
                sCen = "catorce";
                sDec = "";
            } else if (dec == 5) {
                sCen = "quince";
                sDec = "";
            } else
                sCen = "dieci";
            break;
        case 2:
            if (dec == 0)
                sCen = "veinte";
            else
                sCen = "veinti";
            break;
        case 3:
            if (dec == 0)
                sCen = "treinta";
            else
                sCen = "treinta y ";
            break;
        case 4:
            if (dec == 0)
                sCen = "cuarenta";
            else
                sCen = "cuarenta y ";
            break;
        case 5:
            if (dec == 0)
                sCen = "cincuenta";
            else
                sCen = "cincuenta y ";
            break;
        case 6:
            if (dec == 0)
                sCen = "sesenta";
            else
                sCen = "sesenta y ";
            break;
        case 7:
            if (dec == 0)
                sCen = "setenta";
            else
                sCen = "setenta y ";
            break;
        case 8:
            if (dec == 0)
                sCen = "ochenta";
            else
                sCen = "ochenta y ";
            break;
        case 9:
            if (dec == 0)
                sCen = "noventa";
            else
                sCen = "noventa y ";
            break;
        default:
            sCen = "";
            break;
        }
    }

    if (len > 2) {
        mil = Integer.parseInt(sCant.substring(2, 3));
        switch (mil) {
        case 1:
            if (dec == 0 && cen == 0)
                sMil = "cien";
            else
                sMil = "ciento ";
            break;
        case 2:
            sMil = "doscientos ";
            break;
        case 3:
            sMil = "trescientos ";
            break;
        case 4:
            sMil = "cuatrocientos ";
            break;
        case 5:
            sMil = "quinientos ";
            break;
        case 6:
            sMil = "seiscientos ";
            break;
        case 7:
            sMil = "setecientos ";
            break;
        case 8:
            sMil = "ochocientos ";
            break;
        case 9:
            sMil = "novecientos ";
            break;
        default:
            sMil = "";
            break;
        }
    }

    if (len > 3) {
        diezmil = Integer.parseInt(sCant.substring(3, 4));
        switch (diezmil) {
        case 1:
            s10Mil = "un mil ";
            break;
        case 2:
            s10Mil = "dos mil ";
            break;
        case 3:
            s10Mil = "tres mil ";
            break;
        case 4:
            s10Mil = "cuatro mil ";
            break;
        case 5:
            s10Mil = "cinco mil ";
            break;
        case 6:
            s10Mil = "seis mil ";
            break;
        case 7:
            s10Mil = "siete mil ";
            break;
        case 8:
            s10Mil = "ocho mil ";
            break;
        case 9:
            s10Mil = "nueve mil ";
            break;
        default:
            s10Mil = "";
            break;
        }
    }

    if (len > 4) {
        cienmil = Integer.parseInt(sCant.substring(4, 5));
        switch (cienmil) {
        case 1:
            if (diezmil == 0)
                s100Mil = "diez mil ";
            else if (diezmil == 1) {
                s100Mil = "once mil ";
                s10Mil = "";
            } else if (diezmil == 2) {
                s100Mil = "doce mil ";
                s10Mil = "";
            } else if (diezmil == 3) {
                s100Mil = "trece mil ";
                s10Mil = "";
            } else if (diezmil == 4) {
                s100Mil = "catorce mil ";
                s10Mil = "";
            } else if (diezmil == 5) {
                s100Mil = "quince mil ";
                s10Mil = "";
            } else
                s100Mil = "dieci";
            break;
        case 2:
            if (diezmil == 0)
                s100Mil = "veinte mil ";
            else
                s100Mil = "veinti";
            break;
        case 3:
            if (diezmil == 0)
                s100Mil = "treinta mil";
            else
                s100Mil = "treinta y ";
            break;
        case 4:
            if (diezmil == 0)
                s100Mil = "cuarenta mil ";
            else
                s100Mil = "cuarenta y ";
            break;
        case 5:
            if (diezmil == 0)
                s100Mil = "cincuenta mil ";
            else
                s100Mil = "cincuenta y ";
            break;
        case 6:
            if (diezmil == 0)
                s100Mil = "sesenta mil ";
            else
                s100Mil = "sesenta y ";
            break;
        case 7:
            if (diezmil == 0)
                s100Mil = "setenta mil ";
            else
                s100Mil = "setenta y ";
            break;
        case 8:
            if (diezmil == 0)
                s100Mil = "ochenta mil ";
            else
                s100Mil = "ochenta y ";
            break;
        case 9:
            if (diezmil == 0)
                s100Mil = "noventa mil ";
            else
                s100Mil = "noventa y ";
            break;
        default:
            s100Mil = "";
            break;
        }
    }

    if (len > 5) {
        millon = Integer.parseInt(sCant.substring(5, 6));
        switch (millon) {
        case 1:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "cien mil ";
            else
                sMillon = "ciento ";
            break;
        case 2:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "doscientos mil ";
            else
                sMillon = "doscientos ";
            break;
        case 3:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "trescientos mil ";
            else
                sMillon = "trescientos ";
            break;
        case 4:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "cuatrocientos mil ";
            else
                sMillon = "cuatrocientos ";
            break;
        case 5:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "quinientos mil ";
            else
                sMillon = "quinientos ";
            break;
        case 6:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "seiscientos mil ";
            else
                sMillon = "seiscientos ";
            break;
        case 7:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "setecientos mil ";
            else
                sMillon = "setecientos ";
            break;
        case 8:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "ochocientos mil ";
            else
                sMillon = "ochocientos ";
            break;
        case 9:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "novecientos mil ";
            else
                sMillon = "novecientos ";
            break;
        default:
            sMillon = "";
            break;
        }
    }

    // millones
    if (len > 6) {
        diezmillon = Integer.parseInt(sCant.substring(6, 7));
        switch (diezmillon) {
        case 1:
            s10Millon = "un millon ";
            break;
        case 2:
            s10Millon = "dos millones ";
            break;
        case 3:
            s10Millon = "tres millones ";
            break;
        case 4:
            s10Millon = "cuatro millones ";
            break;
        case 5:
            s10Millon = "cinco millones ";
            break;
        case 6:
            s10Millon = "seis millones ";
            break;
        case 7:
            s10Millon = "siete millones ";
            break;
        case 8:
            s10Millon = "ocho millones ";
            break;
        case 9:
            s10Millon = "nueve millones ";
            break;
        default:
            s10Millon = "";
            break;
        }
    }

    if (len > 7) {
        cienmillon = Integer.parseInt(sCant.substring(7, 8));
        switch (cienmillon) {
        case 1:
            if (diezmillon == 0)
                s100Millon = "diez millones ";
            else if (diezmillon == 1) {
                s100Millon = "once millones ";
                s10Millon = "";
            } else if (diezmillon == 2) {
                s100Millon = "doce millones ";
                s10Millon = "";
            } else if (diezmillon == 3) {
                s100Millon = "trece millones ";
                s10Millon = "";
            } else if (diezmillon == 4) {
                s100Millon = "catorce millones ";
                s10Millon = "";
            } else if (diezmillon == 5) {
                s100Millon = "quince millones ";
                s10Millon = "";
            } else
                s100Millon = "dieci";
            break;
        case 2:
            if (diezmillon == 0)
                s100Millon = "veinte millones ";
            else
                s100Millon = "veinti";
            break;
        case 3:
            if (diezmillon == 0)
                s100Millon = "treinta millones ";
            else
                s100Millon = "treinta y ";
            break;
        case 4:
            if (diezmillon == 0)
                s100Millon = "cuarenta millones ";
            else
                s100Millon = "cuarenta y ";
            break;
        case 5:
            if (diezmillon == 0)
                s100Millon = "cincuenta millones ";
            else
                s100Millon = "cincuenta y ";
            break;
        case 6:
            if (diezmillon == 0)
                s100Millon = "sesenta millones ";
            else
                s100Millon = "sesenta y ";
            break;
        case 7:
            if (diezmillon == 0)
                s100Millon = "setenta millones ";
            else
                s100Millon = "setenta y ";
            break;
        case 8:
            if (diezmillon == 0)
                s100Millon = "ochenta millones ";
            else
                s100Millon = "ochenta y ";
            break;
        case 9:
            if (diezmillon == 0)
                s100Millon = "noventa millones ";
            else
                s100Millon = "noventa y ";
            break;
        default:
            s100Millon = "";
            break;
        }
        if (millon == 0 && cienmil == 0 && diezmil == 0 && mil == 0 && cen == 0 && dec == 0)
            s100Millon += "de";
    }

    if (len > 8) {
        milmillon = Integer.parseInt(sCant.substring(8, 9));
        switch (milmillon) {
        case 1:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "cien millones ";
            else
                s1000Millon = "ciento ";
            break;
        case 2:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "doscientos millones ";
            else
                s1000Millon = "doscientos ";
            break;
        case 3:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "trescientos millones ";
            else
                s1000Millon = "trescientos ";
            break;
        case 4:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "cuatrocientos millones ";
            else
                s1000Millon = "cuatrocientos ";
            break;
        case 5:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "quinientos millones ";
            else
                s1000Millon = "quinientos ";
            break;
        case 6:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "seiscientos millones ";
            else
                s1000Millon = "seiscientos ";
            break;
        case 7:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "setecientos millones ";
            else
                s1000Millon = "setecientos ";
            break;
        case 8:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "ochocientos millones ";
            else
                s1000Millon = "ochocientos ";
            break;
        case 9:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "novecientos millones ";
            else
                s1000Millon = "novecientos ";
            break;
        default:
            s1000Millon = "";
            break;
        }
    }

    String res = s1000Millon + s100Millon + s10Millon + sMillon + s100Mil + s10Mil + sMil + sCen + sDec;
    res += " " + MONEDA + " " + decim + " " + MN;

    //sCant.MakeUpper();

    return res;

}

From source file:com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement.java

/**
 * Sets the value of the {@code chOff} property.
 * @param chOff the value of the {@code chOff} property
 *///ww w. j  av a  2s  . c  om
protected void setChOff(String chOff) {
    try {
        final float f = Float.parseFloat(chOff);
        final int i = (int) f;
        if (i == f) {
            chOff = Integer.toString(i);
        } else {
            chOff = Float.toString(f);
        }
    } catch (final NumberFormatException e) {
        // Ignore.
    }
    getDomNodeOrDie().setAttribute("charOff", chOff);
}

From source file:neembuu.uploader.NeembuuUploader.java

/**
 * For peace of mind, the version number used for properties file,
 * version.xml and other stuf is Float.toString(version).
 * For display in user interface //from  w  ww .j a  v  a  2s. c  o m
 * @see #getVersionNumberForUI() 
 * @return version number for usage for non-ui part
 */
public static String getVersionForProgam() {
    return Float.toString(version);
}

From source file:neembuu.uploader.NeembuuUploader.java

static String getVersionNumber(float ver) {
    String v = "";
    int major = (int) ver;
    int minor = (int) ((ver * 10) - major * 10);
    String sub_minor = "";

    v = major + "." + minor;

    if (ver > major + minor * 0.1f) {
        sub_minor = Float.toString(ver);
        sub_minor = sub_minor.substring(sub_minor.indexOf(".") + 2);
        v = v + "." + sub_minor;
    }/*from   w  w w  . jav  a2 s . co  m*/

    return v;
}

From source file:com.example.sensingapp.SensingApp.java

public void recordSensingInfo(SensorData senData) {
    String sRecordLine;//from  w ww .ja  v a  2 s .  com
    String sTimeField;
    Date dtCurDate;
    int i;
    long lStartTime = 0;
    long lCurrentTime = 0;
    SimpleDateFormat spdRecordTime, spdCurDateTime;
    final String DATE_FORMAT = "yyyyMMddHHmmss";
    final String DATE_FORMAT_S = "yyMMddHHmmssSSS"; //"yyyyMMddHHmmssSSS"
    int nSensorReadingType = SENSOR_EVENT_NULL;
    int nSensorDataType;

    if (m_blnRecordStatus == false) { //Stopped
        return;
    }

    dtCurDate = new Date();

    // Timestamp for the record
    spdRecordTime = new SimpleDateFormat(DATE_FORMAT_S);
    sTimeField = spdRecordTime.format(dtCurDate);

    nSensorDataType = senData.getSensorDataType();

    if (nSensorDataType == DATA_TYPE_SENSOR) {
        SensorEvent event;

        event = senData.getSensorEvent();

        synchronized (this) {
            switch (event.sensor.getType()) {

            case Sensor.TYPE_ACCELEROMETER:
                //X, Y, Z
                if (m_blnAcclEnabled) {
                    m_sAccl = Float.toString(event.values[0]) + "," + Float.toString(event.values[1]) + ","
                            + Float.toString(event.values[2]) + ",";

                    nSensorReadingType = SENSOR_EVENT_ACCL;
                }

                //                   if (m_blnOrientEnabled) {
                //                      m_arrfAcclValues = event.values.clone();
                //                      
                //                      if (calculateOrientation()) {
                //                         //Azimuth (rotation around z-axis); Pitch (rotation around x-axis), Roll (rotation around y-axis)
                //                         m_sOrient = Float.toString(m_arrfOrientValues[0]) + "," + 
                //                                  Float.toString(m_arrfOrientValues[1]) + "," + 
                //                                  Float.toString(m_arrfOrientValues[2]) + ",";
                //                         
                //                         nSensorReadingType = SENSOR_EVENT_ORIENT;
                //                         
                //                      }
                //                   }
                break;

            case Sensor.TYPE_LINEAR_ACCELERATION:
                //X,Y,Z
                if (m_blnLinearAcclEnabled) {
                    m_sLinearAccl = Float.toString(event.values[0]) + "," + Float.toString(event.values[1])
                            + "," + Float.toString(event.values[2]) + ",";

                    nSensorReadingType = SENSOR_EVENT_LINEAR_ACCL;
                }

                break;

            case Sensor.TYPE_GRAVITY:
                //X,Y,Z
                if (m_blnGravityEnabled) {
                    m_sGravity = Float.toString(event.values[0]) + "," + Float.toString(event.values[1]) + ","
                            + Float.toString(event.values[2]) + ",";

                    nSensorReadingType = SENSOR_EVENT_GRAVITY;
                }

                break;

            case Sensor.TYPE_GYROSCOPE:
                //X,Y,Z
                m_sGyro = Float.toString(event.values[0]) + "," + Float.toString(event.values[1]) + ","
                        + Float.toString(event.values[2]) + ",";
                nSensorReadingType = SENSOR_EVENT_GYRO;
                break;

            case Sensor.TYPE_MAGNETIC_FIELD:
                // Values are in micro-Tesla (uT) and measure the ambient magnetic field 
                if (m_blnMagnetEnabled) {
                    m_sMagnet = Float.toString(event.values[0]) + "," + Float.toString(event.values[1]) + ","
                            + Float.toString(event.values[2]) + ",";

                    nSensorReadingType = SENSOR_EVENT_MAGNET;
                }

                //                   if (m_blnOrientEnabled) {
                //                      m_arrfMagnetValues = event.values.clone();
                //                      
                //                      if (calculateOrientation()) {
                //                         //Azimuth (rotation around z-axis); Pitch (rotation around x-axis), Roll (rotation around y-axis)
                //                         m_sOrient = Float.toString(m_arrfOrientValues[0]) + "," + 
                //                                  Float.toString(m_arrfOrientValues[1]) + "," + 
                //                                  Float.toString(m_arrfOrientValues[2]) + ",";
                //                                                  
                //                         if (nSensorReadingType != SENSOR_EVENT_MAGNET) {
                //                            nSensorReadingType = SENSOR_EVENT_ORIENT;
                //                         }
                //                      }
                //                   }

                break;

            case Sensor.TYPE_ROTATION_VECTOR: //Added on 20150910
                if (m_blnOrientEnabled) {
                    float[] arrfRotVal = new float[3];
                    float[] arrfR = new float[9];
                    float[] arrfValues = new float[3];

                    try {
                        System.arraycopy(event.values, 0, arrfRotVal, 0, event.values.length);
                    } catch (IllegalArgumentException e) {
                        //Hardcode the size to handle a bug on Samsung devices
                        System.arraycopy(event.values, 0, arrfRotVal, 0, 3);
                    }

                    SensorManager.getRotationMatrixFromVector(arrfR, arrfRotVal);
                    SensorManager.getOrientation(arrfR, arrfValues);

                    m_arrfOrientValues[0] = (float) Math.toDegrees(arrfValues[0]);
                    m_arrfOrientValues[1] = (float) Math.toDegrees(arrfValues[1]);
                    m_arrfOrientValues[2] = (float) Math.toDegrees(arrfValues[2]);

                    if (m_arrfOrientValues[0] < 0) {
                        m_arrfOrientValues[0] = m_arrfOrientValues[0] + 360; // Make Azimuth 0 ~ 360
                    }

                    //                      //Azimuth (rotation around z-axis); Pitch (rotation around x-axis), Roll (rotation around y-axis)
                    m_sOrient = Float.toString(m_arrfOrientValues[0]) + ","
                            + Float.toString(m_arrfOrientValues[1]) + ","
                            + Float.toString(m_arrfOrientValues[2]) + ",";

                    //m_tvGpsUp.setText(m_sOrient); //Show orientation
                    nSensorReadingType = SENSOR_EVENT_ORIENT;
                }

                break;

            case Sensor.TYPE_LIGHT:
                // Ambient light level in SI lux units 
                m_sLight = Float.toString(event.values[0]) + ",";
                nSensorReadingType = SENSOR_EVENT_LIGHT;
                break;

            case Sensor.TYPE_PRESSURE:
                // Atmospheric pressure in hPa (millibar)
                m_sBarometer = Float.toString(event.values[0]) + ",";
                nSensorReadingType = SENSOR_EVENT_BAROMETER;
                break;

            }
        }
    } else if (nSensorDataType == DATA_TYPE_GPS) {
        Location locationGps;
        locationGps = senData.getGpsLocation();

        if (locationGps != null) {

            m_location = new Location(locationGps);

            //Change from double to float
            m_sGPS = Float.valueOf((float) (locationGps.getLatitude())).toString() + ","
                    + Float.valueOf((float) (locationGps.getLongitude())).toString() + ",";
            if (locationGps.hasAltitude()) {
                m_sGPS = m_sGPS + Float.valueOf((float) (locationGps.getAltitude())).toString() + ",";
                GeomagneticField geoField = new GeomagneticField(
                        Double.valueOf(locationGps.getLatitude()).floatValue(),
                        Double.valueOf(locationGps.getLongitude()).floatValue(),
                        Double.valueOf(locationGps.getAltitude()).floatValue(), System.currentTimeMillis());
                // Append Declination, in Degree
                m_sGPS = m_sGPS + Float.valueOf((float) (geoField.getDeclination())).toString() + ","
                        + Float.valueOf((float) (geoField.getInclination())).toString() + ",";
            } else {
                m_sGPS = m_sGPS + ",,,";
                //m_sGPS = m_sGPS + ",";
            }

            //New add 201408270009
            if (locationGps.hasSpeed()) {
                m_sGPS = m_sGPS + Float.valueOf((float) (locationGps.getSpeed())).toString() + ",";
            } else {
                m_sGPS = m_sGPS + ",";
            }

            if (locationGps.hasBearing()) {
                m_sGPS = m_sGPS + Float.valueOf((float) (locationGps.getBearing())).toString() + ",";
            } else {
                m_sGPS = m_sGPS + ",";
            }

            nSensorReadingType = SENSOR_EVENT_GPS;

            m_blnGpsUp = true;
            show_screen5_GpsUp();
        } else {
            m_blnGpsUp = false;
            show_screen5_GpsUp();
        }
    } else if (nSensorDataType == DATA_TYPE_MIC) {
        double fSoundLevelDb;
        fSoundLevelDb = senData.getSoundLevelDb();
        m_sSouldLevel = new BigDecimal(fSoundLevelDb).setScale(0, BigDecimal.ROUND_HALF_UP) + ",";

        nSensorReadingType = SENSOR_EVENT_MIC;

    } else if (nSensorDataType == DATA_TYPE_CELLULAR) {
        int nCellId;
        nCellId = senData.getCellId();
        m_sCellId = Integer.valueOf(nCellId).toString() + ",";
        nSensorReadingType = SENSOR_EVENT_CELLULAR;

    } else if (nSensorDataType == DATA_TYPE_WIFI) {
        List<WifiData> lstWifiData = senData.getListWifiData();
        int nWifiCnt = Math.min(WIFI_COUNT, lstWifiData.size());
        m_sWifi = "";
        for (i = 0; i < nWifiCnt; i++) {
            //m_sWifi = m_sWifi + lstWifiData.get(i).getSSID() + "," + lstWifiData.get(i).getBSSID() + "," + lstWifiData.get(i).getSignalLevel() + ",";
            m_sWifi = m_sWifi + lstWifiData.get(i).getBSSID() + "," + lstWifiData.get(i).getSignalLevel() + ",";

        }

        for (i = 1; i <= WIFI_COUNT - nWifiCnt; i++) {
            //m_sWifi = m_sWifi + ",,,";
            m_sWifi = m_sWifi + ",,";
        }

        nSensorReadingType = SENSOR_EVENT_WIFI;
    }

    if (nSensorReadingType == SENSOR_EVENT_NULL) {
        return;
    }

    sRecordLine = sTimeField + ",";

    if (m_blnNoLabel == false) {
        sRecordLine = sRecordLine + m_sCurrentLabel + ",";
    }

    sRecordLine = sRecordLine + Integer.valueOf(nSensorReadingType) + ",";

    //New: Every field always there
    //Field in each line:
    /*
     *  1) Timestamp
     *  2) Label
     *  3) SensingEventType
     *  4-6) Accl
     *  7-9) Linear Accl
     *  10-12) Gravity
     *  13-15) Gyro
     *  16-18) Orientation
     *  19-21) Magnet
     *  22) Light
     *  23) Barometer
     *  24) Sould Level (Decibel)
     *  25) Cell ID
     *  26-32) GPS (Lat, Long, Alt, Declination, Inclination, Speed, Bearing)
     *  33-72) WiFi (<BSSID, Level>) 
     */
    //      sRecordLine = sRecordLine  + m_sAccl + m_sGyro + m_sOrient + m_sMagnet + 
    //                           m_sLight + m_sBarometer +  
    //                           m_sSouldLevel + m_sCellId +
    //                           m_sGPS + m_sWifi;

    sRecordLine = sRecordLine + m_sAccl + m_sLinearAccl + m_sGravity + m_sGyro + m_sOrient + m_sMagnet
            + m_sLight + m_sBarometer + m_sSouldLevel + m_sCellId + m_sGPS + m_sWifi;

    ////////////////////////////
    //      String sAngle = calculateRot(m_sAccl, m_sGravity);
    //      String sarrAngle[] = sAngle.split(",");
    //      String sShow = sarrAngle[0] + "\n" + sarrAngle[1];

    //      String sShow = "";

    //      if (m_sGravity.length() > 3) {
    //         String sarrAngle[] = m_sGravity.split(",");
    //         double fX = Double.valueOf(sarrAngle[0]).doubleValue();
    //         double fY = Double.valueOf(sarrAngle[1]).doubleValue();
    //         double fZ = Double.valueOf(sarrAngle[2]).doubleValue();
    //         
    //         double fTotal = Math.sqrt(fX*fX + fY*fY + fZ*fZ);
    //         
    //         double fAngleZ = Math.acos(fZ/fTotal)/Math.PI*180;
    //         double fAngleY = 90 - Math.acos(fY/fTotal)/Math.PI*180;
    //         double fAngleX = 90 - Math.acos(fX/fTotal)/Math.PI*180;
    //         
    //         sShow = "X:  " +  fAngleX + "\n";
    //         sShow = sShow + "Y:  " +  fAngleY + "\n";
    //         sShow = sShow + "Z:  " +  fAngleZ;
    //         
    //                     
    //      }

    //      if (m_sGravity.length() > 3) {
    //         String sarrAngle[] = m_sGravity.split(",");
    //         double fX = Double.valueOf(sarrAngle[0]).doubleValue();
    //         double fY = Double.valueOf(sarrAngle[1]).doubleValue();
    //         double fZ = Double.valueOf(sarrAngle[2]).doubleValue();
    //         
    //         int nSymbol = 0;
    //         if (fX < 0)  {
    //            sShow = sShow + "- X" + "\n";
    //         } else if (fX > 0) {
    //            sShow = sShow + "+ X" + "\n";
    //         }
    //         
    //         if (fY < 0)  {
    //            sShow = sShow + "- Y" + "\n";
    //         } else if (fY > 0) {
    //            sShow = sShow + "+ Y" + "\n";
    //         }
    //         
    //         if (fZ < 0)  {
    //            sShow = sShow + "- Z";
    //         } else if (fZ > 0) {
    //            sShow = sShow + "+ Z";
    //         }
    //                     
    //      }
    //      
    //      if (m_sGyro.length() > 3) {
    //         String sarrAngle[] = m_sGyro.split(",");
    //         double fX = Double.valueOf(sarrAngle[0]).doubleValue();
    //         double fY = Double.valueOf(sarrAngle[1]).doubleValue();
    //         double fZ = Double.valueOf(sarrAngle[2]).doubleValue();
    //         
    //         int nSymbol = 0;
    //         if (fX < 0)  {
    //            nSymbol = -1;
    //         } else if (fX > 0) {
    //            nSymbol = 1;
    //         }
    //         
    //         if (fY < 0)  {
    //            nSymbol = nSymbol + (-1);
    //         } else if (fY > 0) {
    //            nSymbol = nSymbol + 1;
    //         }
    //         
    //         if (fZ < 0)  {
    //            nSymbol = nSymbol + (-1);
    //         } else if (fZ > 0) {
    //            nSymbol = nSymbol + 1;
    //         }
    //            
    //         if (nSymbol < 0) {
    //            nSymbol = -1;
    //         } else if (nSymbol > 0) {
    //            nSymbol = 1;
    //         }
    //         
    //         sShow = sShow + "\n\n" + nSymbol + "";
    //      }

    //      m_tvSensingInfo.setText(sShow);
    ////////////////////////////

    sRecordLine = sRecordLine + System.getProperty("line.separator");

    if (m_fwSensorRecord != null) {
        //Write information into file
        //Compose information into recordLine
        try {
            m_fwSensorRecord.write(sRecordLine);
        } catch (IOException e) {

        }
    }

}

From source file:com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.java

/**
 * Gets the {@code opacity} style attribute.
 * @return the style attribute/* w w w.j  ava  2  s  .  c  om*/
 */
@JsxGetter({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(IE) })
public String getOpacity() {
    final String opacity = getStyleAttribute(OPACITY);
    if (opacity == null || opacity.isEmpty()) {
        return "";
    }

    final String trimedOpacity = opacity.trim();
    try {
        final float value = Float.parseFloat(trimedOpacity);
        if (value % 1 == 0) {
            return Integer.toString((int) value);
        }
        return Float.toString(value);
    } catch (final NumberFormatException e) {
        // ignore wrong value
    }
    return "";
}

From source file:es.bsc.servicess.ide.editors.deployers.LicenseTokensTableComposite.java

/**
 * Load a Cost description//from w w  w .j  a  v a2 s .  c om
 * @param number Number of the Cost description
 */
private void loadCostSection(int number) {
    String[] totalEls = getAllPackages();
    String[] selectedEls = ManifestCreation.getPackageNames(
            manifest.getTRECSection().getCostSectionArray(number).getScope().getComponentIdArray());
    cost_scope.setPackagesLists(totalEls, selectedEls);
    if (manifest.getTRECSection().getCostSectionArray(number).getPricePlanArray(0).getPlanCap() > 0)
        cost_cap.setText(Float.toString(
                manifest.getTRECSection().getCostSectionArray(number).getPricePlanArray(0).getPlanCap()));
    else
        cost_cap.setText("");
    if (manifest.getTRECSection().getCostSectionArray(number).getPricePlanArray(0).getCurrency() != null)
        currency.setText(
                manifest.getTRECSection().getCostSectionArray(number).getPricePlanArray(0).getCurrency());
    else
        currency.setText("");
    enableCostDetails(true);
}

From source file:com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.java

/**
 * Sets the style attribute which should be treated as an integer in pixels.
 * @param name the attribute name// w  w w. j a v  a2 s  .  co m
 * @param value the attribute value
 */
protected void setStyleAttributePixel(final String name, String value) {
    if (value.endsWith("px")) {
        value = value.substring(0, value.length() - 2);
    }
    try {
        final float floatValue = Float.parseFloat(value);
        if (floatValue % 1 == 0) {
            value = Integer.toString((int) floatValue) + "px";
        } else {
            value = Float.toString(floatValue) + "px";
        }
    } catch (final Exception e) {
        //ignore
    }
    setStyleAttribute(name, value);
}