public final class MeteringRectangle extends Object
(x, y, width, height)
with an additional
weight component.
The rectangle is defined to be inclusive of the specified coordinates.
When used with a CaptureRequest
, the coordinate system is based on the active pixel
array, with (0,0)
being the top-left pixel in the
active pixel array
, and
(android.sensor.info.activeArraySize.width - 1,
android.sensor.info.activeArraySize.height - 1)
being the bottom-right pixel in the active pixel
array.
The weight must range from 0 to 1000 inclusively, and represents a weight for every pixel in the area. This means that a large metering area with the same weight as a smaller area will have more effect in the metering result. Metering areas can partially overlap and the camera device will add the weights in the overlap rectangle.
If all rectangles have 0 weight, then no specific metering area needs to be used by the camera device. If the metering rectangle is outside the used android.scaler.cropRegion returned in capture result metadata, the camera device will ignore the sections outside the rectangle and output the used sections in the result metadata.
Modifier and Type | Field and Description |
---|---|
static int |
METERING_WEIGHT_DONT_CARE
Weights set to this value will cause the camera device to ignore this rectangle.
|
static int |
METERING_WEIGHT_MAX
The maximum value of valid metering weight.
|
static int |
METERING_WEIGHT_MIN
The minimum value of valid metering weight.
|
Constructor and Description |
---|
MeteringRectangle(int x,
int y,
int width,
int height,
int meteringWeight)
Create a new metering rectangle.
|
MeteringRectangle(Point xy,
Size dimensions,
int meteringWeight)
Create a new metering rectangle.
|
MeteringRectangle(Rect rect,
int meteringWeight)
Create a new metering rectangle.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(MeteringRectangle other)
Compare two metering rectangles to see if they are equal.
|
boolean |
equals(Object other)
Indicates whether some other object is "equal to" this one.
|
int |
getHeight()
Return the height of the rectangle.
|
int |
getMeteringWeight()
Return the metering weight of the rectangle.
|
Rect |
getRect()
Convenience method to create a
Rect from this metering rectangle. |
Size |
getSize()
Convenience method to create the size from this metering rectangle.
|
Point |
getUpperLeftPoint()
Convenience method to create the upper-left (X,Y) coordinate as a
Point . |
int |
getWidth()
Return the width of the rectangle.
|
int |
getX()
Return the X coordinate of the left side of the rectangle.
|
int |
getY()
Return the Y coordinate of the upper side of the rectangle.
|
int |
hashCode()
Returns a hash code value for the object.
|
String |
toString()
Return the metering rectangle as a string representation
"(x:%d, y:%d, w:%d, h:%d, wt:%d)" where each %d respectively represents
the x, y, width, height, and weight points. |
public static final int METERING_WEIGHT_MIN
public static final int METERING_WEIGHT_MAX
public static final int METERING_WEIGHT_DONT_CARE
public MeteringRectangle(int x, int y, int width, int height, int meteringWeight)
x
- coordinate >= 0y
- coordinate >= 0width
- width >= 0height
- height >= 0meteringWeight
- weight between 0 and
1000 inclusivelyIllegalArgumentException
- if any of the parameters were negativepublic MeteringRectangle(Point xy, Size dimensions, int meteringWeight)
The point xy
's data is copied; the reference is not retained.
xy
- a non-null
Point
with both x,y >= 0dimensions
- a non-null
Size
with width, height >= 0meteringWeight
- weight >= 0IllegalArgumentException
- if any of the parameters were negativeNullPointerException
- if any of the arguments were nullpublic MeteringRectangle(Rect rect, int meteringWeight)
The rectangle data is copied; the reference is not retained.
rect
- a non-null
rectangle with all x,y,w,h dimensions >= 0meteringWeight
- weight >= 0IllegalArgumentException
- if any of the parameters were negativeNullPointerException
- if any of the arguments were nullpublic int getX()
public int getY()
public int getWidth()
public int getHeight()
public int getMeteringWeight()
public Point getUpperLeftPoint()
Point
.(x,y)
Point
with both x,y >= 0public Size getSize()
This strips away the X,Y,weight from the rectangle.
Size
with non-negative width and heightpublic Rect getRect()
Rect
from this metering rectangle.
This strips away the weight from the rectangle.
Rect
with non-negative x1, y1, x2, y2public boolean equals(Object other)
The equals
method implements an equivalence relation
on non-null object references:
x
, x.equals(x)
should return
true
.
x
and y
, x.equals(y)
should return true
if and only if
y.equals(x)
returns true
.
x
, y
, and z
, if
x.equals(y)
returns true
and
y.equals(z)
returns true
, then
x.equals(z)
should return true
.
x
and y
, multiple invocations of
x.equals(y)
consistently return true
or consistently return false
, provided no
information used in equals
comparisons on the
objects is modified.
x
,
x.equals(null)
should return false
.
The equals
method for class Object
implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x
and
y
, this method returns true
if and only
if x
and y
refer to the same object
(x == y
has the value true
).
Note that it is generally necessary to override the hashCode
method whenever this method is overridden, so as to maintain the
general contract for the hashCode
method, which states
that equal objects must have equal hash codes.
equals
in class Object
other
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.Object.hashCode()
,
HashMap
public boolean equals(MeteringRectangle other)
other
- Another MeteringRectangletrue
if the metering rectangles are equal, false
otherwisepublic int hashCode()
HashMap
.
The general contract of hashCode
is:
hashCode
method
must consistently return the same integer, provided no information
used in equals
comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode
method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object
does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
JavaTM programming language.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)