Example usage for java.lang Float MAX_VALUE

List of usage examples for java.lang Float MAX_VALUE

Introduction

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

Prototype

float MAX_VALUE

To view the source code for java.lang Float MAX_VALUE.

Click Source Link

Document

A constant holding the largest positive finite value of type float , (2-2-23)·2127.

Usage

From source file:com.datastax.hectorjpa.spring.ConsistencyLevelAspect.java

/**
 * Get the closest match to our method. Will check inheritance as well as
 * overloading/*from   w  w  w  . ja v a 2 s .c  o m*/
 * 
 * @param target
 * @param methodName
 * @param paramTypes
 * @return
 */
private Method getMatchingAccessibleMethod(Class<?> clazz, String methodName, Class<?>[] parameterTypes) {

    // search through all methods
    int paramSize = parameterTypes.length;
    Method bestMatch = null;
    Method[] methods = clazz.getMethods();
    float bestMatchCost = Float.MAX_VALUE;
    float myCost = Float.MAX_VALUE;
    for (int i = 0, size = methods.length; i < size; i++) {
        if (methods[i].getName().equals(methodName)) {

            // compare parameters
            Class<?>[] methodsParams = methods[i].getParameterTypes();
            int methodParamSize = methodsParams.length;
            if (methodParamSize == paramSize) {
                boolean match = true;
                for (int n = 0; n < methodParamSize; n++) {

                    if (!MethodUtils.isAssignmentCompatible(methodsParams[n], parameterTypes[n])) {

                        match = false;
                        break;
                    }
                }

                if (match) {
                    // get accessible version of method
                    Method method = MethodUtils.getAccessibleMethod(clazz, methods[i]);
                    if (method != null) {

                        myCost = getTotalTransformationCost(parameterTypes, method.getParameterTypes());
                        if (myCost < bestMatchCost) {
                            bestMatch = method;
                            bestMatchCost = myCost;
                        }
                    }

                }
            }
        }
    }

    return bestMatch;
}

From source file:edu.umn.cs.spatialHadoop.visualization.FrequencyMap.java

public BufferedImage asImage() {
    if (min >= max) {
        // Values not set. Autodetect
        min = Float.MAX_VALUE;
        max = -Float.MAX_VALUE;//from   w w  w .  j a va  2  s. c  o  m
        for (int x = 0; x < this.getWidth(); x++) {
            for (int y = 0; y < this.getHeight(); y++) {
                if (frequencies[x][y] < min)
                    min = frequencies[x][y];
                if (frequencies[x][y] > max)
                    max = frequencies[x][y];
            }
        }
    }
    BufferedImage image = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
    for (int x = 0; x < this.getWidth(); x++) {
        for (int y = 0; y < this.getHeight(); y++) {
            Color color = calculateColor(frequencies[x][y], min, max);
            image.setRGB(x, y, color.getRGB());
        }
    }
    return image;
}

From source file:org.fhcrc.cpl.toolbox.statistics.BasicStatistics.java

public static double min(List<? extends Number> values) {
    double minValue = Float.MAX_VALUE;
    for (Number value : values)
        if (value.doubleValue() < minValue)
            minValue = value.doubleValue();
    return minValue;
}

From source file:com.example.appf.CS3570.java

