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:org.ncic.bioinfo.sparkseq.algorithms.walker.mutect.Mutect.java

@Override
protected void initialize() {
    callStatsGenerator = new CallStatsGenerator(MTAC.ENABLE_QSCORE_OUTPUT);

    if (!hasNormalBam) {
        MTAC.NORMAL_LOD_THRESHOLD = -1 * Float.MAX_VALUE;
        MTAC.NORMAL_DBSNP_LOD_THRESHOLD = -1 * Float.MAX_VALUE;
        MTAC.NORMAL_ARTIFACT_LOD_THRESHOLD = Float.MAX_VALUE;
        MTAC.NORMAL_SAMPLE_NAME = "none";
    }//from w ww  .  ja v a  2s  .c  om

    this.contaminantAlternateFraction = Math.max(MTAC.MINIMUM_MUTATION_CELL_FRACTION,
            MTAC.FRACTION_CONTAMINATION);

    // coverage related initialization
    double powerConstantEps = Math.pow(10, -1 * (MTAC.POWER_CONSTANT_QSCORE / 10));

    this.tumorPowerCalculator = new TumorPowerCalculator(powerConstantEps, MTAC.TUMOR_LOD_THRESHOLD,
            this.contaminantAlternateFraction);
    this.normalNovelSitePowerCalculator = new NormalPowerCalculator(powerConstantEps,
            MTAC.NORMAL_LOD_THRESHOLD);
    this.normalDbSNPSitePowerCalculator = new NormalPowerCalculator(powerConstantEps,
            MTAC.NORMAL_DBSNP_LOD_THRESHOLD);
    this.strandArtifactPowerCalculator = new TumorPowerCalculator(powerConstantEps,
            MTAC.STRAND_ARTIFACT_LOD_THRESHOLD, 0.0f);
}

From source file:edu.uga.cs.fluxbuster.clustering.hierarchicalclustering.DistanceMatrix.java

/**
 * Retrieves the distance between the clusters at the supplied indexes
 * /*w  ww  . j a  va  2  s . co  m*/
 * @param p
 *            the indexes of the clusters
 * @return the distance between the clusters, if the indexes are not within
 *         the bounds of the distance matrix Float.MAX_VALUE is returned
 */
private float distanceHelper(IndexPair p) {
    int i = p.getI();
    int j = p.getJ();
    if (i >= 0 && i < distMatrix.size() && j >= 0 && j < distMatrix.size()) {
        try {
            Vector<Float> row = distMatrix.get(i);
            return row.get(j);

        } catch (Exception e) {
            if (log.isErrorEnabled()) {
                log.error("Error retrieving distance.", e);
            }
        }
    }
    return Float.MAX_VALUE;
}

From source file:edu.umn.cs.spatialHadoop.nasa.HDFRasterLayer.java

