List of usage examples for java.lang Float MAX_VALUE
float MAX_VALUE
To view the source code for java.lang Float MAX_VALUE.
Click Source Link
From source file:com.isapp.android.circularviewpager.CircularViewPager.java
private void calculatePageOffsets(ItemInfo curItem, int curIndex, ItemInfo oldCurInfo) { final int N = mAdapter.getCount(); final int width = getClientWidth(); final float marginOffset = width > 0 ? (float) mPageMargin / width : 0; // Fix up offsets for later layout. if (oldCurInfo != null) { final int oldCurPosition = oldCurInfo.position; // Base offsets off of oldCurInfo. if ((oldCurPosition < curItem.position && oldCurPosition != 0 && curItem.position != N - 1) || oldCurPosition == N - 1 && curItem.position == 0) { int itemIndex = 0; ItemInfo ii = null;//from ww w.jav a 2s.com float offset = oldCurInfo.offset + oldCurInfo.widthFactor + marginOffset; for (int pos = oldCurPosition + 1; pos <= curItem.position && itemIndex < mItems.size(); pos++) { ii = mItems.get(itemIndex); while (pos > ii.position && itemIndex < mItems.size() - 1) { itemIndex++; ii = mItems.get(itemIndex); } while (pos < ii.position) { // We don't have an item populated for this, // ask the adapter for an offset. offset += mAdapter.getPageWidth(pos) + marginOffset; pos++; } ii.offset = offset; offset += ii.widthFactor + marginOffset; } } else if ((oldCurPosition > curItem.position && oldCurPosition != N - 1 && curItem.position != 0) || oldCurPosition == 0 && curItem.position == N - 1) { int itemIndex = mItems.size() - 1; ItemInfo ii = null; float offset = oldCurInfo.offset; for (int pos = oldCurPosition - 1; pos >= curItem.position && itemIndex >= 0; pos--) { ii = mItems.get(itemIndex); while (pos < ii.position && itemIndex > 0) { itemIndex--; ii = mItems.get(itemIndex); } while (pos > ii.position) { // We don't have an item populated for this, // ask the adapter for an offset. offset -= mAdapter.getPageWidth(pos) + marginOffset; pos--; } offset -= ii.widthFactor + marginOffset; ii.offset = offset; } } } // Base all offsets off of curItem. final int itemCount = mItems.size(); final int pageLimit = mOffscreenPageLimit; final int startPos = mCurItem - pageLimit < 0 ? Math.max(0, N + (mCurItem - pageLimit)) : Math.max(0, mCurItem - pageLimit); final int endPos = mCurItem + pageLimit >= N ? Math.min(N - 1, (mCurItem + pageLimit) - N) : Math.min(N - 1, mCurItem + pageLimit); float offset = curItem.offset; int pos = curItem.position - 1; mFirstOffset = curItem.position == 0 ? curItem.offset : -Float.MAX_VALUE; mLastOffset = curItem.position == N - 1 ? curItem.offset + curItem.widthFactor - 1 : Float.MAX_VALUE; // Previous pages for (int i = curIndex - 1; i >= 0; i--, pos--) { final ItemInfo ii = mItems.get(i); while (pos > ii.position) { offset -= mAdapter.getPageWidth(pos--) + marginOffset; } offset -= ii.widthFactor + marginOffset; ii.offset = offset; if (ii.position == startPos) mFirstOffset = offset; } offset = curItem.offset + curItem.widthFactor + marginOffset; pos = curItem.position + 1; // Next pages for (int i = curIndex + 1; i < itemCount; i++, pos++) { final ItemInfo ii = mItems.get(i); while (pos < ii.position) { offset += mAdapter.getPageWidth(pos++) + marginOffset; } if (ii.position == endPos) { mLastOffset = offset + ii.widthFactor - 1; } ii.offset = offset; offset += ii.widthFactor + marginOffset; } mNeedCalculatePageOffsets = false; }
From source file:com.android.leanlauncher.CellLayout.java
/** * Find a vacant area that will fit the given bounds nearest the requested * cell location, and will also weigh in a suggested direction vector of the * desired location. This method computers distance based on unit grid distances, * not pixel distances.// w ww. j a v a2 s . c o m * * @param cellX The X cell nearest to which you want to search for a vacant area. * @param cellY The Y cell nearest which you want to search for a vacant area. * @param spanX Horizontal span of the object. * @param spanY Vertical span of the object. * @param direction The favored direction in which the views should move from x, y * matches exactly. Otherwise we find the best matching direction. * @param occupied The array which represents which cells in the CellLayout are occupied * @param blockOccupied The array which represents which cells in the specified block (cellX, * cellY, spanX, spanY) are occupied. This is used when try to move a group of views. * @param result Array in which to place the result, or null (in which case a new array will * be allocated) * @return The X, Y cell of a vacant area that can contain this object, * nearest the requested location. */ private int[] findNearestArea(int cellX, int cellY, int spanX, int spanY, int[] direction, boolean[][] occupied, boolean blockOccupied[][], int[] result) { // Keep track of best-scoring drop area final int[] bestXY = result != null ? result : new int[2]; float bestDistance = Float.MAX_VALUE; int bestDirectionScore = Integer.MIN_VALUE; final int countX = mCountX; final int countY = mCountY; for (int y = 0; y < countY - (spanY - 1); y++) { inner: for (int x = 0; x < countX - (spanX - 1); x++) { // First, let's see if this thing fits anywhere for (int i = 0; i < spanX; i++) { for (int j = 0; j < spanY; j++) { if (occupied[x + i][y + j] && (blockOccupied == null || blockOccupied[i][j])) { continue inner; } } } float distance = (float) Math.sqrt((x - cellX) * (x - cellX) + (y - cellY) * (y - cellY)); int[] curDirection = mTmpPoint; computeDirectionVector(x - cellX, y - cellY, curDirection); // The direction score is just the dot product of the two candidate direction // and that passed in. int curDirectionScore = direction[0] * curDirection[0] + direction[1] * curDirection[1]; boolean exactDirectionOnly = false; boolean directionMatches = direction[0] == curDirection[0] && direction[0] == curDirection[0]; if ((directionMatches || !exactDirectionOnly) && Float.compare(distance, bestDistance) < 0 || (Float.compare(distance, bestDistance) == 0 && curDirectionScore > bestDirectionScore)) { bestDistance = distance; bestDirectionScore = curDirectionScore; bestXY[0] = x; bestXY[1] = y; } } } // Return -1, -1 if no suitable location found if (bestDistance == Float.MAX_VALUE) { bestXY[0] = -1; bestXY[1] = -1; } return bestXY; }
From source file:spectrogram.Spectrogram.java
/** * For binary input files from our frame reader set up the input stream * * @return number of entries to read//from w w w . ja va 2 s . c o m * @throws WebUtilException */ private long setupFileReads(String infilename) throws WebUtilException { setProgress("Scan input file for min/max GPS times."); File inFile = new File(infilename); long siz = inFile.length() / (Float.SIZE / 8) / 2; // convert bytes to # entries (time, val) if (!inFile.canRead()) { throw new WebUtilException("Can't open " + infilename + " for reading"); } try { inStream = new SwappedDataInputStream(new FileInputStream(inFile)); float minTime = Float.MAX_VALUE; float maxTime = -Float.MAX_VALUE; setProgress("Searhing for min/max time in input file."); int opct = 0; for (int i = 0; i < siz; i++) { int pct = (int) (100 * i / siz); if (pct > opct) { setProgress(pct, 100); opct = pct; } Float t = inStream.readFloat(); Float d = inStream.readFloat(); minTime = Math.min(minTime, t); maxTime = Math.max(maxTime, t); } startGPS = (int) (minTime); duration = (int) (maxTime - minTime); inStream.close(); inStream = new SwappedDataInputStream(new FileInputStream(inFile)); } catch (IOException ex) { throw new WebUtilException("Can't open " + infilename + " for reading"); } return siz; }
From source file:example.luojing.androidsourceanalysis.ViewPager.java
/** * PageOffsets?//w w w . jav a 2 s . c om */ private void calculatePageOffsets(ItemInfo curItem, int curIndex, ItemInfo oldCurInfo) { final int N = mAdapter.getCount(); final int width = getClientWidth(); final float marginOffset = width > 0 ? (float) mPageMargin / width : 0; // Fix up offsets for later layout. if (oldCurInfo != null) { final int oldCurPosition = oldCurInfo.position; // Base offsets off of oldCurInfo. if (oldCurPosition < curItem.position) { int itemIndex = 0; ItemInfo ii = null; float offset = oldCurInfo.offset + oldCurInfo.widthFactor + marginOffset; for (int pos = oldCurPosition + 1; pos <= curItem.position && itemIndex < mItems.size(); pos++) { ii = mItems.get(itemIndex); while (pos > ii.position && itemIndex < mItems.size() - 1) { itemIndex++; ii = mItems.get(itemIndex); } while (pos < ii.position) { // We don't have an item populated for this, // ask the adapter for an offset. offset += mAdapter.getPageWidth(pos) + marginOffset; pos++; } ii.offset = offset; offset += ii.widthFactor + marginOffset; } } else if (oldCurPosition > curItem.position) { int itemIndex = mItems.size() - 1; ItemInfo ii = null; float offset = oldCurInfo.offset; for (int pos = oldCurPosition - 1; pos >= curItem.position && itemIndex >= 0; pos--) { ii = mItems.get(itemIndex); while (pos < ii.position && itemIndex > 0) { itemIndex--; ii = mItems.get(itemIndex); } while (pos > ii.position) { // We don't have an item populated for this, // ask the adapter for an offset. offset -= mAdapter.getPageWidth(pos) + marginOffset; pos--; } offset -= ii.widthFactor + marginOffset; ii.offset = offset; } } } // Base all offsets off of curItem. final int itemCount = mItems.size(); float offset = curItem.offset; int pos = curItem.position - 1; mFirstOffset = curItem.position == 0 ? curItem.offset : -Float.MAX_VALUE; mLastOffset = curItem.position == N - 1 ? curItem.offset + curItem.widthFactor - 1 : Float.MAX_VALUE; // Previous pages for (int i = curIndex - 1; i >= 0; i--, pos--) { final ItemInfo ii = mItems.get(i); while (pos > ii.position) { offset -= mAdapter.getPageWidth(pos--) + marginOffset; } offset -= ii.widthFactor + marginOffset; ii.offset = offset; if (ii.position == 0) mFirstOffset = offset; } offset = curItem.offset + curItem.widthFactor + marginOffset; pos = curItem.position + 1; // Next pages for (int i = curIndex + 1; i < itemCount; i++, pos++) { final ItemInfo ii = mItems.get(i); while (pos < ii.position) { offset += mAdapter.getPageWidth(pos++) + marginOffset; } if (ii.position == N - 1) { mLastOffset = offset + ii.widthFactor - 1; } ii.offset = offset; offset += ii.widthFactor + marginOffset; } mNeedCalculatePageOffsets = false; }
From source file:org.opencms.loader.CmsImageScaler.java
/** * Calculate the closest match of the given base float with the list of others.<p> * // w w w .j a v a2 s .com * @param base the base float to compare the other with * @param others the list of floats to compate to the base * * @return the array index of the closest match */ private int calculateClosest(float base, float[] others) { int result = -1; float bestMatch = Float.MAX_VALUE; for (int count = 0; count < others.length; count++) { float difference = Math.abs(base - others[count]); if (difference < bestMatch) { // new best match found bestMatch = difference; result = count; } if (bestMatch == 0f) { // it does not get better then this break; } } return result; }
From source file:com.marlonjones.voidlauncher.CellLayout.java
/** * Find a vacant area that will fit the given bounds nearest the requested * cell location, and will also weigh in a suggested direction vector of the * desired location. This method computers distance based on unit grid distances, * not pixel distances./*www .j a v a2 s. co m*/ * * @param cellX The X cell nearest to which you want to search for a vacant area. * @param cellY The Y cell nearest which you want to search for a vacant area. * @param spanX Horizontal span of the object. * @param spanY Vertical span of the object. * @param direction The favored direction in which the views should move from x, y * @param occupied The array which represents which cells in the CellLayout are occupied * @param blockOccupied The array which represents which cells in the specified block (cellX, * cellY, spanX, spanY) are occupied. This is used when try to move a group of views. * @param result Array in which to place the result, or null (in which case a new array will * be allocated) * @return The X, Y cell of a vacant area that can contain this object, * nearest the requested location. */ private int[] findNearestArea(int cellX, int cellY, int spanX, int spanY, int[] direction, boolean[][] occupied, boolean blockOccupied[][], int[] result) { // Keep track of best-scoring drop area final int[] bestXY = result != null ? result : new int[2]; float bestDistance = Float.MAX_VALUE; int bestDirectionScore = Integer.MIN_VALUE; final int countX = mCountX; final int countY = mCountY; for (int y = 0; y < countY - (spanY - 1); y++) { inner: for (int x = 0; x < countX - (spanX - 1); x++) { // First, let's see if this thing fits anywhere for (int i = 0; i < spanX; i++) { for (int j = 0; j < spanY; j++) { if (occupied[x + i][y + j] && (blockOccupied == null || blockOccupied[i][j])) { continue inner; } } } float distance = (float) Math.hypot(x - cellX, y - cellY); int[] curDirection = mTmpPoint; computeDirectionVector(x - cellX, y - cellY, curDirection); // The direction score is just the dot product of the two candidate direction // and that passed in. int curDirectionScore = direction[0] * curDirection[0] + direction[1] * curDirection[1]; if (Float.compare(distance, bestDistance) < 0 || (Float.compare(distance, bestDistance) == 0 && curDirectionScore > bestDirectionScore)) { bestDistance = distance; bestDirectionScore = curDirectionScore; bestXY[0] = x; bestXY[1] = y; } } } // Return -1, -1 if no suitable location found if (bestDistance == Float.MAX_VALUE) { bestXY[0] = -1; bestXY[1] = -1; } return bestXY; }
From source file:com.android.launcher3.CellLayout.java
/** * Find a vacant area that will fit the given bounds nearest the requested * cell location, and will also weigh in a suggested direction vector of the * desired location. This method computers distance based on unit grid distances, * not pixel distances.//from w w w .j a va 2 s . c om * * @param cellX The X cell nearest to which you want to search for a vacant area. * @param cellY The Y cell nearest which you want to search for a vacant area. * @param spanX Horizontal span of the object. * @param spanY Vertical span of the object. * @param direction The favored direction in which the views should move from x, y * @param exactDirectionOnly If this parameter is true, then only solutions where the direction * matches exactly. Otherwise we find the best matching direction. * @param occoupied The array which represents which cells in the CellLayout are occupied * @param blockOccupied The array which represents which cells in the specified block (cellX, * cellY, spanX, spanY) are occupied. This is used when try to move a group of views. * @param result Array in which to place the result, or null (in which case a new array will * be allocated) * @return The X, Y cell of a vacant area that can contain this object, * nearest the requested location. */ private int[] findNearestArea(int cellX, int cellY, int spanX, int spanY, int[] direction, boolean[][] occupied, boolean blockOccupied[][], int[] result) { // Keep track of best-scoring drop area final int[] bestXY = result != null ? result : new int[2]; float bestDistance = Float.MAX_VALUE; int bestDirectionScore = Integer.MIN_VALUE; final int countX = mCountX; final int countY = mCountY; for (int y = 0; y < countY - (spanY - 1); y++) { inner: for (int x = 0; x < countX - (spanX - 1); x++) { // First, let's see if this thing fits anywhere for (int i = 0; i < spanX; i++) { for (int j = 0; j < spanY; j++) { if (occupied[x + i][y + j] && (blockOccupied == null || blockOccupied[i][j])) { continue inner; } } } float distance = (float) Math.hypot(x - cellX, y - cellY); int[] curDirection = mTmpPoint; computeDirectionVector(x - cellX, y - cellY, curDirection); // The direction score is just the dot product of the two candidate direction // and that passed in. int curDirectionScore = direction[0] * curDirection[0] + direction[1] * curDirection[1]; boolean exactDirectionOnly = false; boolean directionMatches = direction[0] == curDirection[0] && direction[0] == curDirection[0]; if ((directionMatches || !exactDirectionOnly) && Float.compare(distance, bestDistance) < 0 || (Float.compare(distance, bestDistance) == 0 && curDirectionScore > bestDirectionScore)) { bestDistance = distance; bestDirectionScore = curDirectionScore; bestXY[0] = x; bestXY[1] = y; } } } // Return -1, -1 if no suitable location found if (bestDistance == Float.MAX_VALUE) { bestXY[0] = -1; bestXY[1] = -1; } return bestXY; }
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:org.springframework.beans.BeanWrapperTests.java
@Test public void testSetNumberProperties() { NumberPropertyBean bean = new NumberPropertyBean(); BeanWrapper bw = new BeanWrapperImpl(bean); String byteValue = " " + Byte.MAX_VALUE + " "; String shortValue = " " + Short.MAX_VALUE + " "; String intValue = " " + Integer.MAX_VALUE + " "; String longValue = " " + Long.MAX_VALUE + " "; String floatValue = " " + Float.MAX_VALUE + " "; String doubleValue = " " + Double.MAX_VALUE + " "; bw.setPropertyValue("myPrimitiveByte", byteValue); bw.setPropertyValue("myByte", byteValue); bw.setPropertyValue("myPrimitiveShort", shortValue); bw.setPropertyValue("myShort", shortValue); bw.setPropertyValue("myPrimitiveInt", intValue); bw.setPropertyValue("myInteger", intValue); bw.setPropertyValue("myPrimitiveLong", longValue); bw.setPropertyValue("myLong", longValue); bw.setPropertyValue("myPrimitiveFloat", floatValue); bw.setPropertyValue("myFloat", floatValue); bw.setPropertyValue("myPrimitiveDouble", doubleValue); bw.setPropertyValue("myDouble", doubleValue); assertEquals(Byte.MAX_VALUE, bean.getMyPrimitiveByte()); assertEquals(Byte.MAX_VALUE, bean.getMyByte().byteValue()); assertEquals(Short.MAX_VALUE, bean.getMyPrimitiveShort()); assertEquals(Short.MAX_VALUE, bean.getMyShort().shortValue()); assertEquals(Integer.MAX_VALUE, bean.getMyPrimitiveInt()); assertEquals(Integer.MAX_VALUE, bean.getMyInteger().intValue()); assertEquals(Long.MAX_VALUE, bean.getMyPrimitiveLong()); assertEquals(Long.MAX_VALUE, bean.getMyLong().longValue()); assertEquals(Float.MAX_VALUE, bean.getMyPrimitiveFloat(), 0.001); assertEquals(Float.MAX_VALUE, bean.getMyFloat().floatValue(), 0.001); assertEquals(Double.MAX_VALUE, bean.getMyPrimitiveDouble(), 0.001); assertEquals(Double.MAX_VALUE, bean.getMyDouble().doubleValue(), 0.001); }