@Override
public void onSensorChanged(SensorEvent event) {
    if (event.sensor.getType() == Sensor.TYPE_GYROSCOPE) {
        mGyroscopeEvent = event.values;/*from  w  ww. j  ava 2  s .c o  m*/
    }
    if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
        mGravity = event.values;

    if (mGravity != null && mGyroscopeEvent != null && mGLView != null && mGLView.mRenderer.mTetra != null) {
        filter.updateFilter(mGyroscopeEvent[0], mGyroscopeEvent[1], mGyroscopeEvent[2], mGravity[0],
                mGravity[1], mGravity[2]);
        filter.computerEuler();
        azimut = (float) filter.getYaw(); // orientation contains: azimut, pitch and roll
        pitch = (float) filter.getPitch();
        roll = (float) filter.getRoll();

        if (previousAzimuth == Float.MAX_VALUE) {
            previousAzimuth = azimut;
        }
        if (previousPitch == Float.MAX_VALUE) {
            previousPitch = pitch;
        }
        if (previousRoll == Float.MAX_VALUE) {
            previousRoll = roll;
        }

        float delta_azimut = azimut - previousAzimuth;
        float delta_pitch = pitch - previousPitch;
        float delta_roll = roll - previousRoll;
        //Log.e("eee", "Azimuth: "+ delta_azimut + " pitch: " + delta_pitch + " roll: " + delta_roll);
        //Log.e("eee", " roll: " + roll);
        //Log.e("eee", "Azimuth: " + azimut + " pitch: " + pitch + " roll: " + roll);

        if (Math.abs(delta_roll) > THRESHOLD && roll != Float.NaN) {
            previousRoll = roll;
            if (cam)
                mGLView.mRenderer.mCamera.rotateX(delta_roll * 180.0 / Math.PI * ROTATE_AMPLIFY);
            //mGLView.mRenderer.mTetra.rotate((float) (delta_roll * 180.0 / Math.PI) * ROTATE_AMPLIFY, 1, 0, 0);
            else
                mGLView.mRenderer.mTetra.pure_rotate((float) ((roll + Math.PI) * 180.0 / Math.PI), 1, 0, 0);
        }

        if (Math.abs(delta_pitch) > THRESHOLD && pitch != Float.NaN) {
            previousPitch = pitch;
            if (cam)
                mGLView.mRenderer.mCamera.rotateX(delta_pitch * 180.0 / Math.PI * ROTATE_AMPLIFY);
            //Log.e("eee", "" + ((delta_pitch)* 180.0 / Math.PI) );
            else
                mGLView.mRenderer.mTetra.pure_rotate((float) ((pitch + Math.PI) * 180.0 / Math.PI), 0, 1, 0);

        }

        if (Math.abs(delta_azimut) > THRESHOLD && azimut != Float.NaN) {
            previousAzimuth = azimut;
            if (cam)
                mGLView.mRenderer.mCamera.rotateY(delta_azimut * 180.0 / Math.PI * ROTATE_AMPLIFY);
            else
                //mGLView.mRenderer.mTetra.rotate((float)(delta_azimut * 180.0/Math.PI) * ROTATE_AMPLIFY, 0, 0, 1 );
                mGLView.mRenderer.mTetra.pure_rotate((float) (azimut * 180.0 / Math.PI), 0, 0, 1);
        }

        if (out != null) {
            //Log.e("eee", "{pitch:" + pitch + "}");
            Vector3 cam_pos = mGLView.mRenderer.mCamera.get_position();
            out.println("{\"pitch\":" + pitch + ", \"roll\": " + roll + ", \"yaw\": " + azimut
                    + ", \"translation\": [" + cam_pos.getX() + ", " + cam_pos.getY() + "," + cam_pos.getZ()
                    + "]}\0");
        }
        mGLView.requestRender();
    }

}

From source file:com.normsstuff.maps4norm.Util.java

/**
 * Calculates the up- & downwards elevation along the passed trace.
 * <p/>//  w  ww  .  jav  a2 s. c  o  m
 * This method might need to connect to the Google Elevation API and
 * therefore must not be called from the main UI thread.
 *
 * @param trace the list of LatLng objects
 * @return null if an error occurs, a pair of two float values otherwise:
 * first one is the upwards elevation, second one downwards
 * <p/>
 * based on
 * http://stackoverflow.com/questions/1995998/android-get-altitude
 * -by-longitude-and-latitude
 */
