Example usage for java.lang Float MIN_VALUE

List of usage examples for java.lang Float MIN_VALUE

Introduction

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

Prototype

float MIN_VALUE

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

Click Source Link

Document

A constant holding the smallest positive nonzero value of type float , 2-149.

Usage

From source file:jp.terasoluna.fw.validation.FieldChecks.java

/**
 * ???float??????//from  ww  w.  jav a 2 s  . c om
 * ??????
 *
 * <p>???10?100???????????
 * true?????
 *
 * <h5>validation.xml?</h5>
 * <code><pre>
 * &lt;form name=&quot;sample&quot;&gt;
 *  
 *  &lt;field property=&quot;floatField&quot;
 *      depends=&quot;floatRange&quot;&gt;
 *    &lt;arg key=&quot;sample.floatField&quot; position="0"/&gt;
 *    &lt;var&gt;
 *      &lt;var-name&gt;floatRangeMin&lt;/var-name&gt;
 *      &lt;var-value&gt;10&lt;/var-value&gt;
 *    &lt;/var&gt;
 *    &lt;var&gt;
 *      &lt;var-name&gt;floatRangeMax&lt;/var-name&gt;
 *      &lt;var-value&gt;100&lt;/var-value&gt;
 *    &lt;/var&gt;
 *  &lt;/field&gt;
 *  
 * &lt;/form&gt;
 * </pre></code>
 *
 * <h5>validation.xml???&lt;var&gt;?</h5>
 * <table border="1">
 *  <tr>
 *   <td><center><b><code>var-name</code></b></center></td>
 *   <td><center><b><code>var-value</code></b></center></td>
 *   <td><center><b></b></center></td>
 *   <td><center><b>?</b></center></td>
 *  </tr>
 *  <tr>
 *   <td> floatRangeMin </td>
 *   <td>?</td>
 *   <td>false</td>
 *   <td>????????Float???
 *   ?
 *   ????????</td>
 *  </tr>
 *  <tr>
 *   <td> floatRangeMax </td>
 *   <td></td>
 *   <td>false</td>
 *   <td>???????Float??
 *   ?
 *   ????????</td>
 *  </tr>
 * </table>
 *
 * @param bean ?JavaBean
 * @param va ?<code>ValidatorAction</code>
 * @param field ?<code>Field</code>
 * @param errors ?????
 * ??
 * @return ??????<code>true</code>?
 * ????<code>false</code>?
 * @throws ValidatorException validation??????
 * ?
 */
public boolean validateFloatRange(Object bean, ValidatorAction va, Field field, ValidationErrors errors)
        throws ValidatorException {
    // 
    String value = extractValue(bean, field);
    if (StringUtils.isEmpty(value)) {
        return true;
    }

    // float?? --- Float??????
    float floatValue = 0;
    try {
        floatValue = Float.parseFloat(value);
    } catch (NumberFormatException e) {
        rejectValue(errors, field, va, bean);
        return false;
    }

    //  --- ?Float??????
    //                ????
    String strMin = field.getVarValue("floatRangeMin");
    float min = Float.MIN_VALUE;
    if (!GenericValidator.isBlankOrNull(strMin)) {
        try {
            min = Float.parseFloat(strMin);
        } catch (NumberFormatException e) {
            String message = "Mistake on validation definition file. " + "- floatRangeMin is not number. "
                    + "You'll have to check it over. ";
            log.error(message, e);
            throw new ValidatorException(message);
        }
    }
    String strMax = field.getVarValue("floatRangeMax");
    float max = Float.MAX_VALUE;
    if (!GenericValidator.isBlankOrNull(strMax)) {
        try {
            max = Float.parseFloat(strMax);
        } catch (NumberFormatException e) {
            String message = "Mistake on validation definition file. " + "- floatRangeMax is not number. "
                    + "You'll have to check it over. ";
            log.error(message, e);
            throw new ValidatorException(message);
        }
    }

    // 
    if (!GenericValidator.isInRange(floatValue, min, max)) {
        rejectValue(errors, field, va, bean);
        return false;
    }
    return true;
}

From source file:SIFT_Volume_Stitching.java

float[] getAndApplyMinMax(final ArrayList<ImageInformation> imageInformationList, final int dim) {
    float min[] = new float[dim];
    float max[] = new float[dim];
    for (int i = 0; i < min.length; i++) {
        min[i] = Float.MAX_VALUE;
        max[i] = Float.MIN_VALUE;
    }/* w  ww.  ja  v  a  2s  .  c  o  m*/

    for (ImageInformation iI : imageInformationList)
        for (int i = 0; i < min.length; i++) {
            if (iI.position[i] < min[i])
                min[i] = iI.position[i];

            if (iI.position[i] + iI.size[i] > max[i])
                max[i] = iI.position[i] + iI.size[i];
        }

    for (ImageInformation iI : imageInformationList)
        for (int i = 0; i < min.length; i++)
            iI.position[i] -= min[i];

    for (int i = 0; i < min.length; i++) {
        max[i] -= min[i];
        min[i] = 0;
    }

    return max;
}

From source file:com.zwj.customview.gesturelock.PatternView.java