public BufferedImage asImage() {
    // Calculate the average
    float[][] avg = new float[getWidth()][getHeight()];
    for (int x = 0; x < this.getWidth(); x++) {
        for (int y = 0; y < this.getHeight(); y++) {
            avg[x][y] = (float) sum[x][y] / count[x][y];
        }/* w  ww  . ja v a2  s.c  o m*/
    }
    if (min >= max) {
        // Values not set. Autodetect
        min = Float.MAX_VALUE;
        max = -Float.MAX_VALUE;
        for (int x = 0; x < this.getWidth(); x++) {
            for (int y = 0; y < this.getHeight(); y++) {
                if (avg[x][y] < min)
                    min = avg[x][y];
                if (avg[x][y] > max)
                    max = avg[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++) {
            if (count[x][y] > 0) {
                Color color = calculateColor(avg[x][y], min, max);
                image.setRGB(x, y, color.getRGB());
            } else {
                image.setRGB(x, y, 0);
            }
        }
    }
    return image;
}

From source file:org.opencms.workplace.commons.CmsChnav.java

/**
 * Builds the HTML for the select box of the navigation position.<p>
 * //from  w  w w  . j a v a  2 s.  co  m
 * @param cms the CmsObject
 * @param filename the current file
 * @param attributes optional attributes for the &lt;select&gt; tag, do not add the "name" atribute!
 * @param messages the localized workplace messages
 * 
 * @return the HTML for a navigation position select box
 */
public static String buildNavPosSelector(CmsObject cms, String filename, String attributes,
        CmsMessages messages) {

    // get current file navigation element
    CmsJspNavBuilder navBuilder = new CmsJspNavBuilder(cms);
    CmsJspNavElement curNav = navBuilder.getNavigationForResource(filename);

    // get the parent folder of the current file
    filename = CmsResource.getParentFolder(filename);

    // get navigation of the current folder
    List navList = navBuilder.getNavigationForFolder(filename);
    float maxValue = 0;
    float nextPos = 0;

    // calculate value for the first navigation position
    float firstValue = 1;
    if (navList.size() > 0) {
        try {
            CmsJspNavElement ne = (CmsJspNavElement) navList.get(0);
            maxValue = ne.getNavPosition();
        } catch (Exception e) {
            // should usually never happen
            LOG.error(e.getLocalizedMessage());
        }
    }

    if (maxValue != 0) {
        firstValue = maxValue / 2;
    }

    List options = new ArrayList(navList.size() + 1);
    List values = new ArrayList(navList.size() + 1);

    // add the first entry: before first element
    options.add(messages.key(Messages.GUI_CHNAV_POS_FIRST_0));
    values.add(firstValue + "");

    // show all present navigation elements in box
    for (int i = 0; i < navList.size(); i++) {
        CmsJspNavElement ne = (CmsJspNavElement) navList.get(i);
        String navText = ne.getNavText();
        float navPos = ne.getNavPosition();
        // get position of next nav element
        nextPos = navPos + 2;
        if ((i + 1) < navList.size()) {
            nextPos = ((CmsJspNavElement) navList.get(i + 1)).getNavPosition();
        }
        // calculate new position of current nav element
        float newPos;
        if ((nextPos - navPos) > 1) {
            newPos = navPos + 1;
        } else {
            newPos = (navPos + nextPos) / 2;
        }

        // check new maxValue of positions and increase it
        if (navPos > maxValue) {
            maxValue = navPos;
        }

        // if the element is the current file, mark it in selectbox
        if ((curNav != null) && curNav.getNavText().equals(navText) && (curNav.getNavPosition() == navPos)) {
            options.add(CmsEncoder.escapeHtml(
                    messages.key(Messages.GUI_CHNAV_POS_CURRENT_1, new Object[] { ne.getFileName() })));
            values.add("-1");
        } else {
            options.add(CmsEncoder.escapeHtml(navText + " [" + ne.getFileName() + "]"));
            values.add(newPos + "");
        }
    }

    // add the entry: at the last position
    options.add(messages.key(Messages.GUI_CHNAV_POS_LAST_0));
    values.add((maxValue + 1) + "");

    // add the entry: no change
    options.add(messages.key(Messages.GUI_CHNAV_NO_CHANGE_0));
    if ((curNav != null) && (curNav.getNavPosition() == Float.MAX_VALUE)) {
        // current resource has no valid position, use "last position"
        values.add((maxValue + 1) + "");
    } else {
        // current resource has valid position, use "-1" for no change
        values.add("-1");
    }

    if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(attributes)) {
        attributes = " " + attributes;
    } else {
        attributes = "";
    }
    return CmsWorkplace.buildSelect("name=\"" + PARAM_NAVPOS + "\"" + attributes, options, values,
            values.size() - 1, true);
}

From source file:au.org.ala.layers.grid.GridCacheBuilder.java

private static void writeGroupGRI(File file, ArrayList<Grid> group) {
    Grid g = group.get(0);//from  w  w w .j a  va 2  s.c  o  m
    RandomAccessFile[] raf = new RandomAccessFile[group.size()];
    RandomAccessFile output = null;

    try {
        output = new RandomAccessFile(file, "rw");

        for (int i = 0; i < group.size(); i++) {
            raf[i] = new RandomAccessFile(group.get(i).filename + ".gri", "r");
        }

        int length = g.ncols * g.nrows;
        int size = 4;
        byte[] b = new byte[size * group.size() * g.ncols];
        float noDataValue = Float.MAX_VALUE * -1;

        byte[] bi = new byte[g.ncols * 8];
        float[][] rows = new float[group.size()][g.ncols];

        for (int i = 0; i < g.nrows; i++) {
            //read
            for (int j = 0; j < raf.length; j++) {
                nextRowOfFloats(rows[j], group.get(j).datatype, group.get(j).byteorderLSB, g.ncols, raf[j], bi,
                        (float) g.nodatavalue);
            }

            //write
            ByteBuffer bb = ByteBuffer.wrap(b);
            bb.order(ByteOrder.LITTLE_ENDIAN);

            for (int k = 0; k < g.ncols; k++) {
                for (int j = 0; j < raf.length; j++) {
                    //float f = getNextValue(raf[j], group.get(j));
                    float f = rows[j][k];
                    if (Float.isNaN(f)) {
                        bb.putFloat(noDataValue);
                    } else {
                        bb.putFloat(f);
                    }
                }
            }
            output.write(b);
        }
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    } finally {
        if (output != null) {
            try {
                output.close();
            } catch (Exception e) {
                logger.error(e.getMessage(), e);
            }
        }
        for (int i = 0; i < raf.length; i++) {
            if (raf[i] != null) {
                try {
                    raf[i].close();
                } catch (Exception e) {
                    logger.error(e.getMessage(), e);
                }
            }
        }
    }
}

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

public static float min(float[] values) {
    float minValue = Float.MAX_VALUE;
    for (float value : values)
        if (value < minValue)
            minValue = value;// ww  w .  j  a v  a 2s  . c  om
    return minValue;
}

From source file:edu.uga.cs.fluxbuster.clustering.hierarchicalclustering.DistanceMatrix.java

/**
 * Find closest cluster pair in the distance matrix.
 * /* w w w .j av  a  2  s  . c om*/
 * @return the closest cluster index pair
 */
public ClusterIndexPair findClosestClusterPair() {
    ClusterIndexPair p = new ClusterIndexPair(-1, -1, Float.MAX_VALUE);

    for (int k = 0; k < distMatrix.size(); k++) {
        for (int l = 0; l < distMatrix.get(k).size(); l++) {
            float d = distMatrix.get(k).get(l);
            if (d < p.getDist()) {
                p.setI(k);
                p.setJ(l + k + 1);
                p.setDist(d);
            } else if (d == p.getDist()) { // in this case chooses at random
                if (Math.random() < 0.5) {
                    p.setI(k);
                    p.setJ(l + k + 1);
                    p.setDist(d);
                }
            }
        }
    }

    return p;
}

From source file:LineGraphDrawable.java

/**
 * Computes the scale factor to scale the given numeric data into the target
 * height.//from  w ww.j a  v  a 2  s  .c  om
 * 
 * @param data
 *          the numeric data.
 * @param height
 *          the target height of the graph.
 * @return the scale factor.
 */
public static float getDivisor(final Number[] data, final int height) {
    if (data == null) {
        throw new NullPointerException("Data array must not be null.");
    }

    if (height < 1) {
        throw new IndexOutOfBoundsException("Height must be greater or equal to 1");
    }

    float max = Float.MIN_VALUE;
    float min = Float.MAX_VALUE;

    for (int index = 0; index < data.length; index++) {
        Number i = data[index];
        if (i == null) {
            continue;
        }

        final float numValue = i.floatValue();
        if (numValue < min) {
            min = numValue;
        }
        if (numValue > max) {
            max = numValue;
        }
    }

    if (max <= min) {
        return 1.0f;
    }
    if (height == 1) {
        return 0;
    }
    return (max - min) / (height - 1);
}

From source file:ddf.catalog.data.dynamic.impl.DynamicMetacardImplTest.java

@Test
public void testSetAttributeWithValues() throws Exception {
    metacard.setAttribute(STRING, "abc");
    assertEquals("abc", baseBean.get(STRING));

    metacard.setAttribute(BOOLEAN, true);
    assertEquals(true, baseBean.get(BOOLEAN));

    Date d = new Date(System.currentTimeMillis());
    metacard.setAttribute(DATE, d);//from   w w w  .j  a  v a  2s  .  c  om
    assertEquals(d, baseBean.get(DATE));

    metacard.setAttribute(SHORT, Short.MAX_VALUE);
    assertEquals(Short.MAX_VALUE, baseBean.get(SHORT));

    metacard.setAttribute(INTEGER, Integer.MAX_VALUE);
    assertEquals(Integer.MAX_VALUE, baseBean.get(INTEGER));

    metacard.setAttribute(LONG, Long.MAX_VALUE);
    assertEquals(Long.MAX_VALUE, baseBean.get(LONG));

    metacard.setAttribute(FLOAT, Float.MAX_VALUE);
    assertEquals(Float.MAX_VALUE, baseBean.get(FLOAT));

    metacard.setAttribute(DOUBLE, Double.MAX_VALUE);
    assertEquals(Double.MAX_VALUE, baseBean.get(DOUBLE));

    Byte[] bytes = new Byte[] { 0x00, 0x01, 0x02, 0x03 };
    metacard.setAttribute(BINARY, bytes);
    assertEquals(bytes, baseBean.get(BINARY));

    metacard.setAttribute(XML, XML_STRING);
    assertEquals(XML_STRING, baseBean.get(XML));

    metacard.setAttribute(OBJECT, XML_STRING);
    assertEquals(XML_STRING, baseBean.get(OBJECT));

    List<Serializable> list = new ArrayList<>();
    list.add("123");
    list.add("234");
    list.add("345");
    metacard.setAttribute(STRING_LIST, list);
    assertEquals(list, baseBean.get(STRING_LIST));

    metacard.setAttribute(STRING_LIST, "456");
    Collection c = (Collection) baseBean.get(STRING_LIST);
    assertEquals(4, c.size());
    assertTrue(c.contains("456"));

    list.remove("123");
    metacard.setAttribute(STRING_LIST, list);
    c = (Collection) baseBean.get(STRING_LIST);
    assertEquals(3, c.size());
    assertTrue(c.contains("456"));
    assertFalse(c.contains("123"));

    metacard.setAttribute(SHORT, Short.MIN_VALUE);
    // this should take no action since auto-conversion fails - handled ConversionException
    metacard.setAttribute(SHORT, Long.MAX_VALUE);
    assertEquals(Short.MIN_VALUE, baseBean.get(SHORT));
}

From source file:edu.fullerton.viewerplugin.SpectrumPlot.java

private ChartPanel getPanel(ArrayList<ChanDataBuffer> dbufs, boolean compact) throws WebUtilException {
    ChartPanel ret = null;//from ww w.  j  av a2 s  . co  m
    try {
        float tfsMax = 0;
        for (ChanDataBuffer buf : dbufs) {
            ChanInfo ci = buf.getChanInfo();
            float fs = ci.getRate();
            tfsMax = Math.max(fs, tfsMax);
        }
        setFsMax(tfsMax);
        String gtitle = getTitle(dbufs, compact);
        int nbuf = dbufs.size();
        XYSeries[] xys = new XYSeries[nbuf];
        XYSeriesCollection mtds = new XYSeriesCollection();

        int cnum = 0;
        compact = dbufs.size() > 2 ? false : compact;
        float bw = 1.f;
        for (ChanDataBuffer dbuf : dbufs) {
            String legend = getLegend(dbuf, compact);

            xys[cnum] = new XYSeries(legend);

            bw = calcSpectrum(xys[cnum], dbuf);

            mtds.addSeries(xys[cnum]);
        }

        DefaultXYDataset ds = new DefaultXYDataset();
        String yLabel = pwrScale.toString();
        DecimalFormat dform = new DecimalFormat("0.0###");
        String xLabel;
        xLabel = String.format("Frequency Hz - (bw: %1$s, #fft: %2$,d, s/fft: %3$.2f, ov: %4$.2f)",
                dform.format(bw), nfft, secperfft, overlap);

        Double minx, miny, maxx, maxy;
        Double[] rng = new Double[4];
        if (fmin <= 0) {
            fmin = bw;
        }
        float searchFmax = fmax;
        if (fmax <= 0 || fmax == Float.MAX_VALUE) {
            fmax = tfsMax / 2;
            searchFmax = tfsMax / 2 * 0.8f;
        }
        PluginSupport.getRangeLimits(mtds, rng, 2, fmin, searchFmax);
        minx = rng[0];
        miny = rng[1];
        maxx = rng[2];
        maxy = rng[3];

        findSmallest(mtds);
        int exp;
        if (maxy == 0. && miny == 0.) {
            miny = -1.;
            exp = 0;
            logYaxis = false;
        } else {
            miny = miny > 0 ? miny : smallestY;
            maxy = maxy > 0 ? maxy : miny * 10;
            exp = PluginSupport.scaleRange(mtds, miny, maxy);
            if (!logYaxis) {
                yLabel += " x 1e-" + Integer.toString(exp);
            }
        }
        JFreeChart chart = ChartFactory.createXYLineChart(gtitle, xLabel, yLabel, ds, PlotOrientation.VERTICAL,
                true, false, false);
        XYPlot plot = (XYPlot) chart.getPlot();
        if (logYaxis) {
            LogAxis rangeAxis = new LogAxis(yLabel);
            double smallest = miny * Math.pow(10, exp);
            rangeAxis.setSmallestValue(smallest);
            rangeAxis.setMinorTickCount(9);

            LogAxisNumberFormat lanf = new LogAxisNumberFormat();
            lanf.setExp(exp);

            rangeAxis.setNumberFormatOverride(lanf);
            rangeAxis.setRange(smallest, maxy * Math.pow(10, exp));
            rangeAxis.setStandardTickUnits(LogAxis.createLogTickUnits(Locale.US));
            plot.setRangeAxis(rangeAxis);
            plot.setRangeGridlinesVisible(true);
            plot.setRangeGridlinePaint(Color.BLACK);
        }
        if (logXaxis) {
            LogAxis domainAxis = new LogAxis(xLabel);
            domainAxis.setBase(2);
            domainAxis.setMinorTickCount(9);
            domainAxis.setMinorTickMarksVisible(true);
            domainAxis.setSmallestValue(smallestX);
            domainAxis.setNumberFormatOverride(new LogAxisNumberFormat());
            //domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            plot.setDomainAxis(domainAxis);
            plot.setDomainGridlinesVisible(true);
            plot.setDomainGridlinePaint(Color.BLACK);
        }
        ValueAxis domainAxis = plot.getDomainAxis();
        if (fmin > Float.MIN_VALUE) {
            domainAxis.setLowerBound(fmin);
        }
        if (fmax != Float.MAX_VALUE) {
            domainAxis.setUpperBound(fmax);
        }
        plot.setDomainAxis(domainAxis);
        plot.setDataset(0, mtds);
        plot.setDomainGridlinePaint(Color.DARK_GRAY);
        plot.setRangeGridlinePaint(Color.DARK_GRAY);

        // Set the line thickness
        XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
        BasicStroke str = new BasicStroke(lineThickness);
        int n = plot.getSeriesCount();
        for (int i = 0; i < n; i++) {
            r.setSeriesStroke(i, str);
        }
        plot.setBackgroundPaint(Color.WHITE);
        if (compact) {
            chart.removeLegend();
        }
        ret = new ChartPanel(chart);
    } catch (Exception ex) {
        throw new WebUtilException("Creating spectrum plot" + ex.getLocalizedMessage());
    }
    return ret;

}