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:org.caleydo.view.bicluster.elem.GLRootElement.java

private static List<Integer> findBestColumns(Integer col, TablePerspective t) {
    final VirtualArray va = t.getRecordPerspective().getVirtualArray();
    List<IntFloat> tmp = new ArrayList<>(va.size());
    final int max = MyPreferences.getMaxNumberofGOs();
    final float pMax = MyPreferences.getMaximalGOPValue();
    final Table table = t.getDataDomain().getTable();
    for (Integer rec : va) {
        final Number n = (Number) table.getRaw(col, rec);
        if (n == null)
            continue;
        float p = n.floatValue();
        if (p > pMax || Float.isNaN(p))
            continue;
        tmp.add(new IntFloat(rec, p));
    }//from w ww. j av  a 2  s  .co  m
    Collections.sort(tmp, IntFloat.BY_MEMBERSHIP);
    List<Integer> top = Lists.transform(tmp, IntFloat.TO_INDEX);
    if (max < tmp.size())
        return top.subList(0, max);
    return top;
}

From source file:com.granita.tasks.EditTaskFragment.java

@SuppressLint("NewApi")
private void updateColor(float percentage) {
    if (VERSION.SDK_INT >= 11) {
        if (mColorBar == null) {
            percentage = 1;//from   www  . ja  v  a 2 s .co m
        } else {
            percentage = Math.max(0, Math.min(Float.isNaN(percentage) ? 0 : percentage, 1));
        }

        int newColor = getBlendColor(mListColor, darkenColor(mListColor),
                (int) ((0.5 + 0.5 * percentage) * 255));
        ActionBar actionBar = ((ActionBarActivity) getActivity()).getSupportActionBar();
        actionBar.setBackgroundDrawable(new ColorDrawable(newColor));

        // this is a workaround to ensure the new color is applied on all devices, some devices show a transparent ActionBar if we don't do that.
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayShowTitleEnabled(true);

        if (VERSION.SDK_INT >= 21) {
            Window window = getActivity().getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(mixColors(newColor, mListColor));
            // window.setNavigationBarColor(mixColors(newColor, mListColor));
        }
    }
    mTaskListBar.setBackgroundColor(mListColor);
    if (mColorBar != null) {
        mColorBar.setBackgroundColor(mListColor);
    }
}

From source file:routines.system.BigDataParserUtils.java

public static Long parseTo_Long(float input) {
    if (Float.isNaN(input)) {
        return null;
    }/*w w  w . ja  va2 s.  co  m*/
    return ((Float) input).longValue();
}

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

