Example usage for java.lang Float isNaN

List of usage examples for java.lang Float isNaN

Introduction

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

Prototype

public static boolean isNaN(float v) 

Source Link

Document

Returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.

Usage

From source file:com.google.blockly.model.FieldAngle.java

/**
 * Set the current angle in this field. The angle will be wrapped to be in the range
 * 0-360.//from   w  w w .  j a v  a  2  s.co m
 *
 * @param angle The angle to set this field to.
 */
public void setAngle(float angle) {
    if (Float.isNaN(angle)) {
        return;
    }
    angle = angle % 360;
    if (angle < 0) {
        angle += 360;
    }
    if (angle > WRAP_ANGLE) {
        angle -= 360;
    }

    if (angle != mAngle) {
        String oldValue = getSerializedValue();
        mAngle = angle;
        String newValue = getSerializedValue();
        fireValueChanged(oldValue, newValue);
    }
}

From source file:cn.goodjobs.common.view.photodraweeview.ScaleDragDetector.java

@Override
public boolean onScale(ScaleGestureDetector detector) {
    float scaleFactor = detector.getScaleFactor();

    if (Float.isNaN(scaleFactor) || Float.isInfinite(scaleFactor)) {
        return false;
    }//from   w  ww .  j  a  va2  s.  c  o m

    mScaleDragGestureListener.onScale(scaleFactor, detector.getFocusX(), detector.getFocusY());
    return true;
}

From source file:org.broad.igv.data.ProcessingUtils.java

private static float computeMin(float[] data) {
    float min = Float.MAX_VALUE;
    for (int i = 0; i < data.length; i++) {
        if (!Float.isNaN(data[i])) {
            min = Math.min(data[i], min);
        }/*from   www.j a va2  s  .co m*/
    }
    return min;
}

From source file:eu.itesla_project.modelica_export.records.LoadRecord.java

public LoadRecord(Load load, ConnectBusInfo busInfo, float SNREF, SourceEngine sourceEngine) {
    this.load = load;
    this.busInfo = busInfo;
    this.loadId = load.getId();
    this.busConnected = busInfo.isConnected();
    this.p0 = this.load.getP0();
    this.q0 = this.load.getQ0();
    this.busVoltage = Float.NaN;
    this.busAngle = Float.NaN;
    this.sourceEngine = sourceEngine;

    if (this.busConnected) {
        if (load.getTerminal().getBusView().getBus() != null) {
            if (!Float.isNaN(load.getTerminal().getBusView().getBus().getV()))
                busVoltage = load.getTerminal().getBusView().getBus().getV()
                        / load.getTerminal().getVoltageLevel().getNominalV();

            if (!Float.isNaN(load.getTerminal().getBusView().getBus().getAngle()))
                busAngle = load.getTerminal().getBusView().getBus().getAngle();
        }// w ww.  j  a  va  2s . com

        addLfParameters();
    } else {
        _log.warn("Load " + this.getModelicaName() + " disconnected.");
        this.addValue(StaticData.COMMENT + " Load " + this.getModelicaName() + " disconnected.");
    }

    if (this.busVoltage == 0) {
        _log.info("Voltage 0");
    }
}

From source file:fr.amap.lidar.amapvox.voxelisation.postproc.MultiBandRaster.java

public static BSQ computeRaster(float startingHeight, float step, int bandNumber, int resolution,
        VoxelSpaceInfos infos, Voxel[][][] voxels, Raster dtm) {

    float[] altitudes = new float[bandNumber];
    for (int i = 0; i < bandNumber; i++) {
        altitudes[i] = startingHeight + (i * step);
    }/* w  w w  . j a  va 2  s.  co m*/

    float scale = (float) (resolution / infos.getResolution());

    int rasterXSize = (int) (Math.ceil(infos.getSplit().x / scale));
    int rasterYSize = (int) (Math.ceil(infos.getSplit().y / scale));

    BHeader header = new BHeader(rasterXSize, rasterYSize, altitudes.length, BCommon.NumberOfBits.N_BITS_32);
    header.setUlxmap(infos.getMinCorner().x + (resolution / 2.0f));
    header.setUlymap(infos.getMinCorner().y - (infos.getResolution() / 2.0f)
            + (infos.getSplit().y * infos.getResolution()));
    header.setXdim(resolution);
    header.setYdim(resolution);

    BSQ raster = new BSQ(null, header);

    Statistic[][][] padMean = new Statistic[rasterXSize][rasterYSize][altitudes.length];

    if (dtm != null) {

        if (altitudes.length > 0) {

            float altitudeMin = altitudes[0];

            for (int i = 0; i < infos.getSplit().x; i++) {
                for (int j = infos.getSplit().y - 1; j >= 0; j--) {
                    for (int k = 0; k < infos.getSplit().z; k++) {

                        Voxel vox = voxels[i][j][k];

                        //on calcule l'indice de la couche auquel appartient le voxel
                        if (vox != null && vox.ground_distance > altitudeMin) {
                            int layer = (int) ((vox.ground_distance - altitudeMin) / step);

                            if (layer < altitudes.length) {

                                int indiceI = (int) (i / scale);
                                int indiceJ = (int) (j / scale);

                                if (padMean[indiceI][indiceJ][layer] == null) {
                                    padMean[indiceI][indiceJ][layer] = new Statistic();
                                }

                                if (!Float.isNaN(vox.PadBVTotal)) {
                                    padMean[indiceI][indiceJ][layer].addValue(vox.PadBVTotal);
                                }
                            }
                        }
                    }
                }
            }

            long l = 4294967295L;

            try {
                //on crit la moyenne
                for (int i = 0; i < rasterXSize; i++) {
                    for (int j = rasterYSize - 1, j2 = 0; j >= 0; j--, j2++) {
                        for (int k = 0; k < altitudes.length; k++) {

                            if (padMean[i][j][k] != null) {

                                double meanPAD = padMean[i][j][k].getMean();
                                //float value = (meanOfPAD-0)/(MAX_PAD-0);

                                long value = (long) ((meanPAD / (double) infos.getMaxPAD()) * (l));
                                String binaryString = Long.toBinaryString(value);
                                byte[] bval = new BigInteger(binaryString, 2).toByteArray();
                                ArrayUtils.reverse(bval);
                                byte b0 = 0x0, b1 = 0x0, b2 = 0x0, b3 = 0x0;
                                if (bval.length > 0) {
                                    b0 = bval[0];
                                }
                                if (bval.length > 1) {
                                    b1 = bval[1];
                                }
                                if (bval.length > 2) {
                                    b2 = bval[2];
                                }
                                if (bval.length > 3) {
                                    b3 = bval[3];
                                }
                                raster.setPixel(i, j2, k, b0, b1, b2, b3);

                            }
                        }
                    }
                }

            } catch (Exception ex) {
                LOGGER.error(ex);
            }
        }

    }

    return raster;
}