static Pair<Float, Float> getElevation(final List<LatLng> trace) {
    float up = 0, down = 0;
    float lastElevation = -Float.MAX_VALUE, currentElevation;
    HttpClient httpClient = new DefaultHttpClient();
    HttpContext localContext = new BasicHttpContext();
    float difference;
    try {
        for (LatLng p : trace) {
            currentElevation = getAltitude(p, httpClient, localContext);

            // current and last point have a valid elevation data ->
            // calculate difference
            if (currentElevation > -Float.MAX_VALUE && lastElevation > -Float.MAX_VALUE) {
                difference = currentElevation - lastElevation;
                if (difference > 0)
                    up += difference;
                else
                    down += difference;
            }
            lastElevation = currentElevation;
        }
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
    return new Pair<Float, Float>(up, down);
}

From source file:com.ahm.fileupload.FileController.java

public void algo() throws Exception {
    if (this.file != null) {
        String fname = this.getFileName(this.file);
        if (this.checkFileType(fname)) {
            String path = this.processUpload(file);
            String fileSavePath = FacesContext.getCurrentInstance().getExternalContext()
                    .getRealPath(this.path_to);
            String pp = fileSavePath + "/" + path;
            try {
                this.targetsMax = Float.MIN_VALUE;
                this.targetsMin = Float.MAX_VALUE;
                this.estimates = new ArrayList<Float>();
                this.targets = new ArrayList<Float>();
                File filBefore = new File(pp);
                this.readLastInputColumn(filBefore);
                AHN.useAHN(pp, pp, this.moleculas, this.eta);
                File filAfter = new File(pp);
                this.estimatesMax = Float.MIN_VALUE;
                this.estimastesMin = Float.MAX_VALUE;
                this.readResult(filAfter);
                this.createLineModels();
                this.activo = true;
                RequestContext.getCurrentInstance().update("main:graf");
            } catch (Exception e) {
                e.printStackTrace();/* w w  w. java 2  s  . c o m*/
            }

            FacesContext context = FacesContext.getCurrentInstance();
            HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();

            File filer = new File(pp);

            if (!filer.exists()) {
                response.sendError(HttpServletResponse.SC_NOT_FOUND);
                return;
            }
            Faces.sendFile(filer, false);
            this.deleteFile(path);
        } else {
            FacesContext context = FacesContext.getCurrentInstance();
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,
                    "Error! Your file is not a csv.", "Your file is not a csv."));
        }
    }
}

From source file:com.epam.catgenome.entity.vcf.VcfFilterForm.java

private void addQualityFilter(BooleanQuery.Builder builder) {
    if (quality != null && !quality.isEmpty()) {
        if (quality.size() < 2) {
            builder.add(FloatPoint.newExactQuery(FeatureIndexFields.QUALITY.getFieldName(), quality.get(0)),
                    BooleanClause.Occur.MUST);
        } else {// www.j a  va 2 s  . c om
            Assert.isTrue(quality.get(0) != null || quality.get(1) != null,
                    "Incorrect filter parameter:" + " quality:[null, null]");
            builder.add(
                    FloatPoint.newRangeQuery(FeatureIndexFields.QUALITY.getFieldName(),
                            quality.get(0) != null ? quality.get(0) : Float.MIN_VALUE,
                            quality.get(1) != null ? quality.get(1) : Float.MAX_VALUE),
                    BooleanClause.Occur.MUST);
        }
    }
}

From source file:org.esa.s1tbx.ocean.toolviews.polarview.SpectraDataAsar.java