@Override
protected void onDraw(Canvas canvas) {
    final ArrayList<Cell> pattern = mPattern;
    final int count = pattern.size();
    final boolean[][] drawLookup = mPatternDrawLookup;

    if (mPatternDisplayMode == DisplayMode.Animate) {

        // figure out which circles to draw

        // + 1 so we pause on complete pattern
        final int oneCycle = (count + 1) * MILLIS_PER_CIRCLE_ANIMATING;
        final int spotInCycle = (int) (SystemClock.elapsedRealtime() - mAnimatingPeriodStart) % oneCycle;
        final int numCircles = spotInCycle / MILLIS_PER_CIRCLE_ANIMATING;

        clearPatternDrawLookup();/*from w w w .j a v a 2 s .c  o  m*/
        for (int i = 0; i < numCircles; i++) {
            final Cell cell = pattern.get(i);
            drawLookup[cell.getRow()][cell.getColumn()] = true;
        }

        // figure out in progress portion of ghosting line

        final boolean needToUpdateInProgressPoint = numCircles > 0 && numCircles < count;

        if (needToUpdateInProgressPoint) {
            final float percentageOfNextCircle = ((float) (spotInCycle % MILLIS_PER_CIRCLE_ANIMATING))
                    / MILLIS_PER_CIRCLE_ANIMATING;

            final Cell currentCell = pattern.get(numCircles - 1);
            final float centerX = getCenterXForColumn(currentCell.column);
            final float centerY = getCenterYForRow(currentCell.row);

            final Cell nextCell = pattern.get(numCircles);
            final float dx = percentageOfNextCircle * (getCenterXForColumn(nextCell.column) - centerX);
            final float dy = percentageOfNextCircle * (getCenterYForRow(nextCell.row) - centerY);
            mInProgressX = centerX + dx;
            mInProgressY = centerY + dy;
        }
        // TODO: Infinite loop here...
        invalidate();
    }

    final Path currentPath = mCurrentPath;
    currentPath.rewind();

    // draw the circles
    for (int i = 0; i < mRowCount; i++) {
        float centerY = getCenterYForRow(i);
        for (int j = 0; j < mColumnCount; j++) {
            CellState cellState = mCellStates[i][j];
            float centerX = getCenterXForColumn(j);
            float translationY = cellState.translationY;

            // TODO 
            drawCircle(canvas, (int) centerX, (int) centerY + translationY, cellState.radius, drawLookup[i][j],
                    cellState.alpha);
        }
    }

    // TODO: the path should be created and cached every time we hit-detect a cell
    // only the last segment of the path should be computed here
    // draw the path of the pattern (unless we are in stealth mode)
    final boolean drawPath = !mInStealthMode;

    if (drawPath) {

        mPathPaint.setColor(getCurrentColor(true /* partOfPattern */));
        // Anyway other drawing sets their own alpha ignoring the original; And in this way we
        // can use ?colorControlNormal better.
        mPathPaint.setAlpha(255);

        boolean anyCircles = false;
        float lastX = 0f;
        float lastY = 0f;
        for (int i = 0; i < count; i++) {
            Cell cell = pattern.get(i);

            // only draw the part of the pattern stored in
            // the lookup table (this is only different in the case
            // of animation).
            if (!drawLookup[cell.row][cell.column]) {
                break;
            }
            anyCircles = true;

            float centerX = getCenterXForColumn(cell.column);
            float centerY = getCenterYForRow(cell.row);
            if (i != 0) {
                CellState state = mCellStates[cell.row][cell.column];
                currentPath.rewind();
                currentPath.moveTo(lastX, lastY);
                if (state.lineEndX != Float.MIN_VALUE && state.lineEndY != Float.MIN_VALUE) {
                    currentPath.lineTo(state.lineEndX, state.lineEndY);
                } else {
                    currentPath.lineTo(centerX, centerY);
                }
                canvas.drawPath(currentPath, mPathPaint);
            }
            lastX = centerX;
            lastY = centerY;
        }

        // draw last in progress section
        if ((mPatternInProgress || mPatternDisplayMode == DisplayMode.Animate) && anyCircles) {
            currentPath.rewind();
            currentPath.moveTo(lastX, lastY);
            currentPath.lineTo(mInProgressX, mInProgressY);

            mPathPaint.setAlpha(
                    (int) (calculateLastSegmentAlpha(mInProgressX, mInProgressY, lastX, lastY) * 255f));
            canvas.drawPath(currentPath, mPathPaint);
        }
    }
}

From source file:org.fao.geonet.kernel.search.LuceneQueryBuilder.java

public static NumericRangeQuery buildNumericRangeQueryForType(String fieldName, String min, String max,
        boolean minInclusive, boolean maxInclusive, String type) {
    NumericRangeQuery rangeQuery;/*from  w w w .j a v a2s.  c  o  m*/
    if ("double".equals(type)) {
        rangeQuery = NumericRangeQuery.newDoubleRange(fieldName,
                (min == null ? Double.MIN_VALUE : Double.valueOf(min)),
                (max == null ? Double.MAX_VALUE : Double.valueOf(max)), true, true);

    } else if ("float".equals(type)) {
        rangeQuery = NumericRangeQuery.newFloatRange(fieldName,
                (min == null ? Float.MIN_VALUE : Float.valueOf(min)),
                (max == null ? Float.MAX_VALUE : Float.valueOf(max)), true, true);
    } else if ("long".equals(type)) {
        rangeQuery = NumericRangeQuery.newLongRange(fieldName,
                (min == null ? Long.MIN_VALUE : Long.valueOf(min)),
                (max == null ? Long.MAX_VALUE : Long.valueOf(max)), true, true);
    } else {
        rangeQuery = NumericRangeQuery.newIntRange(fieldName,
                (min == null ? Integer.MIN_VALUE : Integer.valueOf(min)),
                (max == null ? Integer.MAX_VALUE : Integer.valueOf(max)), true, true);
    }
    return rangeQuery;
}