public void setParameters(boolean isInyection, float SNREF) {
    IIDMParameter parameter;/*  ww  w.  j a  va2  s  .c o  m*/
    iidmgenParameters = new ArrayList<IIDMParameter>();
    float voltage = 0;
    float angle = 0;

    if (generator.getTerminal().getBusView().getBus() != null) {
        if (!Float.isNaN(generator.getTerminal().getBusView().getBus().getV())) {
            voltage = generator.getTerminal().getBusView().getBus().getV();
        }
        if (!Float.isNaN(generator.getTerminal().getBusView().getBus().getAngle())) {
            angle = generator.getTerminal().getBusView().getBus().getAngle();
        }
    }
    if (this.sourceEngine instanceof EurostagEngine) {
        if (!isInyection) {
            parameter = new IIDMParameter(StaticData.SNREF, StaticData.SNREF);
            this.iidmgenParameters.add(parameter);
            addParamInMap(parameter.getName(), parameter.getValue().toString());

            float modulo = voltage / generator.getTerminal().getVoltageLevel().getNominalV();
            float angulo = (float) (angle * Math.PI / 180);

            double ur0 = modulo * Math.cos(angulo);
            double ui0 = modulo * Math.sin(angulo);

            parameter = new IIDMParameter(EurostagFixedData.UR0, ur0);
            this.iidmgenParameters.add(parameter);
            addParamInMap(parameter.getName(), parameter.getValue().toString());

            parameter = new IIDMParameter(EurostagFixedData.UI0, ui0);
            this.iidmgenParameters.add(parameter);
            addParamInMap(parameter.getName(), parameter.getValue().toString());
        } else {
            parameter = new IIDMParameter(EurostagFixedData.V_0,
                    voltage / generator.getTerminal().getVoltageLevel().getNominalV());
            this.iidmgenParameters.add(parameter);
            addParamInMap(parameter.getName(), parameter.getValue().toString());

            parameter = new IIDMParameter(EurostagFixedData.ANGLE_0, angle);
            this.iidmgenParameters.add(parameter);
            addParamInMap(parameter.getName(), parameter.getValue().toString());

            //Before 2015-05-28 the sign of pelec and qelec was not changed but now we change the sign.
            float pelec = -this.generator.getTerminal().getP() / SNREF;
            parameter = new IIDMParameter(EurostagFixedData.P, pelec);
            this.iidmgenParameters.add(parameter);
            addParamInMap(parameter.getName(), parameter.getValue().toString());

            float qelec = -this.generator.getTerminal().getQ() / SNREF;
            parameter = new IIDMParameter(EurostagFixedData.Q, qelec);
            this.iidmgenParameters.add(parameter);
            addParamInMap(parameter.getName(), parameter.getValue().toString());
        }
    } else if (this.sourceEngine instanceof PsseEngine) {
        if (!isInyection) {
            parameter = new IIDMParameter(PsseFixedData.V_0,
                    voltage / generator.getTerminal().getVoltageLevel().getNominalV());
            this.iidmgenParameters.add(parameter);
            addParamInMap(parameter.getName(), parameter.getValue().toString());

            parameter = new IIDMParameter(PsseFixedData.ANGLE_0, angle);
            this.iidmgenParameters.add(parameter);
            addParamInMap(parameter.getName(), parameter.getValue().toString());

            //Before 2015-05-28 the sign of pelec and qelec was not changed but now we change the sign.
            float pelec = -this.generator.getTerminal().getP();
            parameter = new IIDMParameter(PsseFixedData.P_0, pelec);
            this.iidmgenParameters.add(parameter);
            addParamInMap(parameter.getName(), parameter.getValue().toString());

            float qelec = -this.generator.getTerminal().getQ();
            parameter = new IIDMParameter(PsseFixedData.Q_0, qelec);
            this.iidmgenParameters.add(parameter);
            addParamInMap(parameter.getName(), parameter.getValue().toString());

            double mbase = this.generator.getRatedS();
            double refValue = Math.sqrt(Math.pow(pelec, 2) + Math.pow(qelec, 2));
            if (mbase <= refValue) {
                mbase = 1.1 * refValue;
                changedMbse = true;
            }
            parameter = new IIDMParameter(PsseFixedData.M_b, mbase);
            this.iidmgenParameters.add(parameter);
            addParamInMap(parameter.getName(), parameter.getValue().toString());
        } else {
            parameter = new IIDMParameter(PsseFixedData.V_0,
                    voltage / generator.getTerminal().getVoltageLevel().getNominalV());
            this.iidmgenParameters.add(parameter);
            addParamInMap(parameter.getName(), parameter.getValue().toString());

            parameter = new IIDMParameter(PsseFixedData.ANGLE_0, angle);
            this.iidmgenParameters.add(parameter);
            addParamInMap(parameter.getName(), parameter.getValue().toString());

            //Before 2015-05-28 the sign of pelec and qelec was not changed but now we change the sign.
            float pelec = -this.generator.getTerminal().getP();
            parameter = new IIDMParameter(PsseFixedData.P_0, pelec);
            this.iidmgenParameters.add(parameter);
            addParamInMap(parameter.getName(), parameter.getValue().toString());

            float qelec = -this.generator.getTerminal().getQ();
            parameter = new IIDMParameter(PsseFixedData.Q_0, qelec);
            this.iidmgenParameters.add(parameter);
            addParamInMap(parameter.getName(), parameter.getValue().toString());
        }
    }
}

From source file:com.tmall.wireless.tangram3.dataparser.concrete.Card.java

public void storeAspectRatio() {
    if (style != null && !Float.isNaN(style.aspectRatio)) {
        mTmpAspectRatio = style.aspectRatio;
        style.aspectRatio = Float.NaN;
    }/*ww w  .  ja va  2  s.  co  m*/
}

From source file:org.apache.drill.exec.physical.impl.common.HashTableTemplate.java

