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.felipeacerbi.nfctest.activities.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.
 *//*from www  .  j  a v a 2s . c om*/
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(Activity.RESULT_OK, data);
        finish();
        return true;
    }
    return false;
}

From source file:pipeline.misc_util.Utils.java

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

From source file:com.apm4all.tracy.TracyTest.java

@Test
public void testGetEvents_floatAnnotation() throws InterruptedException {
    final String FLOAT_NAME = "floatName";
    float floatValue = Float.MAX_VALUE;
    Tracy.setContext(TASK_ID_VALUE, PARENT_OPT_ID_VALUE, COMPONENT_VALUE);
    Tracy.before(L1_LABEL_NAME);//from w  ww.j a va2  s  .  co m
    Tracy.annotate(FLOAT_NAME, floatValue);
    Tracy.after(L1_LABEL_NAME);
    List<TracyEvent> events = Tracy.getEvents();
    assertEquals(1, events.size());
    TracyEvent event = events.get(0);
    assertEquals(TASK_ID_VALUE, event.getTaskId());
    assertEquals(PARENT_OPT_ID_VALUE, event.getParentOptId());
    assertEquals(L1_LABEL_NAME, event.getLabel());
    assertEquals(event.getAnnotation(FLOAT_NAME), new Float(floatValue));
    assertEquals(new Float(floatValue), Tracy.getEventsAsMaps().get(0).get(FLOAT_NAME));
    String jsonEvent = Tracy.getEventsAsJson().get(0);
    assertTrue(jsonEvent.contains("\"" + FLOAT_NAME + "\":" + Float.toString(floatValue)));
    Tracy.clearContext();
}

From source file:com.google.android.gms.samples.vision.barcodereader.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.
 *//*from  ww  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;
    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();
        for (BarcodeGraphic graphic : mGraphicOverlay.getGraphics()) {
            Barcode barcode = graphic.getBarcode();
            if (isLeftBarcode(barcode)) {
                data.putExtra(BarcodeObjectLeft, barcode);
            }
            if (isRightBarcode(barcode)) {
                data.putExtra(BarcodeObjectRight, barcode);
            }
        }

        setResult(CommonStatusCodes.SUCCESS, data);
        finish();
        return true;
    }
    return false;
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java

@Test
public void testConfigurationXMLWithFloatArray() {
    ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray();

    Float floatValue = config.floatArray[0];

    assertEquals(Float.class, floatValue.getClass());
    assertEquals(Float.MAX_VALUE, floatValue.floatValue(), 1);
    assertEquals(5, config.floatArray.length);
}

From source file:pipeline.misc_util.Utils.java

private static void findMinMax(float[] a, MinMax m) {
    float max = -Float.MAX_VALUE;
    float min = Float.MAX_VALUE;
    for (float element : a) {
        if (element > max)
            max = element;/*  ww  w  .j av  a 2 s  .  co m*/
        if (element < min)
            min = element;
    }
    m.max = max;
    m.min = min;
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java

@Test
public void testConfigurationXMLWithFloatList() {
    ConfigurationXMLWithList config = prepareConfigurationXMLWithList();

    Float floatValue = config.floatList.get(0);

    assertEquals(Float.class, floatValue.getClass());
    assertEquals(Float.MAX_VALUE, floatValue.floatValue(), 1);
    assertEquals(5, config.floatList.size());
}

From source file:org.apache.flink.table.codegen.SortCodeGeneratorTest.java

private Object value3(InternalType type, Random rnd) {
    if (type.equals(InternalTypes.BOOLEAN)) {
        return true;
    } else if (type.equals(InternalTypes.BYTE)) {
        return Byte.MAX_VALUE;
    } else if (type.equals(InternalTypes.SHORT)) {
        return Short.MAX_VALUE;
    } else if (type.equals(InternalTypes.INT)) {
        return Integer.MAX_VALUE;
    } else if (type.equals(InternalTypes.LONG)) {
        return Long.MAX_VALUE;
    } else if (type.equals(InternalTypes.FLOAT)) {
        return Float.MAX_VALUE;
    } else if (type.equals(InternalTypes.DOUBLE)) {
        return Double.MAX_VALUE;
    } else if (type.equals(InternalTypes.STRING)) {
        return BinaryString.fromString(RandomStringUtils.random(100));
    } else if (type instanceof DecimalType) {
        DecimalType decimalType = (DecimalType) type;
        return Decimal.fromBigDecimal(new BigDecimal(Integer.MAX_VALUE), decimalType.precision(),
                decimalType.scale());/*from ww  w. ja  v  a2 s .c om*/
    } else if (type instanceof ArrayType || type.equals(InternalTypes.BINARY)) {
        byte[] bytes = new byte[rnd.nextInt(100) + 100];
        rnd.nextBytes(bytes);
        return type.equals(InternalTypes.BINARY) ? bytes : BinaryArray.fromPrimitiveArray(bytes);
    } else if (type instanceof RowType) {
        RowType rowType = (RowType) type;
        if (rowType.getTypeAt(0).equals(InternalTypes.INT)) {
            return GenericRow.of(rnd.nextInt());
        } else {
            return GenericRow.of(GenericRow.of(rnd.nextInt()));
        }
    } else if (type instanceof GenericType) {
        return new BinaryGeneric<>(rnd.nextInt(), IntSerializer.INSTANCE);
    } else {
        throw new RuntimeException("Not support!");
    }
}

From source file:pipeline.misc_util.Utils.java

public static void updateRangeInStack(ImagePlus imp) {
    float max = -Float.MAX_VALUE;
    float min = Float.MAX_VALUE;
    int nSlices = imp.getNSlices();
    int nChannels = imp.getNChannels();
    MinMax m = new MinMax();
    for (int i = 1; i <= nSlices; i++) {
        Object pixels = imp.getStack().getPixels((i - 1) * nChannels + imp.getChannel());
        float sliceMax = 0;
        float sliceMin = 0;
        if (pixels instanceof float[]) {
            findMinMax((float[]) pixels, m);
        } else if (pixels instanceof byte[]) {
            findMinMax((byte[]) pixels, m);
        } else if (pixels instanceof short[]) {
            findMinMax((short[]) pixels, m);
        }/*from w  w  w.j ava  2  s.  c o  m*/
        sliceMax = m.max;
        sliceMin = m.min;
        if (sliceMax > max)
            max = sliceMax;
        if (sliceMin < min)
            min = sliceMin;
    }

    imp.setDisplayRange(min, max);
    imp.updateChannelAndDraw();
}

From source file:org.apache.hadoop.hbase.master.balancer.LocalityAwareLoadBalancer.java

private float getLocalityIndex(HRegionInfo region, ServerAndLoad server) {
    try {/*from www  .  j  a  v a2  s  .c o  m*/
        HTableDescriptor tableDescriptor = this.services.getTableDescriptors().get(region.getTable());
        if (tableDescriptor != null) {
            HDFSBlocksDistribution blocksDistribution = HRegion.computeHDFSBlocksDistribution(getConf(),
                    tableDescriptor, region);
            return blocksDistribution.getBlockLocalityIndex(server.getServerName().getHostname());

        }
    } catch (IOException ioe) {
        LOG.debug("IOException during HDFSBlocksDistribution computation. for " + "region = "
                + region.getEncodedName(), ioe);
    }
    return Float.MAX_VALUE;
}