本文整理匯總了Java中android.graphics.RectF.sort方法的典型用法代碼示例。如果您正苦於以下問題:Java RectF.sort方法的具體用法?Java RectF.sort怎麽用?Java RectF.sort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.RectF
的用法示例。
在下文中一共展示了RectF.sort方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: trapToRect
import android.graphics.RectF; //導入方法依賴的package包/類
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;
if (x <= r.right) {
x = r.right;
}
r.right = x;
if (y <= r.bottom) {
y = r.bottom;
}
r.bottom = y;
}
r.sort();
return r;
}
示例2: trapToRect
import android.graphics.RectF; //導入方法依賴的package包/類
/**
* 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;
}
示例3: trapToRect
import android.graphics.RectF; //導入方法依賴的package包/類
/**
* 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;
}