public PolarData getPolarData(final int currentRec, final SpectraUnit spectraUnit) throws Exception {
    final boolean realBand = spectraUnit != SpectraUnit.IMAGINARY;
    spectrum = getSpectrum(currentRec, realBand);

    float minValue = getMinValue(realBand);
    float maxValue = getMaxValue(realBand);

    if (waveProductType == SpectraData.WaveProductType.WAVE_SPECTRA) {
        if (spectraUnit == SpectraUnit.INTENSITY) {
            minValue = Float.MAX_VALUE;
            maxValue = Float.MIN_VALUE;
            for (int i = 0; i < spectrum.length; i++) {
                for (int j = 0; j < spectrum[0].length; j++) {
                    final float realVal = spectrum[i][j];
                    final float val = realVal * realVal;
                    spectrum[i][j] = val;
                    minValue = Math.min(minValue, val);
                    maxValue = Math.max(maxValue, val);
                }/*from w w  w.  j  a  va  2s .  com*/
            }
        }
    } else if (spectraUnit == SpectraUnit.AMPLITUDE || spectraUnit == SpectraUnit.INTENSITY) {
        // complex data
        final float imagSpectrum[][] = getSpectrum(currentRec, false);
        minValue = Float.MAX_VALUE;
        maxValue = Float.MIN_VALUE;
        for (int i = 0; i < spectrum.length; i++) {
            for (int j = 0; j < spectrum[0].length; j++) {
                final float realVal = spectrum[i][j];
                final float imagVal = imagSpectrum[i][j];
                float val;
                if (sign(realVal) == sign(imagVal)) {
                    val = realVal * realVal + imagVal * imagVal;
                } else {
                    val = 0.0F;
                }
                if (spectraUnit == SpectraUnit.AMPLITUDE) {
                    val = (float) Math.sqrt(val);
                }
                spectrum[i][j] = val;
                minValue = Math.min(minValue, val);
                maxValue = Math.max(maxValue, val);
            }
        }
    }

    final float rStep = (float) (Math.log(lastWLBin) - Math.log(firstWLBin)) / (float) (numWLBins - 1);
    double logr = Math.log(firstWLBin) - (rStep / 2.0);

    final float thFirst;
    final float thStep;
    if (waveProductType == SpectraData.WaveProductType.WAVE_SPECTRA) {
        thFirst = firstDirBins + 5f;
        thStep = -dirBinStep;
    } else {
        thFirst = firstDirBins - 5f;
        thStep = dirBinStep;
    }

    final float radii[] = new float[spectrum[0].length + 1];
    for (int j = 0; j <= spectrum[0].length; j++) {
        radii[j] = (float) (10000.0 / FastMath.exp(logr));
        logr += rStep;
    }

    return new PolarData(spectrum, 90f + thFirst, thStep, radii, minValue, maxValue);
}

From source file:pipeline.data.ClickedPoint.java

public void setConfidence(Float confidence) {
    if (confidence == null) {
        if (cachedConfidenceIndex > -1) {
            quantifiedProperties.set(cachedConfidenceIndex, Float.MAX_VALUE);
        }//from  w  w  w  .  j av  a 2  s .  c  om
        return;
    }
    if (cachedConfidenceIndex == -1) {
        updateConfidenceIndex();
    }
    if (cachedConfidenceIndex == -1) {
        throw new IllegalStateException("Confidence was not initialized");
    }
    quantifiedProperties.set(cachedConfidenceIndex, confidence);
}

From source file:femr.ui.controllers.ResearchController.java

private ResearchGraphDataModel buildGraphModel(ResearchResultSetItem results) {

    ResearchGraphDataModel graphModel = new ResearchGraphDataModel();

    graphModel.setAverage(results.getAverage());
    if (results.getDataRangeLow() > -1 * Float.MAX_VALUE) {
        graphModel.setRangeLow(results.getDataRangeLow());
    } else {//w ww . j a va2s.  co m
        graphModel.setRangeLow(0.0f);
    }
    if (results.getDataRangeHigh() < Float.MAX_VALUE) {
        graphModel.setRangeHigh(results.getDataRangeHigh());
    } else {
        graphModel.setRangeHigh(0.0f);
    }
    graphModel.setTotalPatients(results.getTotalPatients());
    graphModel.setTotalEncounters(results.getTotalEncounters());

    graphModel.setUnitOfMeasurement(results.getUnitOfMeasurement());
    graphModel.setxAxisTitle(WordUtils.capitalize(StringUtils.splitCamelCase(results.getDataType())));
    graphModel.setyAxisTitle("Number of Patients");

    graphModel.setPrimaryValuemap(results.getPrimaryValueMap());
    graphModel.setSecondaryValuemap(results.getSecondaryValueMap());

    // @TODO - This go in item mapper?
    List<ResearchItemModel> graphData = new ArrayList<>();
    for (ResearchResultItem item : results.getDataset()) {

        ResearchItemModel resultItem = new ResearchItemModel();
        resultItem.setPrimaryName(item.getPrimaryName());
        resultItem.setPrimaryValue(item.getPrimaryValue());
        resultItem.setSecondaryData(item.getSecondaryData());
        graphData.add(resultItem);
    }
    graphModel.setGraphData(graphData);

    return graphModel;
}