The coordinate space for rectangles and points is considered to have increasing values downward and to the right from its origin making this the normal, computer graphics oriented notion of (x, y) coordinates rather than the strict mathematical one.
The hashCode() method in this class uses the values of the public fields to compute the hash value. When storing instances of the class in hashed collections, do not modify these fields after the object has been inserted.
Application code does not need to explicitly release the
resources managed by each instance when those instances are no longer
required, and thus no dispose() method is provided.
Point, Sample code and further information
| Modifier and Type | Field and Description |
|---|---|
| public int | height
the height of the rectangle |
| pack-priv static final long | |
| public int | width
the width of the rectangle |
| public int | x
the x coordinate of the rectangle |
| public int | y
the y coordinate of the rectangle |
| Access | Constructor and Description |
|---|---|
| public | Rectangle(int
the x coordinate of the origin of the rectangle x, int the y coordinate of the origin of the rectangle y, int the width of the rectangle width, int the height of the rectangle height)Construct a new instance of this class given the x, y, width and height values. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public boolean | Returns: true if the rectangle contains the point and false otherwisethe x coordinate of the point to test for containment x, int the y coordinate of the point to test for containment y)Returns |
| public boolean | |
| public boolean | Returns: true if the object is the same as this object and false otherwisethe object to compare with this object object)Overrides java. |
| public int | Returns: the receiver's hashOverrides java. |
| public void | |
| public Rectangle | Returns: the intersection of the receiver and the argumentthe rectangle to intersect with the receiver rect)Returns a new rectangle which represents the intersection of the receiver and the given rectangle. |
| public boolean | Returns: true if the rectangle intersects with the receiver, and false otherwisethe x coordinate of the origin of the rectangle x, int the y coordinate of the origin of the rectangle y, int the width of the rectangle width, int the height of the rectangle height)Returns |
| public boolean | Returns: true if the rectangle intersects with the receiver, and false otherwisethe rectangle to test for intersection rect)Returns |
| public boolean | Returns: true if the receiver is empty, and false otherwiseReturns |
| public String | Returns: a string representation of the rectangleOverrides java. |
| public Rectangle |
| height | back to summary |
|---|---|
| public int height the height of the rectangle | |
| serialVersionUID | back to summary |
|---|---|
| pack-priv static final long serialVersionUID | |
| width | back to summary |
|---|---|
| public int width the width of the rectangle | |
| x | back to summary |
|---|---|
| public int x the x coordinate of the rectangle | |
| y | back to summary |
|---|---|
| public int y the y coordinate of the rectangle | |
| Rectangle | back to summary |
|---|---|
| public Rectangle(int x, int y, int width, int height) Construct a new instance of this class given the x, y, width and height values.
| |
| add | back to summary |
|---|---|
| public void add(Rectangle rect) Destructively replaces the x, y, width and height values in the receiver with ones which represent the union of the rectangles specified by the receiver and the given rectangle. The union of two rectangles is the smallest single rectangle that completely covers both of the areas covered by the two given rectangles.
| |
| contains | back to summary |
|---|---|
| public boolean contains(int x, int y) Returns
| |
| contains | back to summary |
|---|---|
| public boolean contains(Point pt) Returns
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object object) Overrides java. Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns an integer hash code for the receiver. Any two
objects that return
| |
| intersect | back to summary |
|---|---|
| public void intersect(Rectangle rect) Destructively replaces the x, y, width and height values in the receiver with ones which represent the intersection of the rectangles specified by the receiver and the given rectangle.
| |
| intersection | back to summary |
|---|---|
| public Rectangle intersection(Rectangle rect) Returns a new rectangle which represents the intersection of the receiver and the given rectangle. The intersection of two rectangles is the rectangle that covers the area which is contained within both rectangles.
| |
| intersects | back to summary |
|---|---|
| public boolean intersects(int x, int y, int width, int height) Returns Two rectangles intersect if the area of the rectangle representing their intersection is not empty.
| |
| intersects | back to summary |
|---|---|
| public boolean intersects(Rectangle rect) Returns Two rectangles intersect if the area of the rectangle representing their intersection is not empty.
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Returns A rectangle is considered to cover area in the (x, y) coordinate plane if both its width and height are non-zero.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string containing a concise, human-readable description of the receiver. | |
| union | back to summary |
|---|---|
| public Rectangle union(Rectangle rect) Returns a new rectangle which represents the union of the receiver and the given rectangle. The union of two rectangles is the smallest single rectangle that completely covers both of the areas covered by the two given rectangles.
| |