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:hugonicolau.openbrailleinput.wordcorrection.mafsa.MAFSA.java

private float min(List<Float> l) {
    float min = Float.MAX_VALUE;
    for (float d : l)
        if (d < min)
            min = d;/*  w w  w .j a  v a 2s . c  om*/
    return min;
}

From source file:com.jogden.spunkycharts.pricebyvolumechart.PriceByVolumeChartFragmentAdapter.java

public void cleanUpAndUpdate() {
    _streamReady.set(false);//from   www . ja  va 2  s.c o m
    for (Thread t : _activeThreads)
        t.interrupt();
    _clear(); /* leave display values */
    _highPrice = 0;
    _lowPrice = Float.MAX_VALUE;
    _highVolume = 0;
}

From source file:org.languagetool.rules.spelling.suggestions.XGBoostSuggestionsOrderer.java

@Override
public boolean shouldAutoCorrect(List<SuggestedReplacement> rankedSuggestions) {
    if (rankedSuggestions.isEmpty() || rankedSuggestions.stream().anyMatch(s -> s.getConfidence() == null)) {
        return false;
    }/*w w w. j  a  v a 2s .c  o m*/
    float threshold = autoCorrectThreshold.getOrDefault(language.getShortCodeWithCountryAndVariant(),
            Float.MAX_VALUE);
    return rankedSuggestions.get(0).getConfidence() >= threshold;
}

From source file:com.google.android.gms.samples.vision.barcodereader.BarcodeCapture.java

/**
 * onTap returns the tapped barcode result to the calling Activity.
 *
 * @param rawX - the raw position of the tap
 * @param rawY - the raw position of the tap.
 * @return true if the activity is ending.
 *///from   w w w .  j a v  a  2s  .  co  m
private boolean onTap(float rawX, float rawY) {
    // Find tap point in preview frame coordinates.
    int[] location = new int[2];
    mGraphicOverlay.getLocationOnScreen(location);
    float x = (rawX - location[0]) / mGraphicOverlay.getWidthScaleFactor();
    float y = (rawY - location[1]) / mGraphicOverlay.getHeightScaleFactor();

    // Find the barcode whose center is closest to the tapped point.
    Barcode best = null;
    float bestDistance = Float.MAX_VALUE;
    ArrayList<Barcode> allRetrieved = new ArrayList<>();
    for (BarcodeGraphic graphic : mGraphicOverlay.getGraphics()) {
        Barcode barcode = graphic.getBarcode();
        allRetrieved.add(barcode);
        if (barcode.getBoundingBox().contains((int) x, (int) y)) {
            // Exact hit, no need to keep looking.
            best = barcode;
            break;
        }
        float dx = x - barcode.getBoundingBox().centerX();
        float dy = y - barcode.getBoundingBox().centerY();
        float distance = (dx * dx) + (dy * dy); // actually squared distance
        if (distance < bestDistance) {
            best = barcode;
            bestDistance = distance;
        }
    }

    if (best != null) {
        if (barcodeRetriever != null)
            if (supportMultipleScan()) {
                barcodeRetriever.onRetrievedMultiple(best, mGraphicOverlay.getGraphics());
            } else {
                barcodeRetriever.onRetrieved(best);
            }
        return true;
    }
    return false;
}

From source file:checkdb.CheckDb.java