From source file:io.authme.sdk.widget.LockPatternView.java

@Override
protected void onDraw(Canvas canvas) {
    final ArrayList<Cell> pattern = mPattern;
    final int count = pattern.size();
    final boolean[][] drawLookup = mPatternDrawLookup;

    if (mPatternDisplayMode == DisplayMode.Animate) {

        // figure out which circles to draw

        // + 1 so we pause on complete pattern
        final int oneCycle = (count + 1) * MILLIS_PER_CIRCLE_ANIMATING;
        final int spotInCycle = (int) (SystemClock.elapsedRealtime() - mAnimatingPeriodStart) % oneCycle;
        final int numCircles = spotInCycle / MILLIS_PER_CIRCLE_ANIMATING;

        clearPatternDrawLookup();/*  w  w w  .  jav a 2s  . com*/
        for (int i = 0; i < numCircles; i++) {
            final Cell cell = pattern.get(i);
            drawLookup[cell.row][cell.column] = true;
        }

        // figure out in progress portion of ghosting line

        final boolean needToUpdateInProgressPoint = numCircles > 0 && numCircles < count;

        if (needToUpdateInProgressPoint) {
            final float percentageOfNextCircle = ((float) (spotInCycle % MILLIS_PER_CIRCLE_ANIMATING))
                    / MILLIS_PER_CIRCLE_ANIMATING;

            final Cell currentCell = pattern.get(numCircles - 1);
            final float centerX = getCenterXForColumn(currentCell.column);
            final float centerY = getCenterYForRow(currentCell.row);

            final Cell nextCell = pattern.get(numCircles);
            final float dx = percentageOfNextCircle * (getCenterXForColumn(nextCell.column) - centerX);
            final float dy = percentageOfNextCircle * (getCenterYForRow(nextCell.row) - centerY);
            mInProgressX = centerX + dx;
            mInProgressY = centerY + dy;
        }
        // TODO: Infinite loop here...
        invalidate();
    }

    final Path currentPath = mCurrentPath;
    currentPath.rewind();

    // draw the circles
    for (int i = 0; i < MATRIX_WIDTH; i++) {
        float centerY = getCenterYForRow(i);
        for (int j = 0; j < MATRIX_WIDTH; j++) {
            CellState cellState = mCellStates[i][j];
            float centerX = getCenterXForColumn(j);
            float size = cellState.size * cellState.scale;
            float translationY = cellState.translateY;
            drawCircle(canvas, (int) centerX, (int) centerY + translationY, size, drawLookup[i][j],
                    cellState.alpha);
        }
    }

    // TODO: the path should be created and cached every time we hit-detect
    // a cell
    // only the last segment of the path should be computed here
    // draw the path of the pattern (unless we are in stealth mode)
    final boolean drawPath = !mInStealthMode;

    if (drawPath) {
        mPathPaint.setColor(getCurrentColor(true /* partOfPattern */));

        boolean anyCircles = false;
        float lastX = 0f;
        float lastY = 0f;
        for (int i = 0; i < count; i++) {
            Cell cell = pattern.get(i);

            // only draw the part of the pattern stored in
            // the lookup table (this is only different in the case
            // of animation).
            if (!drawLookup[cell.row][cell.column]) {
                break;
            }
            anyCircles = true;

            float centerX = getCenterXForColumn(cell.column);
            float centerY = getCenterYForRow(cell.row);
            if (i != 0) {
                CellState state = mCellStates[cell.row][cell.column];
                currentPath.rewind();
                currentPath.moveTo(lastX, lastY);
                if (state.lineEndX != Float.MIN_VALUE && state.lineEndY != Float.MIN_VALUE) {
                    currentPath.lineTo(state.lineEndX, state.lineEndY);
                } else {
                    currentPath.lineTo(centerX, centerY);
                }
                canvas.drawPath(currentPath, mPathPaint);
            }
            lastX = centerX;
            lastY = centerY;
        }

        // draw last in progress section
        if ((mPatternInProgress || mPatternDisplayMode == DisplayMode.Animate) && anyCircles) {
            currentPath.rewind();
            currentPath.moveTo(lastX, lastY);
            currentPath.lineTo(mInProgressX, mInProgressY);

            mPathPaint.setAlpha(
                    (int) (calculateLastSegmentAlpha(mInProgressX, mInProgressY, lastX, lastY) * 255f));
            canvas.drawPath(currentPath, mPathPaint);
        }
    }
}

From source file:com.actelion.research.table.view.JVisualization.java

