MeteringRectangle
  public
  
  final
  
  class
  MeteringRectangle
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.hardware.camera2.params.MeteringRectangle | 
An immutable class to represent a rectangle (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 .METERING_WEIGHT_MIN to .METERING_WEIGHT_MAX
 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.
Summary
| Constants | |
|---|---|
| int | METERING_WEIGHT_DONT_CAREWeights set to this value will cause the camera device to ignore this rectangle. | 
| int | METERING_WEIGHT_MAXThe maximum value of valid metering weight. | 
| int | METERING_WEIGHT_MINThe minimum value of valid metering weight. | 
| Public constructors | |
|---|---|
| 
      MeteringRectangle(Point xy, Size dimensions, int meteringWeight)
      Create a new metering rectangle. | |
| 
      MeteringRectangle(Rect rect, int meteringWeight)
      Create a new metering rectangle. | |
| 
      MeteringRectangle(int x, int y, int width, int height, int meteringWeight)
      Create a new metering rectangle. | |
| Public methods | |
|---|---|
| 
        
        
        
        
        
        boolean | 
      equals(Object other)
      Indicates whether some other object is "equal to" this one. | 
| 
        
        
        
        
        
        boolean | 
      equals(MeteringRectangle other)
      Compare two metering rectangles to see if they are equal. | 
| 
        
        
        
        
        
        int | 
      getHeight()
      Return the height of the rectangle. | 
| 
        
        
        
        
        
        int | 
      getMeteringWeight()
      Return the metering weight of the rectangle. | 
| 
        
        
        
        
        
        Rect | 
      getRect()
      Convenience method to create a  | 
| 
        
        
        
        
        
        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  | 
| 
        
        
        
        
        
        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
  | 
| Inherited methods | |
|---|---|
Constants
METERING_WEIGHT_DONT_CARE
public static final int METERING_WEIGHT_DONT_CARE
Weights set to this value will cause the camera device to ignore this rectangle. If all metering rectangles are weighed with 0, the camera device will choose its own metering rectangles.
Constant Value: 0 (0x00000000)
METERING_WEIGHT_MAX
public static final int METERING_WEIGHT_MAX
The maximum value of valid metering weight.
Constant Value: 1000 (0x000003e8)
METERING_WEIGHT_MIN
public static final int METERING_WEIGHT_MIN
The minimum value of valid metering weight.
Constant Value: 0 (0x00000000)
Public constructors
MeteringRectangle
public MeteringRectangle (Point xy, Size dimensions, int meteringWeight)
Create a new metering rectangle.
The point xy's data is copied; the reference is not retained.
| Parameters | |
|---|---|
| xy | Point: a non-nullPointwith both x,y >= 0 | 
| dimensions | Size: a non-nullSizewith width, height >= 0 | 
| meteringWeight | int: weight >= 0 | 
| Throws | |
|---|---|
| IllegalArgumentException | if any of the parameters were negative | 
| NullPointerException | if any of the arguments were null | 
MeteringRectangle
public MeteringRectangle (Rect rect, int meteringWeight)
Create a new metering rectangle.
The rectangle data is copied; the reference is not retained.
| Parameters | |
|---|---|
| rect | Rect: a non-nullrectangle with all x,y,w,h dimensions >= 0 | 
| meteringWeight | int: weight >= 0 | 
| Throws | |
|---|---|
| IllegalArgumentException | if any of the parameters were negative | 
| NullPointerException | if any of the arguments were null | 
MeteringRectangle
public MeteringRectangle (int x, 
                int y, 
                int width, 
                int height, 
                int meteringWeight)Create a new metering rectangle.
| Parameters | |
|---|---|
| x | int: coordinate >= 0 | 
| y | int: coordinate >= 0 | 
| width | int: width >= 0 | 
| height | int: height >= 0 | 
| meteringWeight | int: weight between.METERING_WEIGHT_MINand.METERING_WEIGHT_MAXinclusively | 
| Throws | |
|---|---|
| IllegalArgumentException | if any of the parameters were negative | 
Public methods
equals
public boolean equals (Object other)
Indicates whether some other object is "equal to" this one.
 The equals method implements an equivalence relation
 on non-null object references:
 
- It is reflexive: for any non-null reference value
     x,x.equals(x)should returntrue.
- It is symmetric: for any non-null reference values
     xandy,x.equals(y)should returntrueif and only ify.equals(x)returnstrue.
- It is transitive: for any non-null reference values
     x,y, andz, ifx.equals(y)returnstrueandy.equals(z)returnstrue, thenx.equals(z)should returntrue.
- It is consistent: for any non-null reference values
     xandy, multiple invocations ofx.equals(y)consistently returntrueor consistently returnfalse, provided no information used inequalscomparisons on the objects is modified.
- For any non-null reference value x,x.equals(null)should returnfalse.
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| Parameters | |
|---|---|
| other | Object: the reference object with which to compare. | 
| Returns | |
|---|---|
| boolean | trueif this object is the same as the obj
          argument;falseotherwise. | 
equals
public boolean equals (MeteringRectangle other)
Compare two metering rectangles to see if they are equal. Two weighted rectangles are only considered equal if each of their components (x, y, width, height, weight) is respectively equal.
| Parameters | |
|---|---|
| other | MeteringRectangle: Another MeteringRectangle | 
| Returns | |
|---|---|
| boolean | trueif the metering rectangles are equal,falseotherwise | 
getHeight
public int getHeight ()
Return the height of the rectangle.
| Returns | |
|---|---|
| int | height >= 0 | 
getMeteringWeight
public int getMeteringWeight ()
Return the metering weight of the rectangle.
| Returns | |
|---|---|
| int | weight >= 0 | 
getRect
public Rect getRect ()
Convenience method to create a Rect from this metering rectangle.
 
This strips away the weight from the rectangle.
| Returns | |
|---|---|
| Rect | a new Rectwith non-negative x1, y1, x2, y2 | 
getSize
public Size getSize ()
Convenience method to create the size from this metering rectangle.
This strips away the X,Y,weight from the rectangle.
| Returns | |
|---|---|
| Size | a new Sizewith non-negative width and height | 
getUpperLeftPoint
public Point getUpperLeftPoint ()
Convenience method to create the upper-left (X,Y) coordinate as a Point.
| Returns | |
|---|---|
| Point | a new (x,y)Pointwith both x,y >= 0 | 
getWidth
public int getWidth ()
Return the width of the rectangle.
| Returns | |
|---|---|
| int | width >= 0 | 
getX
public int getX ()
Return the X coordinate of the left side of the rectangle.
| Returns | |
|---|---|
| int | x coordinate >= 0 | 
getY
public int getY ()
Return the Y coordinate of the upper side of the rectangle.
| Returns | |
|---|---|
| int | y coordinate >= 0 | 
hashCode
public int hashCode ()
Returns a hash code value for the object. This method is
 supported for the benefit of hash tables such as those provided by
 HashMap.
 
 The general contract of hashCode is:
 
- Whenever it is invoked on the same object more than once during
     an execution of a Java application, the hashCodemethod must consistently return the same integer, provided no information used inequalscomparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
- If two objects are equal according to the equalsmethod, then calling thehashCodemethod on each of the two objects must produce the same integer result.
- It is not required that if two objects are unequal
     according to the equalsmethod, then calling thehashCodemethod 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.
| Returns | |
|---|---|
| int | a hash code value for this object. | 
toString
public 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.
| Returns | |
|---|---|
| String | string representation of the metering rectangle | 