@Override
public void setup(HashTableConfig htConfig, BufferAllocator allocator, VectorContainer incomingBuild,
        RecordBatch incomingProbe, RecordBatch outgoing, VectorContainer htContainerOrig,
        FragmentContext context, ClassGenerator<?> cg) {
    float loadf = htConfig.getLoadFactor();
    int initialCap = htConfig.getInitialCapacity();

    if (loadf <= 0 || Float.isNaN(loadf)) {
        throw new IllegalArgumentException("Load factor must be a valid number greater than 0");
    }//from w  w w . j  ava2 s  .  c om
    if (initialCap <= 0) {
        throw new IllegalArgumentException("The initial capacity must be greater than 0");
    }
    if (initialCap > MAXIMUM_CAPACITY) {
        throw new IllegalArgumentException("The initial capacity must be less than maximum capacity allowed");
    }

    if (htConfig.getKeyExprsBuild() == null || htConfig.getKeyExprsBuild().size() == 0) {
        throw new IllegalArgumentException("Hash table must have at least 1 key expression");
    }

    this.htConfig = htConfig;
    this.allocator = allocator;
    this.incomingBuild = incomingBuild;
    this.incomingProbe = incomingProbe;
    this.outgoing = outgoing;
    this.htContainerOrig = htContainerOrig;
    this.context = context;
    this.cg = cg;
    this.allocationTracker = new HashTableAllocationTracker(htConfig);

    // round up the initial capacity to nearest highest power of 2
    tableSize = roundUpToPowerOf2(initialCap);
    if (tableSize > MAXIMUM_CAPACITY) {
        tableSize = MAXIMUM_CAPACITY;
    }
    originalTableSize = tableSize; // retain original size

    threshold = (int) Math.ceil(tableSize * loadf);

    dummyIntField = MaterializedField.create("dummy", Types.required(MinorType.INT));

    startIndices = allocMetadataVector(tableSize, EMPTY_SLOT);

    // Create the first batch holder
    batchHolders = new ArrayList<BatchHolder>();
    // First BatchHolder is created when the first put request is received.

    prevIndexSize = 0;
    currentIndexSize = 0;
    totalIndexSize = 0;

    try {
        doSetup(incomingBuild, incomingProbe);
    } catch (SchemaChangeException e) {
        throw new IllegalStateException("Unexpected schema change", e);
    }

    currentIdxHolder = new IndexPointer();
}

From source file:edu.tum.cs.vis.model.util.algorithm.ACCUM.java

/**
 * Compute a "typical scale" for the mesh: computed as 1% of the reciprocal of the 10-th
 * percentile curvature/*from w  w  w. j a  v a2s .c o m*/
 * 
 * @param curvatures
 *            Curvature values for each vertex
 * @param m
 *            main model
 * @return typical scale value for the mesh
 */
private static float typical_scale(HashMap<Vertex, Curvature> curvatures, Model m) {
    float frac = 0.1f;
    float mult = 0.01f;

    int nv = m.getVertices().size();
    int nsamp = Math.min(nv, 500);
    if (nsamp == 0)
        return 0;

    float samples[] = new float[nsamp * 2];
    int idx = 0;
    for (int i = 0; i < nsamp; i++) {
        int ind = (int) (Math.random() * nv);

        samples[idx++] = Math.abs(curvatures.get(m.getVertices().get(ind)).getCurvatureMax());
        samples[idx++] = Math.abs(curvatures.get(m.getVertices().get(ind)).getCurvatureMin());
    }

    int which = (int) (frac * samples.length);
    Arrays.sort(samples);

    float f = 0;
    if (samples[which] == 0.0f || Float.isNaN(samples[which])) {
        f = mult * m.getBoundingSphere().getR();
        // logger.warn("Couldn't determine typical scale. Using bsphere value: " + f + ".");
    } else {
        f = mult / samples[which];
    }
    return f;
}

From source file:com.tmall.wireless.tangram3.dataparser.concrete.Card.java

public void restoreAspectRatio() {
    if (style != null && !Float.isNaN(mTmpAspectRatio)) {
        style.aspectRatio = mTmpAspectRatio;
    }
}

From source file:com.androzic.location.LocationService.java

private void updateLocation() {
    final Location location = lastKnownLocation;
    final boolean continous = isContinous;
    final boolean geoid = !Float.isNaN(nmeaGeoidHeight);
    final float smoothspeed = smoothSpeed;
    final float avgspeed = avgSpeed;

    final Handler handler = new Handler();

    if (trackingEnabled) {
        handler.post(new Runnable() {
            @Override//w  w  w  .j a v  a2s. com
            public void run() {
                writeTrack(location, continous, geoid, smoothspeed, avgspeed);
            }
        });
    }
    for (final ILocationListener callback : locationCallbacks) {
        handler.post(new Runnable() {
            @Override
            public void run() {
                callback.onLocationChanged(location, continous, geoid, smoothspeed, avgspeed);
            }
        });
    }
    final int n = locationRemoteCallbacks.beginBroadcast();
    for (int i = 0; i < n; i++) {
        final ILocationCallback callback = locationRemoteCallbacks.getBroadcastItem(i);
        try {
            callback.onLocationChanged(location, continous, geoid, smoothspeed, avgspeed);
        } catch (RemoteException e) {
            Log.e(TAG, "Location broadcast error", e);
        }
    }
    locationRemoteCallbacks.finishBroadcast();
    Log.d(TAG, "Location dispatched: " + (locationCallbacks.size() + n));
}

From source file:routines.system.BigDataParserUtils.java

public static long parseTo_long(float input) {
    if (Float.isNaN(input)) {
        return defaultValueLong;
    }/*from www .  j  a v  a2 s.com*/
    return ((Float) input).longValue();
}