Methods Summary |
---|
public static void | convertRectF(android.graphics.Rect source, android.graphics.RectF destination)Convert an integral rectangle ({@code source}) to a floating point rectangle
({@code destination}) in-place.
checkNotNull(source, "source must not be null");
checkNotNull(destination, "destination must not be null");
destination.left = source.left;
destination.right = source.right;
destination.bottom = source.bottom;
destination.top = source.top;
|
public static android.util.Rational | createRational(float value)Create a {@link Rational} value by approximating the float value as a rational.
Floating points too large to be represented as an integer will be converted to
to {@link Integer#MAX_VALUE}; floating points too small to be represented as an integer
will be converted to {@link Integer#MIN_VALUE}.
if (Float.isNaN(value)) {
return Rational.NaN;
} else if (value == Float.POSITIVE_INFINITY) {
return Rational.POSITIVE_INFINITY;
} else if (value == Float.NEGATIVE_INFINITY) {
return Rational.NEGATIVE_INFINITY;
} else if (value == 0.0f) {
return Rational.ZERO;
}
// normal finite value: approximate it
/*
* Start out trying to approximate with denominator = 1million,
* but if the numerator doesn't fit into an Int then keep making the denominator
* smaller until it does.
*/
int den = RATIONAL_DENOMINATOR;
float numF;
do {
numF = value * den;
if ((numF > Integer.MIN_VALUE && numF < Integer.MAX_VALUE) || (den == 1)) {
break;
}
den /= 10;
} while (true);
/*
* By float -> int narrowing conversion in JLS 5.1.3, this will automatically become
* MIN_VALUE or MAX_VALUE if numF is too small/large to be represented by an integer
*/
int num = (int) numF;
return new Rational(num, den);
|
public static android.graphics.Rect | createRect(android.util.Size size)Create a {@link Rect} from a {@code Size} by creating a new rectangle with
left, top = {@code (0, 0)} and right, bottom = {@code (width, height)} // 1million
checkNotNull(size, "size must not be null");
return new Rect(/*left*/0, /*top*/0, size.getWidth(), size.getHeight());
|
public static android.graphics.Rect | createRect(android.graphics.RectF rect)Create a {@link Rect} from a {@code RectF} by creating a new rectangle with
each corner (left, top, right, bottom) rounded towards the nearest integer bounding box.
In particular (left, top) is floored, and (right, bottom) is ceiled.
checkNotNull(rect, "rect must not be null");
Rect r = new Rect();
rect.roundOut(r);
return r;
|
public static android.util.Size | createSize(android.graphics.Rect rect)Create a {@link Size} from a {@code Rect} by creating a new size whose width
and height are the same as the rectangle's width and heights.
checkNotNull(rect, "rect must not be null");
return new Size(rect.width(), rect.height());
|
public static T | getOrDefault(android.hardware.camera2.CaptureRequest r, CaptureRequest.Key key, T defaultValue)Return the value set by the key, or the {@code defaultValue} if no value was set.
checkNotNull(r, "r must not be null");
checkNotNull(key, "key must not be null");
checkNotNull(defaultValue, "defaultValue must not be null");
T value = r.get(key);
if (value == null) {
return defaultValue;
} else {
return value;
}
|
public static android.graphics.Rect | mapRect(android.graphics.Matrix transform, android.graphics.Rect rect)Map the rectangle in {@code rect} with the transform in {@code transform} into
a new rectangle, with each corner (left, top, right, bottom) rounded towards the nearest
integer bounding box.
None of the arguments are mutated.
checkNotNull(transform, "transform must not be null");
checkNotNull(rect, "rect must not be null");
RectF rectF = new RectF(rect);
transform.mapRect(rectF);
return createRect(rectF);
|