private void makeChannelIndexTable() throws SQLException {
    Pattern ifoSubsysPat = Pattern.compile("(^.+):((.+?)[_-])?");

    for (Entry<String, TreeMap<String, ChanStat>> csl : chanstats.entrySet()) {
        ChanIndexInfo cii = new ChanIndexInfo();

        String cname = csl.getKey();
        cii.setName(cname);/*from  www.j a v  a2s  . c o  m*/

        TreeMap<String, ChanStat> serverList = csl.getValue();
        int n = serverList.size();
        cii.setnServers(n);

        Matcher ifoSubsys = ifoSubsysPat.matcher(cname);
        if (ifoSubsys.find()) {
            cii.setIfo(ifoSubsys.group(1));
            String subsys = ifoSubsys.group(3);
            subsys = subsys == null ? "" : subsys;
            cii.setSubsys(subsys);
        } else {
            cii.setIfo("");
            cii.setSubsys("");
        }
        float minRawRate = Float.MAX_VALUE;
        float maxRawRate = Float.MIN_VALUE;
        float minRdsRate = Float.MAX_VALUE;
        float maxRdsRate = Float.MIN_VALUE;

        boolean hasRaw = false;
        boolean hasRds = false;
        boolean hasOnline = false;
        boolean hasMtrends = false;
        boolean hasStrends = false;
        boolean hasTstpnt = false;
        boolean hasStatic = false;
        String cisAvail = " ";

        for (Entry<String, ChanStat> srv : serverList.entrySet()) {
            ChanStat cs = srv.getValue();
            minRawRate = Math.min(minRawRate, cs.getMinRawRate());
            maxRawRate = Math.max(maxRawRate, cs.getMaxRawRate());
            maxRdsRate = Math.max(maxRdsRate, cs.getMaxRdsRate());
            minRdsRate = Math.min(minRdsRate, cs.getMinRdsRate());
            hasRaw |= cs.hasRaw();
            hasRds |= cs.hasRds();
            hasMtrends |= cs.hasMtrends();
            hasStrends |= cs.hasStrend();
            hasStatic |= cs.hasStatic();
            hasOnline |= cs.hasOnline();
            String cis = cs.getCisAvail();
            if (cis.equalsIgnoreCase("d")) {
                cisAvail = cis;
            } else if (!cisAvail.equalsIgnoreCase("d") && cis.equalsIgnoreCase("a")) {
                cisAvail = cis;
            }
        }
        minRawRate = minRawRate == Float.MAX_VALUE ? 0 : minRawRate;
        cii.setMinRawRate(minRawRate);
        maxRawRate = maxRawRate == Float.MIN_VALUE ? 0 : maxRawRate;
        cii.setMaxRawRate(maxRawRate);
        minRdsRate = minRdsRate == Float.MAX_VALUE ? 0 : minRdsRate;
        cii.setMinRdsRate(minRdsRate);
        maxRdsRate = maxRdsRate == Float.MIN_VALUE ? 0 : maxRdsRate;
        cii.setMaxRdsRate(maxRdsRate);

        cii.setCisAvail(cisAvail);
        cii.setHasMtrends(hasMtrends);
        cii.setHasRaw(hasRaw);
        cii.setHasRds(hasRds);
        cii.setHasStrends(hasStrends);
        cii.setHasStatic(hasStatic);
        cii.setHasTestpoint(hasTstpnt);
        cii.setHasOnline(hasOnline);

        cidx.insertNewBulk(cii);
    }
    cidx.insertNewBulk(null); // flush any remaining
}

From source file:FastByteArrayOutputStream.java

public void testPerformanceOfWriteToJspWriter(TextSource textSource) throws IOException {
        NoopJspWriter noopJspWriter = new NoopJspWriter();
        String[] methods = { "writeTo (using hueristics)", "writeToViaSmoosh", };

        System.out.println(textSource.getDesc());
        System.out.println();// www .j  a v a  2 s.c  o  m
        float bestTime = Float.MAX_VALUE;
        String bestMethod = methods[0];
        for (int methodIndex = 0; methodIndex < methods.length; methodIndex++) {
            String method = methods[methodIndex];

            float totalTime = 0;
            final int MAX_TIMES = 10;
            final int MAX_ITERATIONS = 100;
            for (int times = 0; times < MAX_TIMES; times++) {
                String srcText = textSource.getText(times);
                for (int i = 0; i < MAX_ITERATIONS; i++) {
                    FastByteArrayOutputStream bout = new FastByteArrayOutputStream();
                    bout.write(srcText.getBytes(UTF_8));

                    // just time the JspWriter output. And let it warm u first as well
                    if (times > 3) {
                        long then = System.currentTimeMillis();
                        switch (methodIndex) {
                        case 0:
                            bout.writeTo(noopJspWriter, UTF_8);
                            break;
                        case 1:
                            bout.writeToViaSmoosh(noopJspWriter, UTF_8);
                            break;
                        }
                        long now = System.currentTimeMillis();
                        totalTime += (now - then);
                    }
                }
            }
            float avgTime = totalTime / MAX_TIMES / MAX_ITERATIONS;
            System.out.println(method + "  - Total Call Time = " + totalTime + "ms");
            System.out.println(method + " - Average Call Time = " + avgTime + "ms");
            System.out.println();

            if (avgTime < bestTime) {
                bestTime = avgTime;
                bestMethod = method;
            }
        }
        System.out.println(bestMethod + " was the best method - Average Call Time = " + bestTime + "ms");
        System.out.println("____________________\n");

    }