private void updateColorIndices() {
    if (mMarkerColor.getColorColumn() == cColumnUnassigned) {
        for (int i = 0; i < mDataPoints; i++)
            mPoint[i].colorIndex = VisualizationColor.cDefaultDataColorIndex;
    } else if (CompoundTableHitlistHandler.isHitlistColumn(mMarkerColor.getColorColumn())) {
        int hitlistIndex = CompoundTableHitlistHandler.getHitlistFromColumn(mMarkerColor.getColorColumn());
        int flagNo = mTableModel.getHitlistHandler().getHitlistFlagNo(hitlistIndex);
        for (int i = 0; i < mDataPoints; i++)
            mPoint[i].colorIndex = (byte) (mPoint[i].record.isFlagSet(flagNo)
                    ? VisualizationColor.cSpecialColorCount
                    : VisualizationColor.cSpecialColorCount + 1);
    } else if (mTableModel.isDescriptorColumn(mMarkerColor.getColorColumn())) {
        setSimilarityColors(-1);/*from w  ww  .j a  v a  2 s  .c o m*/
    } else if (mMarkerColor.getColorListMode() == VisualizationColor.cColorListModeCategories) {
        for (int i = 0; i < mDataPoints; i++)
            mPoint[i].colorIndex = (byte) (VisualizationColor.cSpecialColorCount
                    + mTableModel.getCategoryIndex(mMarkerColor.getColorColumn(), mPoint[i].record));
    } else if (mTableModel.isColumnTypeDouble(mMarkerColor.getColorColumn())) {
        float min = Float.isNaN(mMarkerColor.getColorMin())
                ? mTableModel.getMinimumValue(mMarkerColor.getColorColumn())
                : (mTableModel.isLogarithmicViewMode(mMarkerColor.getColorColumn()))
                        ? (float) Math.log10(mMarkerColor.getColorMin())
                        : mMarkerColor.getColorMin();
        float max = Float.isNaN(mMarkerColor.getColorMax())
                ? mTableModel.getMaximumValue(mMarkerColor.getColorColumn())
                : (mTableModel.isLogarithmicViewMode(mMarkerColor.getColorColumn()))
                        ? (float) Math.log10(mMarkerColor.getColorMax())
                        : mMarkerColor.getColorMax();

        //   1. colorMin is explicitly set; max is real max, but lower than min
        // or 2. colorMax is explicitly set; min is real min, but larger than max
        // first case is OK, second needs adaption below to be handled as indented
        if (min >= max)
            if (!Float.isNaN(mMarkerColor.getColorMax()))
                min = Float.MIN_VALUE;

        for (int i = 0; i < mDataPoints; i++) {
            float value = mPoint[i].record.getDouble(mMarkerColor.getColorColumn());
            if (Float.isNaN(value))
                mPoint[i].colorIndex = VisualizationColor.cMissingDataColorIndex;
            else if (value <= min)
                mPoint[i].colorIndex = (byte) VisualizationColor.cSpecialColorCount;
            else if (value >= max)
                mPoint[i].colorIndex = (byte) (mMarkerColor.getColorList().length - 1);
            else
                mPoint[i].colorIndex = (byte) (0.5 + VisualizationColor.cSpecialColorCount
                        + (float) (mMarkerColor.getColorList().length - VisualizationColor.cSpecialColorCount
                                - 1) * (value - min) / (max - min));
        }
    }

    invalidateOffImage(true);
}

From source file:org.appcelerator.titanium.view.TiUIView.java

/**
 * "Forget" the values we save after scale and rotation and alpha animations.
 *//*  w  w  w .ja  v a 2 s  . c o  m*/
private void resetPostAnimationValues() {
    animatedRotationDegrees = 0f; // i.e., no rotation.
    animatedScaleValues = Pair.create(Float.valueOf(1f), Float.valueOf(1f)); // 1 means no scaling
    animatedAlpha = Float.MIN_VALUE; // we use min val to signal no val.
}

From source file:org.apache.rya.indexing.smarturi.duplication.DuplicateDataDetectorIT.java

