Java Code Examples for android.graphics.RectF#sort()
The following examples show how to use
android.graphics.RectF#sort() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MatrixUtils.java From EasyPhotos with Apache License 2.0 | 5 votes |
public static RectF trapToRect(float[] array) { RectF r = new RectF(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY); for (int i = 1; i < array.length; i += 2) { float x = round(array[i - 1] * 10) / 10.f; float y = round(array[i] * 10) / 10.f; r.left = (x < r.left) ? x : r.left; r.top = (y < r.top) ? y : r.top; r.right = (x > r.right) ? x : r.right; r.bottom = (y > r.bottom) ? y : r.bottom; } r.sort(); return r; }
Example 2
Source File: RectUtils.java From EasyPhotos with Apache License 2.0 | 5 votes |
/** * Takes an array of 2D coordinates representing corners and returns the * smallest rectangle containing those coordinates. * * @param array array of 2D coordinates * @return smallest rectangle containing coordinates */ public static RectF trapToRect(float[] array) { RectF r = new RectF(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY); for (int i = 1; i < array.length; i += 2) { float x = Math.round(array[i - 1] * 10) / 10.f; float y = Math.round(array[i] * 10) / 10.f; r.left = (x < r.left) ? x : r.left; r.top = (y < r.top) ? y : r.top; r.right = (x > r.right) ? x : r.right; r.bottom = (y > r.bottom) ? y : r.bottom; } r.sort(); return r; }
Example 3
Source File: MatrixUtils.java From imsdk-android with MIT License | 5 votes |
public static RectF trapToRect(float[] array) { RectF r = new RectF(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY); for (int i = 1; i < array.length; i += 2) { float x = round(array[i - 1] * 10) / 10.f; float y = round(array[i] * 10) / 10.f; r.left = (x < r.left) ? x : r.left; r.top = (y < r.top) ? y : r.top; r.right = (x > r.right) ? x : r.right; r.bottom = (y > r.bottom) ? y : r.bottom; } r.sort(); return r; }
Example 4
Source File: RectUtils.java From Matisse-Kotlin with Apache License 2.0 | 5 votes |
/** * Takes an array of 2D coordinates representing corners and returns the * smallest rectangle containing those coordinates. * * @param array array of 2D coordinates * @return smallest rectangle containing coordinates */ public static RectF trapToRect(float[] array) { RectF r = new RectF(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY); for (int i = 1; i < array.length; i += 2) { float x = Math.round(array[i - 1] * 10) / 10.f; float y = Math.round(array[i] * 10) / 10.f; r.left = (x < r.left) ? x : r.left; r.top = (y < r.top) ? y : r.top; r.right = (x > r.right) ? x : r.right; r.bottom = (y > r.bottom) ? y : r.bottom; } r.sort(); return r; }
Example 5
Source File: RectUtils.java From PictureSelector with Apache License 2.0 | 5 votes |
/** * Takes an array of 2D coordinates representing corners and returns the * smallest rectangle containing those coordinates. * * @param array array of 2D coordinates * @return smallest rectangle containing coordinates */ public static RectF trapToRect(float[] array) { RectF r = new RectF(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY); for (int i = 1; i < array.length; i += 2) { float x = Math.round(array[i - 1] * 10) / 10.f; float y = Math.round(array[i] * 10) / 10.f; r.left = (x < r.left) ? x : r.left; r.top = (y < r.top) ? y : r.top; r.right = (x > r.right) ? x : r.right; r.bottom = (y > r.bottom) ? y : r.bottom; } r.sort(); return r; }
Example 6
Source File: CropMath.java From imageCrop with MIT License | 5 votes |
/** * Takes an array of 2D coordinates representing corners and returns the * smallest rectangle containing those coordinates. * * @param array array of 2D coordinates * @return smallest rectangle containing coordinates */ public static RectF trapToRect(float[] array) { RectF r = new RectF(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY); for (int i = 1; i < array.length; i += 2) { float x = array[i - 1]; float y = array[i]; r.left = (x < r.left) ? x : r.left; r.top = (y < r.top) ? y : r.top; r.right = (x > r.right) ? x : r.right; r.bottom = (y > r.bottom) ? y : r.bottom; } r.sort(); return r; }
Example 7
Source File: DragPinchManager.java From AndroidPdfViewer with Apache License 2.0 | 5 votes |
private boolean checkLinkTapped(float x, float y) { PdfFile pdfFile = pdfView.pdfFile; if (pdfFile == null) { return false; } float mappedX = -pdfView.getCurrentXOffset() + x; float mappedY = -pdfView.getCurrentYOffset() + y; int page = pdfFile.getPageAtOffset(pdfView.isSwipeVertical() ? mappedY : mappedX, pdfView.getZoom()); SizeF pageSize = pdfFile.getScaledPageSize(page, pdfView.getZoom()); int pageX, pageY; if (pdfView.isSwipeVertical()) { pageX = (int) pdfFile.getSecondaryPageOffset(page, pdfView.getZoom()); pageY = (int) pdfFile.getPageOffset(page, pdfView.getZoom()); } else { pageY = (int) pdfFile.getSecondaryPageOffset(page, pdfView.getZoom()); pageX = (int) pdfFile.getPageOffset(page, pdfView.getZoom()); } for (PdfDocument.Link link : pdfFile.getPageLinks(page)) { RectF mapped = pdfFile.mapRectToDevice(page, pageX, pageY, (int) pageSize.getWidth(), (int) pageSize.getHeight(), link.getBounds()); mapped.sort(); if (mapped.contains(mappedX, mappedY)) { pdfView.callbacks.callLinkHandler(new LinkTapEvent(x, y, mappedX, mappedY, mapped, link)); return true; } } return false; }
Example 8
Source File: Vector2.java From cidrawing with Apache License 2.0 | 4 votes |
public RectF getRect() { RectF rect = new RectF(point1.x, point1.y, point2.x, point2.y); rect.sort(); return rect; }