From source file:pipeline.misc_util.Utils.java

private static void findMinMax(byte[] a, MinMax m) {
    float max = -Float.MAX_VALUE;
    float min = Float.MAX_VALUE;
    for (byte element : a) {
        if (((element & 0xff)) > max)
            max = (element & 0xff);/*from w  ww . jav  a 2s  . c  o m*/
        if (((element & 0xff)) < min)
            min = (element & 0xff);
    }
    m.max = max;
    m.min = min;
}

From source file:ac.robinson.ticqr.TicQRActivity.java

private void verifyBoxes() {
    // scans the list comparing with the actual tick box positions (some could be outside the image)
    int maximumBoxDistance = Math.round(mBoxSize * 0.75f);
    int maximumQRCodeDistance = Math.round(mBoxSize * 0.4f);
    int maximumQRCodeDistanceSquared = maximumQRCodeDistance * maximumQRCodeDistance;

    Log.d(TAG, "Searching for codes at max distance: " + maximumBoxDistance + " (QR dist: "
            + maximumQRCodeDistance + ")");

    // update the server boxes with their position on the image
    for (TickBoxHolder tickBox : mServerTickBoxes) {
        tickBox.setImagePosition(QRImageParser.getImagePosition(mImageParameters, tickBox.location));
    }/*from w  ww .j  a  v a  2 s  .co  m*/

    // first pass - match ticked boxes on the image with ticked boxes from the server
    for (PointF p : mImageTickBoxes) {

        // check that we're not too close to a QR code
        boolean qrBox = false;
        for (int q = 0, qn = Math.min(mCodeParameters.mIdPoints.length,
                mCodeParameters.mAlignmentPoints.length); q < qn; q++) {
            PointF idP = mCodeParameters.mIdPoints[q];
            PointF alignP = mCodeParameters.mAlignmentPoints[q];
            double pX1 = (idP.x - p.x);
            double pY1 = (idP.y - p.y);
            double pX2 = (alignP.x - p.x);
            double pY2 = (alignP.y - p.y);
            if (((pX1 * pX1) + (pY1 * pY1)) < maximumQRCodeDistanceSquared
                    || ((pX2 * pX2) + (pY2 * pY2)) < maximumQRCodeDistanceSquared) {
                qrBox = true;
                break;
            }
        }
        if (qrBox) {
            // Log.d(TAG, "Box seems to be a QR point - ignoring");
            continue;
        }

        float minDistance = Float.MAX_VALUE;
        TickBoxHolder assignedBox = null;
        for (TickBoxHolder tickBox : mServerTickBoxes) {
            if (tickBox.foundOnImage) {
                continue;
            }

            PointF pos = tickBox.imagePosition;
            float boxDistance = (float) Math.sqrt(Math.pow(p.x - pos.x, 2) + Math.pow(p.y - pos.y, 2));
            if (boxDistance < maximumBoxDistance && boxDistance < minDistance) {
                assignedBox = tickBox;
                minDistance = boxDistance;
            }
        }
        if (assignedBox != null) {
            Log.d(TAG, "Found closest box (" + assignedBox.description + ") at " + minDistance + " distance");
            assignedBox.foundOnImage = true;
            assignedBox.ticked = false;
        } else {
            Log.d(TAG, "Couldn't find actual box for detected box at " + minDistance + " distance");
        }
    }

    // second pass - un-tick any boxes that are still marked as ticked, but are actually outside the image,
    // then add an animated tick box on those that remain
    boolean tickedBoxes = false;
    for (TickBoxHolder tickBox : mServerTickBoxes) {
        if (tickBox.ticked) {
            PointF imagePosition = tickBox.imagePosition;
            try {
                if (mBitmap.getPixel((int) imagePosition.x, (int) imagePosition.y) == Color.TRANSPARENT) {
                    tickBox.ticked = false;
                    Log.d(TAG, "Un-ticking box outside the image (" + tickBox.description + " " + "at "
                            + imagePosition.x + "," + imagePosition.y + ")");
                }
            } catch (IllegalArgumentException e) {
                tickBox.ticked = false;
                Log.d(TAG, "Un-ticking box with invalid image coordinate (" + tickBox.description + ") at "
                        + imagePosition.x + "," + imagePosition.y);
            }

            if (tickBox.ticked) {
                Log.d(TAG, "Ticked box (" + tickBox.description + ") found at " + imagePosition.x + ","
                        + +imagePosition.y);

                // add a tick overlay on each ticked box, and allow clicking to tick/un-tick any box
                addTickHighlight(tickBox);
                tickedBoxes = true;
            }
        }
    }

    findViewById(R.id.parse_progress).setVisibility(View.GONE);

    getSupportActionBar().setTitle(R.string.title_activity_order);
    mEmailContents = getEmailMessage();
    supportInvalidateOptionsMenu(); // to show the place order button (if required) & rescan option
    Toast.makeText(TicQRActivity.this, tickedBoxes ? R.string.hint_send_order : R.string.hint_no_boxes_found,
            Toast.LENGTH_SHORT).show();
}