@Test
public void testFloatProperty() throws SmartUriException {
    System.out.println("Float Property Test");
    final ImmutableList.Builder<TestInput> builder = ImmutableList.builder();
    // Tolerance 0.0
    Tolerance tolerance = new Tolerance(0.0, ToleranceType.DIFFERENCE);
    builder.add(new TestInput(Float.MIN_VALUE, tolerance, false));
    builder.add(new TestInput(-1.0f, tolerance, false));
    builder.add(new TestInput(0.0f, tolerance, false));
    builder.add(new TestInput(0.01f, tolerance, false));
    builder.add(new TestInput(0.02f, tolerance, false));
    builder.add(new TestInput(0.1f, tolerance, false));
    builder.add(new TestInput(0.2f, tolerance, false));
    builder.add(new TestInput(1.0f, tolerance, false));
    builder.add(new TestInput(250f, tolerance, false));
    builder.add(new TestInput(250.7f, tolerance, false));
    builder.add(new TestInput(250.72f, tolerance, false));
    builder.add(new TestInput(250.73f, tolerance, false));
    builder.add(new TestInput(250.74f, tolerance, false));
    builder.add(new TestInput(250.75f, tolerance, true)); // Equals value
    builder.add(new TestInput(250.76f, tolerance, false));
    builder.add(new TestInput(250.77f, tolerance, false));
    builder.add(new TestInput(250.78f, tolerance, false));
    builder.add(new TestInput(250.8f, tolerance, false));
    builder.add(new TestInput(251f, tolerance, false));
    builder.add(new TestInput(300.0f, tolerance, false));
    builder.add(new TestInput(Float.MAX_VALUE, tolerance, false));
    // Tolerance 0.01
    tolerance = new Tolerance(0.01, ToleranceType.DIFFERENCE);
    builder.add(new TestInput(Float.MIN_VALUE, tolerance, false));
    builder.add(new TestInput(-1.0f, tolerance, false));
    builder.add(new TestInput(0.0f, tolerance, false));
    builder.add(new TestInput(0.01f, tolerance, false));
    builder.add(new TestInput(0.02f, tolerance, false));
    builder.add(new TestInput(0.1f, tolerance, false));
    builder.add(new TestInput(0.2f, tolerance, false));
    builder.add(new TestInput(1.0f, tolerance, false));
    builder.add(new TestInput(250f, tolerance, false));
    builder.add(new TestInput(250.7f, tolerance, false));
    builder.add(new TestInput(250.72f, tolerance, false));
    builder.add(new TestInput(250.73f, tolerance, false));
    builder.add(new TestInput(250.74f, tolerance, true));
    builder.add(new TestInput(250.75f, tolerance, true)); // Equals value
    builder.add(new TestInput(250.76f, tolerance, true));
    builder.add(new TestInput(250.77f, tolerance, false));
    builder.add(new TestInput(250.78f, tolerance, false));
    builder.add(new TestInput(250.8f, tolerance, false));
    builder.add(new TestInput(251f, tolerance, false));
    builder.add(new TestInput(300.0f, tolerance, false));
    builder.add(new TestInput(Float.MAX_VALUE, tolerance, false));
    // Tolerance 0.02
    tolerance = new Tolerance(0.02, ToleranceType.DIFFERENCE);
    builder.add(new TestInput(Float.MIN_VALUE, tolerance, false));
    builder.add(new TestInput(-1.0f, tolerance, false));
    builder.add(new TestInput(0.0f, tolerance, false));
    builder.add(new TestInput(0.01f, tolerance, false));
    builder.add(new TestInput(0.02f, tolerance, false));
    builder.add(new TestInput(0.1f, tolerance, false));
    builder.add(new TestInput(0.2f, tolerance, false));
    builder.add(new TestInput(1.0f, tolerance, false));
    builder.add(new TestInput(250f, tolerance, false));
    builder.add(new TestInput(250.7f, tolerance, false));
    builder.add(new TestInput(250.72f, tolerance, false));
    builder.add(new TestInput(250.73f, tolerance, true));
    builder.add(new TestInput(250.74f, tolerance, true));
    builder.add(new TestInput(250.75f, tolerance, true)); // Equals value
    builder.add(new TestInput(250.76f, tolerance, true));
    builder.add(new TestInput(250.77f, tolerance, true));
    builder.add(new TestInput(250.78f, tolerance, false));
    builder.add(new TestInput(250.8f, tolerance, false));
    builder.add(new TestInput(251f, tolerance, false));
    builder.add(new TestInput(300.0f, tolerance, false));
    builder.add(new TestInput(Float.MAX_VALUE, tolerance, false));

    // Tolerance 0.0%
    tolerance = new Tolerance(0.0, ToleranceType.PERCENTAGE);
    builder.add(new TestInput(Float.MIN_VALUE, tolerance, false));
    builder.add(new TestInput(-1.0f, tolerance, false));
    builder.add(new TestInput(0.0f, tolerance, false));
    builder.add(new TestInput(0.01f, tolerance, false));
    builder.add(new TestInput(0.02f, tolerance, false));
    builder.add(new TestInput(0.1f, tolerance, false));
    builder.add(new TestInput(0.2f, tolerance, false));
    builder.add(new TestInput(1.0f, tolerance, false));
    builder.add(new TestInput(248.2424f, tolerance, false));
    builder.add(new TestInput(248.2425f, tolerance, false));
    builder.add(new TestInput(248.2426f, tolerance, false));
    builder.add(new TestInput(250f, tolerance, false));
    builder.add(new TestInput(250.7f, tolerance, false));
    builder.add(new TestInput(250.72f, tolerance, false));
    builder.add(new TestInput(250.73f, tolerance, false));
    builder.add(new TestInput(250.74f, tolerance, false));
    builder.add(new TestInput(250.75f, tolerance, true)); // Equals value
    builder.add(new TestInput(250.76f, tolerance, false));
    builder.add(new TestInput(250.77f, tolerance, false));
    builder.add(new TestInput(250.78f, tolerance, false));
    builder.add(new TestInput(250.8f, tolerance, false));
    builder.add(new TestInput(251f, tolerance, false));
    builder.add(new TestInput(253.2574f, tolerance, false));
    builder.add(new TestInput(253.2575f, tolerance, false));
    builder.add(new TestInput(253.2576f, tolerance, false));
    builder.add(new TestInput(300.0f, tolerance, false));
    builder.add(new TestInput(Float.MAX_VALUE, tolerance, false));
    // Tolerance 1.0%
    tolerance = new Tolerance(0.01, ToleranceType.PERCENTAGE);
    builder.add(new TestInput(Float.MIN_VALUE, tolerance, false));
    builder.add(new TestInput(-1.0f, tolerance, false));
    builder.add(new TestInput(0.0f, tolerance, false));
    builder.add(new TestInput(0.01f, tolerance, false));
    builder.add(new TestInput(0.02f, tolerance, false));
    builder.add(new TestInput(0.1f, tolerance, false));
    builder.add(new TestInput(0.2f, tolerance, false));
    builder.add(new TestInput(1.0f, tolerance, false));
    builder.add(new TestInput(248.2424f, tolerance, false));
    builder.add(new TestInput(248.2425f, tolerance, true));
    builder.add(new TestInput(248.2426f, tolerance, true));
    builder.add(new TestInput(250f, tolerance, true));
    builder.add(new TestInput(250.7f, tolerance, true));
    builder.add(new TestInput(250.72f, tolerance, true));
    builder.add(new TestInput(250.73f, tolerance, true));
    builder.add(new TestInput(250.74f, tolerance, true));
    builder.add(new TestInput(250.75f, tolerance, true)); // Equals value
    builder.add(new TestInput(250.76f, tolerance, true));
    builder.add(new TestInput(250.77f, tolerance, true));
    builder.add(new TestInput(250.78f, tolerance, true));
    builder.add(new TestInput(250.8f, tolerance, true));
    builder.add(new TestInput(251f, tolerance, true));
    builder.add(new TestInput(253.2574f, tolerance, true));
    builder.add(new TestInput(253.2575f, tolerance, true));
    builder.add(new TestInput(253.2576f, tolerance, false));
    builder.add(new TestInput(300.0f, tolerance, false));
    builder.add(new TestInput(Float.MAX_VALUE, tolerance, false));
    // Tolerance 100.0%
    tolerance = new Tolerance(1.00, ToleranceType.PERCENTAGE);
    builder.add(new TestInput(Float.MIN_VALUE, tolerance, true));
    builder.add(new TestInput(-1.0f, tolerance, true));
    builder.add(new TestInput(0.0f, tolerance, true));
    builder.add(new TestInput(0.01f, tolerance, true));
    builder.add(new TestInput(0.02f, tolerance, true));
    builder.add(new TestInput(0.1f, tolerance, true));
    builder.add(new TestInput(0.2f, tolerance, true));
    builder.add(new TestInput(1.0f, tolerance, true));
    builder.add(new TestInput(248.2424f, tolerance, true));
    builder.add(new TestInput(248.2425f, tolerance, true));
    builder.add(new TestInput(248.2426f, tolerance, true));
    builder.add(new TestInput(250f, tolerance, true));
    builder.add(new TestInput(250.7f, tolerance, true));
    builder.add(new TestInput(250.72f, tolerance, true));
    builder.add(new TestInput(250.73f, tolerance, true));
    builder.add(new TestInput(250.74f, tolerance, true));
    builder.add(new TestInput(250.75f, tolerance, true)); // Equals value
    builder.add(new TestInput(250.76f, tolerance, true));
    builder.add(new TestInput(250.77f, tolerance, true));
    builder.add(new TestInput(250.78f, tolerance, true));
    builder.add(new TestInput(250.8f, tolerance, true));
    builder.add(new TestInput(251f, tolerance, true));
    builder.add(new TestInput(253.2574f, tolerance, true));
    builder.add(new TestInput(253.2575f, tolerance, true));
    builder.add(new TestInput(253.2576f, tolerance, true));
    builder.add(new TestInput(300.0f, tolerance, true));
    builder.add(new TestInput(Float.MAX_VALUE, tolerance, true));

    final ImmutableList<TestInput> testInputs = builder.build();

    testProperty(testInputs, PERSON_TYPE_URI, HAS_WEIGHT);
}

