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.todoroo.astrid.tags.TagsControlSet.java

private CharSequence buildTagString() {
    List<TagData> sortedTagData = orderByName.sortedCopy(selectedTags);
    List<SpannableString> tagStrings = Lists.transform(sortedTagData, tagToString(Float.MAX_VALUE));
    SpannableStringBuilder builder = new SpannableStringBuilder();
    for (SpannableString tagString : tagStrings) {
        if (builder.length() > 0) {
            builder.append(SPACE);/*from w w w  .j a v a  2 s . c o m*/
        }
        builder.append(tagString);
    }
    return builder;
}

From source file:MSUmpire.SpectrumParser.mzXMLReadUnit.java

public ScanData Parse() throws ParserConfigurationException, SAXException, IOException, DataFormatException {
    if (XMLtext.replaceFirst("</scan>", "").contains("</scan>")) {
        XMLtext = XMLtext.replaceFirst("</scan>", "");
    }//from ww  w .ja v a  2 s . c  o m
    if (!XMLtext.contains("</scan>")) {
        XMLtext += "</scan>";
    }
    ScanData scan = new ScanData();
    final DocumentBuilder docBuilder = tls.get();
    docBuilder.reset();
    InputSource input = new InputSource(new StringReader(XMLtext));
    Document doc = null;
    try {
        doc = docBuilder.parse(input);
    } catch (Exception ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
        Logger.getRootLogger().error(XMLtext);
    }
    Node root = doc.getFirstChild();
    for (int i = 0; i < root.getAttributes().getLength(); i++) {
        switch (root.getAttributes().item(i).getNodeName()) {
        case ("num"):
            scan.ScanNum = Integer.parseInt(root.getAttributes().item(i).getNodeValue());
            break;
        case ("centroided"): {
            if ("1".equals(root.getAttributes().item(i).getNodeValue())) {
                scan.centroided = true;
            } else {
                scan.centroided = false;
            }
            break;
        }
        case ("msLevel"):
            scan.MsLevel = Integer.parseInt(root.getAttributes().item(i).getNodeValue());
            break;
        case ("scanType"):
            scan.scanType = root.getAttributes().item(i).getNodeValue();
            break;
        case ("peaksCount"):
            scan.PeaksCountString = Integer.parseInt(root.getAttributes().item(i).getNodeValue());
            break;
        case ("retentionTime"):
            scan.RetentionTime = Float.parseFloat(root.getAttributes().item(i).getNodeValue().substring(2,
                    root.getAttributes().item(i).getNodeValue().indexOf("S"))) / 60f;
            break;
        case ("lowMz"): {
            String value = root.getAttributes().item(i).getNodeValue();
            if ("inf".equals(value)) {
                value = String.valueOf(Float.MIN_VALUE);
            }
            scan.StartMz = Float.parseFloat(value);
            break;
        }
        case ("highMz"): {
            String value = root.getAttributes().item(i).getNodeValue();
            if ("inf".equals(value)) {
                value = String.valueOf(Float.MAX_VALUE);
            }
            scan.EndMz = Float.parseFloat(value);
            break;
        }
        case ("startMz"):
            scan.StartMz = Float.parseFloat(root.getAttributes().item(i).getNodeValue());
            break;
        case ("endMz"): {
            String value = root.getAttributes().item(i).getNodeValue();
            if ("inf".equals(value)) {
                value = String.valueOf(Float.MAX_VALUE);
            }
            scan.EndMz = Float.parseFloat(value);
            break;
        }
        case ("basePeakMz"): {
            String value = root.getAttributes().item(i).getNodeValue();
            if ("inf".equals(value)) {
                value = String.valueOf(Float.MAX_VALUE);
            }
            scan.BasePeakMz = Float.parseFloat(value);
            break;
        }
        case ("basePeakIntensity"):
            scan.BasePeakIntensity = Float.parseFloat(root.getAttributes().item(i).getNodeValue());
            break;
        case ("totIonCurrent"):
            scan.SetTotIonCurrent(Float.parseFloat(root.getAttributes().item(i).getNodeValue()));
            break;
        }
    }
    for (int i = 0; i < root.getChildNodes().getLength(); i++) {
        Node childNode = root.getChildNodes().item(i);
        switch (childNode.getNodeName()) {
        case ("precursorMz"): {
            scan.PrecursorMz = Float.parseFloat(childNode.getTextContent());
            for (int j = 0; j < childNode.getAttributes().getLength(); j++) {
                switch (childNode.getAttributes().item(j).getNodeName()) {
                case ("precursorScanNum"):
                    scan.precursorScanNum = Integer.parseInt(childNode.getAttributes().item(j).getNodeValue());
                    break;
                case ("precursorIntensity"):
                    scan.PrecursorIntensity = Float
                            .parseFloat(childNode.getAttributes().item(j).getNodeValue());
                    break;
                case ("precursorCharge"):
                    scan.PrecursorCharge = Integer.parseInt(childNode.getAttributes().item(j).getNodeValue());
                    break;
                case ("activationMethod"):
                    scan.ActivationMethod = childNode.getAttributes().item(j).getNodeValue();
                    break;
                case ("windowWideness"):
                    scan.windowWideness = Float.parseFloat(childNode.getAttributes().item(j).getNodeValue());
                    break;
                }
            }
            break;
        }
        case ("peaks"): {
            for (int j = 0; j < childNode.getAttributes().getLength(); j++) {
                switch (childNode.getAttributes().item(j).getNodeName()) {
                case ("compressionType"):
                    scan.compressionType = childNode.getAttributes().item(j).getNodeValue();
                    break;
                case ("precision"):
                    scan.precision = Integer.parseInt(childNode.getAttributes().item(j).getNodeValue());
                    break;
                }
            }
            ParsePeakString(scan, childNode.getTextContent());
            break;
        }
        }
        childNode = null;
    }
    if ("calibration".equals(scan.scanType)) {
        scan.MsLevel = -1;
    }
    XMLtext = null;
    scan.Data.Finalize();
    return scan;
}

