List of usage examples for android.graphics RectF sort
public void sort()
From source file:Main.java
/** * Takes an array of 2D coordinates representing corners and returns the * smallest rectangle containing those coordinates. * * @param array array of 2D coordinates//from ww w.j av a 2s. c o m * @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; }
From source file:Main.java
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; }/*from w w w. jav a 2 s.c o m*/ r.sort(); return r; }