From source file:org.akvo.caddisfly.sensor.colorimetry.strip.widget.PercentageMeterView.java

@Override
public void onDraw(@NonNull Canvas canvas) {

    if (Float.isNaN(percentage)) {
        return;/*  w w w.j ava  2 s  .c  o m*/
    }

    double number = (100 - percentage) * NUMBER_OF_BARS * PERCENT;

    canvas.save();

    // Set each dot's diameter to half the canvas height
    canvas.translate(
            canvas.getWidth() / 2f - ((canvas.getHeight() / 2f + GUTTER_SPACE) * ((NUMBER_OF_BARS - 1) / 2f)),
            0);

    for (double i = 0; i < NUMBER_OF_BARS; i++) {

        // Reset color
        paint.setColor(Color.LTGRAY);

        if (number >= 0) {
            if (i < 2) {
                // Red if number is lower than i + 1
                // 2 red dots if number < 1 or 1 red dot if number > 1
                if (number <= i + 1) {
                    paint.setColor(red);
                }
            } else if (i < 4) {
                // Orange if number between 1 and 4
                // if number == 1.5 then 1 red followed by orange dot
                // if number == 2.5 then 2 orange dots
                // if number == 3.5 then 1 orange dot
                if (number >= i - 1 && number <= i + 2) {
                    paint.setColor(orange);
                }
            } else {
                if (number > i) {
                    // Green if number larger than 3 but yellow if number exceeds optimum
                    if (number > NUMBER_OF_BARS) {
                        paint.setColor(Color.YELLOW);
                    } else {
                        paint.setColor(green);
                    }
                }
            }
        }

        canvas.drawCircle(0, canvas.getHeight() / 2f, canvas.getHeight() / 4f, paint);

        // Position next circle
        canvas.translate(canvas.getHeight() / 2f + GUTTER_SPACE, 0);
    }

    canvas.restore();

    super.onDraw(canvas);
}

From source file:org.bitpipeline.lib.owm.LocalizedWeatherData.java

public boolean hasDistance() {
    return !Float.isNaN(this.distance);
}

From source file:juicebox.matrix.SymmetricMatrix.java

public float getColumnMean(int j) {
    float sum = 0;
    int count = 0;
    for (int i = 0; i < dim; i++) {
        float value = getEntry(i, j);
        if (!Float.isNaN(value)) {
            sum += value;// w  w  w .  ja  va2s. co m
            count++;
        }
    }
    return count == 0 ? Float.NaN : sum / count;
}

From source file:de.metanome.algorithm_integration.ColumnConditionAnd.java

@Override
public float getCoverage() {
    if (Float.isNaN(this.coverage)) {
        float coverage = Float.MAX_VALUE;
        for (ColumnCondition subCondition : this.columnValues) {
            if (coverage > subCondition.getCoverage()) {
                coverage = subCondition.getCoverage();
            }//from   ww w. j  a  v  a2s.  com
        }
        return coverage;
    } else {
        return this.coverage;
    }
}

From source file:org.broad.igv.data.ProcessingUtils.java

private static float computeMax(float[] data) {
    float max = -Float.MAX_VALUE;
    for (int i = 0; i < data.length; i++) {
        if (!Float.isNaN(data[i])) {
            max = Math.max(data[i], max);
        }// www  . java  2 s. c  o m
    }
    return max;
}