From source file:org.apache.rya.indexing.smarturi.duplication.DuplicateDataDetectorTest.java

@Test
public void testFloatProperty() throws SmartUriException {
    System.out.println("Float Property Test");
    final ImmutableList.Builder<TestInput> builder = ImmutableList.<TestInput>builder();
    // Tolerance 0.0
    Tolerance tolerance = new Tolerance(0.0, ToleranceType.DIFFERENCE);
    builder.add(new TestInput(Float.MIN_VALUE, tolerance, false));
    builder.add(new TestInput(-1.0f, tolerance, false));
    builder.add(new TestInput(0.0f, tolerance, false));
    builder.add(new TestInput(0.01f, tolerance, false));
    builder.add(new TestInput(0.02f, tolerance, false));
    builder.add(new TestInput(0.1f, tolerance, false));
    builder.add(new TestInput(0.2f, tolerance, false));
    builder.add(new TestInput(1.0f, tolerance, false));
    builder.add(new TestInput(250f, tolerance, false));
    builder.add(new TestInput(250.7f, tolerance, false));
    builder.add(new TestInput(250.72f, tolerance, false));
    builder.add(new TestInput(250.73f, tolerance, false));
    builder.add(new TestInput(250.74f, tolerance, false));
    builder.add(new TestInput(250.75f, tolerance, true)); // Equals value
    builder.add(new TestInput(250.76f, tolerance, false));
    builder.add(new TestInput(250.77f, tolerance, false));
    builder.add(new TestInput(250.78f, tolerance, false));
    builder.add(new TestInput(250.8f, tolerance, false));
    builder.add(new TestInput(251f, tolerance, false));
    builder.add(new TestInput(300.0f, tolerance, false));
    builder.add(new TestInput(Float.MAX_VALUE, tolerance, false));
    // Tolerance 0.01
    tolerance = new Tolerance(0.01, ToleranceType.DIFFERENCE);
    builder.add(new TestInput(Float.MIN_VALUE, tolerance, false));
    builder.add(new TestInput(-1.0f, tolerance, false));
    builder.add(new TestInput(0.0f, tolerance, false));
    builder.add(new TestInput(0.01f, tolerance, false));
    builder.add(new TestInput(0.02f, tolerance, false));
    builder.add(new TestInput(0.1f, tolerance, false));
    builder.add(new TestInput(0.2f, tolerance, false));
    builder.add(new TestInput(1.0f, tolerance, false));
    builder.add(new TestInput(250f, tolerance, false));
    builder.add(new TestInput(250.7f, tolerance, false));
    builder.add(new TestInput(250.72f, tolerance, false));
    builder.add(new TestInput(250.73f, tolerance, false));
    builder.add(new TestInput(250.74f, tolerance, true));
    builder.add(new TestInput(250.75f, tolerance, true)); // Equals value
    builder.add(new TestInput(250.76f, tolerance, true));
    builder.add(new TestInput(250.77f, tolerance, false));
    builder.add(new TestInput(250.78f, tolerance, false));
    builder.add(new TestInput(250.8f, tolerance, false));
    builder.add(new TestInput(251f, tolerance, false));
    builder.add(new TestInput(300.0f, tolerance, false));
    builder.add(new TestInput(Float.MAX_VALUE, tolerance, false));
    // Tolerance 0.02
    tolerance = new Tolerance(0.02, ToleranceType.DIFFERENCE);
    builder.add(new TestInput(Float.MIN_VALUE, tolerance, false));
    builder.add(new TestInput(-1.0f, tolerance, false));
    builder.add(new TestInput(0.0f, tolerance, false));
    builder.add(new TestInput(0.01f, tolerance, false));
    builder.add(new TestInput(0.02f, tolerance, false));
    builder.add(new TestInput(0.1f, tolerance, false));
    builder.add(new TestInput(0.2f, tolerance, false));
    builder.add(new TestInput(1.0f, tolerance, false));
    builder.add(new TestInput(250f, tolerance, false));
    builder.add(new TestInput(250.7f, tolerance, false));
    builder.add(new TestInput(250.72f, tolerance, false));
    builder.add(new TestInput(250.73f, tolerance, true));
    builder.add(new TestInput(250.74f, tolerance, true));
    builder.add(new TestInput(250.75f, tolerance, true)); // Equals value
    builder.add(new TestInput(250.76f, tolerance, true));
    builder.add(new TestInput(250.77f, tolerance, true));
    builder.add(new TestInput(250.78f, tolerance, false));
    builder.add(new TestInput(250.8f, tolerance, false));
    builder.add(new TestInput(251f, tolerance, false));
    builder.add(new TestInput(300.0f, tolerance, false));
    builder.add(new TestInput(Float.MAX_VALUE, tolerance, false));

    // Tolerance 0.0%
    tolerance = new Tolerance(0.0, ToleranceType.PERCENTAGE);
    builder.add(new TestInput(Float.MIN_VALUE, tolerance, false));
    builder.add(new TestInput(-1.0f, tolerance, false));
    builder.add(new TestInput(0.0f, tolerance, false));
    builder.add(new TestInput(0.01f, tolerance, false));
    builder.add(new TestInput(0.02f, tolerance, false));
    builder.add(new TestInput(0.1f, tolerance, false));
    builder.add(new TestInput(0.2f, tolerance, false));
    builder.add(new TestInput(1.0f, tolerance, false));
    builder.add(new TestInput(248.2424f, tolerance, false));
    builder.add(new TestInput(248.2425f, tolerance, false));
    builder.add(new TestInput(248.2426f, tolerance, false));
    builder.add(new TestInput(250f, tolerance, false));
    builder.add(new TestInput(250.7f, tolerance, false));
    builder.add(new TestInput(250.72f, tolerance, false));
    builder.add(new TestInput(250.73f, tolerance, false));
    builder.add(new TestInput(250.74f, tolerance, false));
    builder.add(new TestInput(250.75f, tolerance, true)); // Equals value
    builder.add(new TestInput(250.76f, tolerance, false));
    builder.add(new TestInput(250.77f, tolerance, false));
    builder.add(new TestInput(250.78f, tolerance, false));
    builder.add(new TestInput(250.8f, tolerance, false));
    builder.add(new TestInput(251f, tolerance, false));
    builder.add(new TestInput(253.2574f, tolerance, false));
    builder.add(new TestInput(253.2575f, tolerance, false));
    builder.add(new TestInput(253.2576f, tolerance, false));
    builder.add(new TestInput(300.0f, tolerance, false));
    builder.add(new TestInput(Float.MAX_VALUE, tolerance, false));
    // Tolerance 1.0%
    tolerance = new Tolerance(0.01, ToleranceType.PERCENTAGE);
    builder.add(new TestInput(Float.MIN_VALUE, tolerance, false));
    builder.add(new TestInput(-1.0f, tolerance, false));
    builder.add(new TestInput(0.0f, tolerance, false));
    builder.add(new TestInput(0.01f, tolerance, false));
    builder.add(new TestInput(0.02f, tolerance, false));
    builder.add(new TestInput(0.1f, tolerance, false));
    builder.add(new TestInput(0.2f, tolerance, false));
    builder.add(new TestInput(1.0f, tolerance, false));
    builder.add(new TestInput(248.2424f, tolerance, false));
    builder.add(new TestInput(248.2425f, tolerance, true));
    builder.add(new TestInput(248.2426f, tolerance, true));
    builder.add(new TestInput(250f, tolerance, true));
    builder.add(new TestInput(250.7f, tolerance, true));
    builder.add(new TestInput(250.72f, tolerance, true));
    builder.add(new TestInput(250.73f, tolerance, true));
    builder.add(new TestInput(250.74f, tolerance, true));
    builder.add(new TestInput(250.75f, tolerance, true)); // Equals value
    builder.add(new TestInput(250.76f, tolerance, true));
    builder.add(new TestInput(250.77f, tolerance, true));
    builder.add(new TestInput(250.78f, tolerance, true));
    builder.add(new TestInput(250.8f, tolerance, true));
    builder.add(new TestInput(251f, tolerance, true));
    builder.add(new TestInput(253.2574f, tolerance, true));
    builder.add(new TestInput(253.2575f, tolerance, true));
    builder.add(new TestInput(253.2576f, tolerance, false));
    builder.add(new TestInput(300.0f, tolerance, false));
    builder.add(new TestInput(Float.MAX_VALUE, tolerance, false));
    // Tolerance 100.0%
    tolerance = new Tolerance(1.00, ToleranceType.PERCENTAGE);
    builder.add(new TestInput(Float.MIN_VALUE, tolerance, true));
    builder.add(new TestInput(-1.0f, tolerance, true));
    builder.add(new TestInput(0.0f, tolerance, true));
    builder.add(new TestInput(0.01f, tolerance, true));
    builder.add(new TestInput(0.02f, tolerance, true));
    builder.add(new TestInput(0.1f, tolerance, true));
    builder.add(new TestInput(0.2f, tolerance, true));
    builder.add(new TestInput(1.0f, tolerance, true));
    builder.add(new TestInput(248.2424f, tolerance, true));
    builder.add(new TestInput(248.2425f, tolerance, true));
    builder.add(new TestInput(248.2426f, tolerance, true));
    builder.add(new TestInput(250f, tolerance, true));
    builder.add(new TestInput(250.7f, tolerance, true));
    builder.add(new TestInput(250.72f, tolerance, true));
    builder.add(new TestInput(250.73f, tolerance, true));
    builder.add(new TestInput(250.74f, tolerance, true));
    builder.add(new TestInput(250.75f, tolerance, true)); // Equals value
    builder.add(new TestInput(250.76f, tolerance, true));
    builder.add(new TestInput(250.77f, tolerance, true));
    builder.add(new TestInput(250.78f, tolerance, true));
    builder.add(new TestInput(250.8f, tolerance, true));
    builder.add(new TestInput(251f, tolerance, true));
    builder.add(new TestInput(253.2574f, tolerance, true));
    builder.add(new TestInput(253.2575f, tolerance, true));
    builder.add(new TestInput(253.2576f, tolerance, true));
    builder.add(new TestInput(300.0f, tolerance, true));
    builder.add(new TestInput(Float.MAX_VALUE, tolerance, true));

    final ImmutableList<TestInput> testInputs = builder.build();

    testProperty(testInputs, PERSON_TYPE_URI, HAS_WEIGHT);
}