From source file:org.apache.hadoop.hive.hbase.HBaseTestSetup.java

private void createHBaseTable() throws IOException {
    final String HBASE_TABLE_NAME = "HiveExternalTable";
    HTableDescriptor htableDesc = new HTableDescriptor(HBASE_TABLE_NAME.getBytes());
    HColumnDescriptor hcolDesc = new HColumnDescriptor("cf".getBytes());
    htableDesc.addFamily(hcolDesc);/*from w ww  .  j a  va2  s . c o m*/

    boolean[] booleans = new boolean[] { true, false, true };
    byte[] bytes = new byte[] { Byte.MIN_VALUE, -1, Byte.MAX_VALUE };
    short[] shorts = new short[] { Short.MIN_VALUE, -1, Short.MAX_VALUE };
    int[] ints = new int[] { Integer.MIN_VALUE, -1, Integer.MAX_VALUE };
    long[] longs = new long[] { Long.MIN_VALUE, -1, Long.MAX_VALUE };
    String[] strings = new String[] { "Hadoop, HBase,", "Hive", "Test Strings" };
    float[] floats = new float[] { Float.MIN_VALUE, -1.0F, Float.MAX_VALUE };
    double[] doubles = new double[] { Double.MIN_VALUE, -1.0, Double.MAX_VALUE };

    HBaseAdmin hbaseAdmin = null;
    HTableInterface htable = null;
    try {
        hbaseAdmin = new HBaseAdmin(hbaseConn.getConfiguration());
        if (Arrays.asList(hbaseAdmin.listTables()).contains(htableDesc)) {
            // if table is already in there, don't recreate.
            return;
        }
        hbaseAdmin.createTable(htableDesc);
        htable = hbaseConn.getTable(HBASE_TABLE_NAME);

        // data
        Put[] puts = new Put[] { new Put("key-1".getBytes()), new Put("key-2".getBytes()),
                new Put("key-3".getBytes()) };

        // store data
        for (int i = 0; i < puts.length; i++) {
            puts[i].add("cf".getBytes(), "cq-boolean".getBytes(), Bytes.toBytes(booleans[i]));
            puts[i].add("cf".getBytes(), "cq-byte".getBytes(), new byte[] { bytes[i] });
            puts[i].add("cf".getBytes(), "cq-short".getBytes(), Bytes.toBytes(shorts[i]));
            puts[i].add("cf".getBytes(), "cq-int".getBytes(), Bytes.toBytes(ints[i]));
            puts[i].add("cf".getBytes(), "cq-long".getBytes(), Bytes.toBytes(longs[i]));
            puts[i].add("cf".getBytes(), "cq-string".getBytes(), Bytes.toBytes(strings[i]));
            puts[i].add("cf".getBytes(), "cq-float".getBytes(), Bytes.toBytes(floats[i]));
            puts[i].add("cf".getBytes(), "cq-double".getBytes(), Bytes.toBytes(doubles[i]));

            htable.put(puts[i]);
        }
    } finally {
        if (htable != null)
            htable.close();
        if (hbaseAdmin != null)
            hbaseAdmin.close();
    }
}

