public final class BoundingRectangle extends Object implements IEquatable<BoundingRectangle>, IEquatableEpsilon<BoundingRectangle>, ImmutableValueType
Constructor and Description |
---|
BoundingRectangle()
Initializes a new instance.
|
BoundingRectangle(double[] elements)
Initializes a new instance from the first four consecutive elements in the provided array.
|
BoundingRectangle(double[] elements,
int startIndex)
Initializes a new instance from four consecutive elements in the provided array.
|
BoundingRectangle(double left,
double bottom,
double right,
double top)
Initializes a new instance.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
equals(BoundingRectangle left,
BoundingRectangle right)
Returns
true if the two instances are exactly equal. |
boolean |
equals(Object obj)
Indicates whether another object is exactly equal to this instance.
|
boolean |
equalsEpsilon(BoundingRectangle other,
double epsilon)
Indicates whether each coordinate value of another instance of this type
is within the required tolerance of the corresponding coordinate value of this instance.
|
boolean |
equalsType(BoundingRectangle other)
Indicates whether another instance of this type is exactly equal to this instance.
|
static BoundingRectangle |
fromWidthHeight(double x,
double y,
double width,
double height)
Initializes a new instance.
|
double |
get(int index)
|
double |
getBottom()
Gets the y-coordinate of the bottom edge of the rectangle.
|
static BoundingRectangle |
getEmpty()
Gets a
BoundingRectangle with all values set to zero. |
double |
getHeight()
Gets the height of the rectangle.
|
double |
getLeft()
Gets the x-coordinate of the left edge of the rectangle.
|
int |
getLength()
Gets the number of elements in this set of coordinates.
|
double |
getRight()
Gets the x-coordinate of the right edge of the rectangle.
|
double |
getTop()
Gets the y-coordinate of the top edge of the rectangle.
|
double |
getWidth()
Gets the width of the rectangle.
|
int |
hashCode()
Returns a hash code for this instance, which is suitable for use in hashing algorithms and data structures like a hash table.
|
static boolean |
notEquals(BoundingRectangle left,
BoundingRectangle right)
Returns
true if the two instances are not exactly equal. |
String |
toString()
Returns the string representation of the value of this instance.
|
public BoundingRectangle()
public BoundingRectangle(double left, double bottom, double right, double top)
left
- The x coordinate of the lower-left corner.bottom
- The y coordinate of the lower-left corner.right
- The x coordinate of the upper-right corner.top
- The y coordinate of the upper-right corner.ArgumentException
- Thrown when the right parameter is less than the left parameter or when the top parameter is less than the bottom parameter.public BoundingRectangle(@Nonnull double[] elements)
elements
- The array of coordinate values.ArgumentNullException
- The array of elements
cannot be null
.ArgumentOutOfRangeException
- An object of this type must be constructed from an array with at least four elements
.ArgumentException
- Thrown when the right parameter is less than the left parameter or when the top parameter is less than the bottom parameter.public BoundingRectangle(@Nonnull double[] elements, int startIndex)
elements
- The array of coordinate values.startIndex
- The index of the first element in the array to use.ArgumentNullException
- Thrown when the array of elements
is null
.ArgumentOutOfRangeException
- Thrown when an object of this type is constructed from an array with less than four elements
.ArgumentException
- Thrown when the right parameter is less than the left parameter or when the top parameter is less than the bottom parameter.@Nonnull public static BoundingRectangle getEmpty()
BoundingRectangle
with all values set to zero.@Nonnull public static BoundingRectangle fromWidthHeight(double x, double y, double width, double height)
x
- The x coordinate of the lower-left corner.y
- The y coordinate of the lower-left corner.width
- The width of the rectangle.height
- The height of the rectangle.BoundingRectangle
.public final double getLeft()
public final double getTop()
public final double getBottom()
public final double getRight()
public final double getWidth()
public final double getHeight()
public final int getLength()
public final double get(int index)
index
of 0, 1, 2, and 3 corresponding to the coordinates
Left
(get
), Bottom
(get
), Right
(get
), and Top
(get
).index
- The index to retrieve.index
.ArgumentOutOfRangeException
- Thrown when index
is less than 0 or greater than or equal to Length
(get
).public boolean equals(Object obj)
equals
in class Object
obj
- The object to compare to this instance.true
if obj
is an instance of this type and represents the same value as this instance; otherwise false
.Object.hashCode()
,
HashMap
public final boolean equalsType(@Nonnull BoundingRectangle other)
equalsType
in interface IEquatable<BoundingRectangle>
other
- The instance to compare to this instance.true
if other
represents the same value as this instance; otherwise false
.public final boolean equalsEpsilon(@Nonnull BoundingRectangle other, double epsilon)
equalsEpsilon
in interface IEquatableEpsilon<BoundingRectangle>
other
- The set of BoundingRectangle
coordinates to compare to this instance.epsilon
- The limit at which the absolute differences between the coordinate values will not be considered equal.true
if the absolute differences are less than or equal to epsilon
; otherwise false
.public int hashCode()
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public String toString()
public static boolean equals(@Nonnull BoundingRectangle left, @Nonnull BoundingRectangle right)
true
if the two instances are exactly equal.left
- The instance to compare to right
.right
- The instance to compare to left
.true
if left
represents the same value as right
; otherwise false
.public static boolean notEquals(@Nonnull BoundingRectangle left, @Nonnull BoundingRectangle right)
true
if the two instances are not exactly equal.left
- The instance to compare to right
.right
- The instance to compare to left
.true
if left
does not represent the same value as right
; otherwise false
.