From source file:com.example.xusoku.dragtopviewdemo.DragTopLayout.java

private void resetDispatchingContentView() {
    dispatchingChildrenDownFaked = false;
    dispatchingChildrenContentView = false;
    dispatchingChildrenStartedAtY = Float.MAX_VALUE;
}

From source file:br.com.marcioaleson.androidgooglemobilevision.BarcodeCaptureActivity.java

/**
 * onTap returns the tapped barcode result to the calling Activity.
 *
 * @param rawX - the raw position of the tap
 * @param rawY - the raw position of the tap.
 * @return true if the activity is ending.
 *///  w  w w  .  j a  v  a 2s . c  o  m
private boolean onTap(float rawX, float rawY) {
    // Find tap point in preview frame coordinates.
    int[] location = new int[2];
    mGraphicOverlay.getLocationOnScreen(location);
    float x = (rawX - location[0]) / mGraphicOverlay.getWidthScaleFactor();
    float y = (rawY - location[1]) / mGraphicOverlay.getHeightScaleFactor();

    // Find the barcode whose center is closest to the tapped point.
    Barcode best = null;
    float bestDistance = Float.MAX_VALUE;
    for (BarcodeGraphic graphic : mGraphicOverlay.getGraphics()) {
        Barcode barcode = graphic.getBarcode();
        if (barcode.getBoundingBox().contains((int) x, (int) y)) {
            // Exact hit, no need to keep looking.
            best = barcode;
            break;
        }
        float dx = x - barcode.getBoundingBox().centerX();
        float dy = y - barcode.getBoundingBox().centerY();
        float distance = (dx * dx) + (dy * dy); // actually squared distance
        if (distance < bestDistance) {
            best = barcode;
            bestDistance = distance;
        }
    }

    if (best != null) {
        Intent data = new Intent();
        data.putExtra(BarcodeObject, best);
        setResult(CommonStatusCodes.SUCCESS, data);
        finish();
        return true;
    }
    return false;
}