From source file:LineGraphDrawable.java

/**
 * Draws the bar-graph into the given Graphics2D context in the given area.
 * This method will not draw a graph if the data given is null or empty.
 * //w w  w .  j a v a 2  s  .c om
 * @param graphics
 *          the graphics context on which the bargraph should be rendered.
 * @param drawArea
 *          the area on which the bargraph should be drawn.
 */
public void draw(final Graphics2D graphics, final Rectangle2D drawArea) {
    if (graphics == null) {
        throw new NullPointerException();
    }
    if (drawArea == null) {
        throw new NullPointerException();
    }

    final int height = (int) drawArea.getHeight();
    if (height <= 0) {
        return;
    }

    final Graphics2D g2 = (Graphics2D) graphics.create();
    if (background != null) {
        g2.setPaint(background);
        g2.draw(drawArea);
    }

    if (data == null || data.length == 0) {
        g2.dispose();
        return;
    }

    g2.translate(drawArea.getX(), drawArea.getY());

    float d = getDivisor(data, height);
    final int spacing = getSpacing();
    final int w = (((int) drawArea.getWidth()) - (spacing * (data.length - 1))) / (data.length - 1);

    float min = Float.MAX_VALUE;
    for (int index = 0; index < data.length; index++) {
        Number i = data[index];
        if (i == null) {
            continue;
        }
        final float value = i.floatValue();
        if (value < min) {
            min = value;
        }
    }

    int x = 0;
    int y = -1;

    if (d == 0.0) {
        // special case -- a horizontal straight line
        d = 1.0f;
        y = -height / 2;
    }

    final Line2D.Double line = new Line2D.Double();
    for (int i = 0; i < data.length - 1; i++) {
        final int px1 = x;
        x += (w + spacing);
        final int px2 = x;

        g2.setPaint(color);

        final Number number = data[i];
        final Number nextNumber = data[i + 1];
        if (number == null && nextNumber == null) {
            final float delta = height - ((0 - min) / d);
            line.setLine(px1, y + delta, px2, y + delta);
        } else if (number == null) {
            line.setLine(px1, y + (height - ((0 - min) / d)), px2,
                    y + (height - ((nextNumber.floatValue() - min) / d)));
        } else if (nextNumber == null) {
            line.setLine(px1, y + (height - ((number.floatValue() - min) / d)), px2,
                    y + (height - ((0 - min) / d)));
        } else {
            line.setLine(px1, y + (height - ((number.floatValue() - min) / d)), px2,
                    y + (height - ((nextNumber.floatValue() - min) / d)));
        }
        g2.draw(line);

    }

    g2.dispose();

}

From source file:com.quantcast.measurement.service.QCLocation.java

Location findBestLocation() {
    Location retval = null;//  w  w  w  .j av  a  2  s .  c o m
    long acceptableTimestamp = System.currentTimeMillis() - STALE_LIMIT;
    float bestAccuracy = Float.MAX_VALUE;
    List<String> matchingProviders = _locManager.getAllProviders();
    for (String provider : matchingProviders) {
        try {
            Location location = _locManager.getLastKnownLocation(provider);
            if (location != null) {
                float accuracy = location.getAccuracy();
                long time = location.getTime();

                //accuracy of 0 means unknown, not perfect accuracy
                if (accuracy > 0.0 && time >= acceptableTimestamp && accuracy <= bestAccuracy) {
                    retval = location;
                    bestAccuracy = accuracy;
                    acceptableTimestamp = time;
                }
            }
        } catch (SecurityException ignored) {
        }
    }
    return retval;
}

From source file:Range.java

/**
 * @param a//w  ww.ja  v  a2 s.co m
 *            a static range
 * @param b
 *            a mobile range
 * @param bv
 *            The velocity of b
 * @return The time period over which a and b intersect, or
 *         <code>null</code> if they never do
 */