From source file:com.doubleTwist.drawerlib.ADrawerLayout.java

protected void onRestoreInstanceState(Parcelable state) {
    if (!(state instanceof SavedState)) {
        super.onRestoreInstanceState(state);
        return;/*from   w w w. j av  a 2s.  c  o  m*/
    }

    SavedState ss = (SavedState) state;
    super.onRestoreInstanceState(ss.getSuperState());

    // Avoid restoring state if the drawer was still being dragged
    // i.e. round the scroll states and set the right active drawer
    if (ss.scrollState != IDLE) {
        if (ss.currentScrollFractionX != Float.MIN_VALUE)
            ss.currentScrollFractionX = Math.round(ss.currentScrollFractionX);
        if (ss.currentScrollFractionY != Float.MIN_VALUE)
            ss.currentScrollFractionY = Math.round(ss.currentScrollFractionY);
        ss.scrollState = IDLE;
        // Need to set the right activeDrawer
        if (ss.currentScrollFractionX == 0 && ss.currentScrollFractionY == 0)
            ss.activeDrawer = NO_DRAWER;
    }

    if (ss.scrollState >= 0)
        mDrawerState.mScrollState = ss.scrollState;
    if (ss.activeDrawer >= 0)
        mDrawerState.mActiveDrawer = ss.activeDrawer;
    // Do not restore this, use setDraggingEnabled explicitly from activity/fragment code
    // mDrawerState.mDraggingEnabled = ss.draggingEnabled;

    boolean doNotRestore = (mDrawerState.mActiveDrawer == LEFT_DRAWER && mLeft == null)
            || (mDrawerState.mActiveDrawer == RIGHT_DRAWER && mRight == null)
            || (mDrawerState.mActiveDrawer == TOP_DRAWER && mTop == null)
            || (mDrawerState.mActiveDrawer == BOTTOM_DRAWER && mBottom == null);
    if (doNotRestore) {
        mDrawerState.mActiveDrawer = NO_DRAWER;
        mDrawerState.mScrollState = IDLE;
    }

    // Restoring the drawer offset will only occur in the next layout pass.
    // We need the actual drawer dimensions in order to properly set the
    // the offset.
    mPendingSavedState = new RestoreStateRunnable(ss);
}