public static Range intersectionTime(Range a, Range b, float bv) {
    if (bv == 0) { // nobody likes division by zero
        if (a.intersects(b)) { // continual intersection
            return new Range(-Float.MAX_VALUE, Float.MAX_VALUE);
        } else { // no intersection
            return null;
        }
    }

    // time when low edge of a meets high edge of b
    float t1 = (a.getMin() - b.getMax()) / bv;
    // time when high edge of a meets low edge of b
    float t2 = (a.getMax() - b.getMin()) / bv;

    // constructor sorts the times into proper order
    return new Range(t1, t2);
}

From source file:com.scottjjohnson.finance.analysis.WeeksTightCalculator.java

/**
 * Iterates over quote list looking for a Weeks Tight
 * /*from  www .  j ava2 s. c  om*/
 * @param quotes
 *            list of stock quote beans
 * @return Weeks Tight bean
 */
protected WeeksTightBean scanQuotesForWeeksTight(List<WeeklyQuoteBean> quotes) {

    float minAdjClose = Float.MAX_VALUE;
    float maxAdjClose = 0f;
    float maxHigh = 0f;
    float minLow = 0f;
    float maxHighWeekAfter = Float.MAX_VALUE;
    float minCloseAnytimeAfter = Float.MAX_VALUE;
    float variance = 0f;

    String ticker = quotes.get(0).getSymbol();

    WeeklyQuoteBean possibleWeekPatternCompleted = null;
    WeeklyQuoteBean priorWeek = null;

    WeeksTightBean wt = null;
    int i = quotes.size();
    int j = 0;

    Date today = DateUtils.getStockExchangeCalendar().getTime();

    // loop through each week in reverse order starting at the current week-ending.
    // stop at i=1 because minimum weeks tight is 3. Only look back MAX_AGE_IN_WEEKS_OF_WT weeks.
    while (wt == null && i > 2 && i > quotes.size() - MAX_AGE_IN_WEEKS_OF_WT - 1) {

        i--;
        j = i;

        possibleWeekPatternCompleted = quotes.get(i);

        if (possibleWeekPatternCompleted.getWeekEndingDate().after(today)) {
            continue; // the bean is for the current week and the week is not complete yet so skip it
        }

        minAdjClose = possibleWeekPatternCompleted.getAdj_Close();
        maxAdjClose = possibleWeekPatternCompleted.getAdj_Close();
        maxHigh = possibleWeekPatternCompleted.getAdj_High();
        minLow = possibleWeekPatternCompleted.getAdj_Low();

        LOGGER.debug("Finding weeks tight for week ending {}.",
                possibleWeekPatternCompleted.getWeekEndingDate());

        // for the week-ending, see how far back we can go and be within
        // tolerance for a weeks tight
        while (j > 0) {
            j--;

            priorWeek = quotes.get(j);

            minAdjClose = Math.min(minAdjClose, priorWeek.getAdj_Close());
            maxAdjClose = Math.max(maxAdjClose, priorWeek.getAdj_Close());

            LOGGER.debug("Checking week {}.", priorWeek.getWeekEndingDate());

            variance = Math.abs((minAdjClose / maxAdjClose) - 1);
            LOGGER.debug("variance = {}.", (variance));

            if (variance <= WEEKS_TIGHT_TOLERANCE) {
                int patternLength = i - j + 1;

                // This is the special "SLXP" rule mentioned above. It ignores drops > 2.5% in the week high earlier
                // than 2 weeks into the pattern.
                if (patternLength >= 3 && priorWeek.getAdj_High() >= SLXP_RULE_DEVIATION * maxHigh
                        && maxHighWeekAfter < maxHigh) {
                    // skip updating the maxHigh
                } else
                    maxHigh = Math.max(maxHigh, priorWeek.getAdj_High());

                minLow = Math.min(minLow, priorWeek.getAdj_Low());

                // make sure we're at least 3 weeks into the Weeks Tight
                if (patternLength >= MIN_WEEKS_IN_A_WEEKS_TIGHT && isStockInUptrend(
                        quotes.subList(Math.max(j - MINIMUM_UPTREND_PERIOD_WEEKS, 0), j + 1))) {
                    wt = new WeeksTightBean();
                    wt.setPatternEndingDate(possibleWeekPatternCompleted.getWeekEndingDate());
                    wt.setTickerSymbol(possibleWeekPatternCompleted.getSymbol());
                    wt.setWeeksTightLength(patternLength);
                    wt.setHighestPrice(maxHigh);
                    wt.setLowestPrice(minLow);
                }

                LOGGER.debug("WT bean = {}", wt);
            } else
                break; // not in a weeks tight so skip to the next week
        }

        if (wt == null) {

            // if we're not in a WT save the high for this week in case we need it for the special "SLXP" rule
            // mentioned in the Javadoc.
            maxHighWeekAfter = possibleWeekPatternCompleted.getAdj_High();

            // also save the lowest close prior to the WT
            minCloseAnytimeAfter = Math.min(minCloseAnytimeAfter, possibleWeekPatternCompleted.getAdj_Close());
        }
    }

    if (wt != null) {
        if (minCloseAnytimeAfter < wt.getLowestPrice()) {
            LOGGER.debug(
                    "Dropping WT for {} because stock closed the week below the low of the pattern after the pattern completed.",
                    ticker, wt.getLowestPrice(), minCloseAnytimeAfter);
            wt = null;
        }
    }
    return wt;
}

From source file:com.github.rvesse.airline.restrictions.factories.RangeRestrictionFactory.java

protected RangeRestriction createFloatRange(Annotation annotation) {
    FloatRange sRange = (FloatRange) annotation;
    return new RangeRestriction(
            sRange.min() != Float.MIN_VALUE || !sRange.minInclusive() ? Float.valueOf(sRange.min()) : null,
            sRange.minInclusive(),/*ww w  .  j a  va2  s.  c o  m*/
            sRange.max() != Float.MAX_VALUE || !sRange.maxInclusive() ? Float.valueOf(sRange.max()) : null,
            sRange.maxInclusive(), FLOAT_COMPARATOR);
}

From source file:org.deegree.tools.rendering.manager.buildings.PrototypeManager.java

/**
 * @param rqm//from ww  w  .jav a 2s . c  o m
 */
private RenderableQualityModel createScaledQualityModel(RenderableQualityModel rqm) {
    float minX = Float.MAX_VALUE;
    float minY = Float.MAX_VALUE;
    float minZ = Float.MAX_VALUE;
    float maxX = Float.MIN_VALUE;
    float maxY = Float.MIN_VALUE;
    float maxZ = Float.MIN_VALUE;
    ArrayList<RenderableQualityModelPart> qualityModelParts = rqm.getQualityModelParts();
    for (RenderableQualityModelPart rqmp : qualityModelParts) {
        if (rqmp != null) {
            RenderableGeometry geom = (RenderableGeometry) rqmp;
            FloatBuffer fb = geom.getCoordBuffer();
            fb.rewind();
            int position = fb.position();
            while (position < fb.capacity()) {
                float x = fb.get();
                float y = fb.get();
                float z = fb.get();

                minX = Math.min(minX, x);
                minY = Math.min(minY, y);
                minZ = Math.min(minZ, z);

                maxX = Math.max(maxX, x);
                maxY = Math.max(maxY, y);
                maxZ = Math.max(maxZ, z);
                position = fb.position();
            }
        }
    }

    double scaleX = 1d / (maxX - minX);
    double scaleY = 1d / (maxY - minY);
    double scaleZ = 1d / (maxZ - minZ);

    for (RenderableQualityModelPart rqmp : qualityModelParts) {
        if (rqmp != null) {
            RenderableGeometry geom = (RenderableGeometry) rqmp;
            FloatBuffer fb = geom.getCoordBuffer();
            fb.rewind();
            int i = 0;
            while ((i + 3) <= fb.capacity()) {
                float x = fb.get(i);
                x -= minX;
                x *= scaleX;
                fb.put(i, x);

                float y = fb.get(i + 1);
                y -= minY;
                y *= scaleY;
                fb.put(i + 1, y);

                float z = fb.get(i + 2);
                z -= minZ;
                z *= scaleZ;
                fb.put(i + 2, z);
                i += 3;
            }
        }
    }
    return rqm;

}

From source file:org.opencms.site.CmsSite.java

/**
 * @see java.lang.Comparable#compareTo(java.lang.Object)
 *//*from www .  ja  va  2 s.  c  om*/
public int compareTo(CmsSite that) {

    if (that == this) {
        return 0;
    }
    float thatPos = that.getPosition();
    // please note: can't just subtract and cast to int here because of float precision loss
    if (m_position == thatPos) {
        if (m_position == Float.MAX_VALUE) {
            // if they both do not have any position, sort by title
            return m_title.compareTo((that).getTitle());
        }
        return 0;
    }
    return (m_position < thatPos) ? -1 : 1;
}