public class Rect
extends java.lang.Object
Rect
represents a rectangle.
It holds four integer values for a rectangle.
Modifier and Type | Field and Description |
---|---|
int |
bottom
The Y coordinate of the bottom of the rectangle.
|
int |
left
The X coordinate of the left side of the rectangle.
|
int |
right
The X coordinate of the right side of the rectangle.
|
int |
top
The Y coordinate of the top of the rectangle.
|
Constructor and Description |
---|
Rect()
Construct a
Rect object by the default way, and all coordinates are initialized to 0. |
Rect(int left,
int top,
int right,
int bottom)
Construct a
Rect object with the specified coordinates. |
Rect(Rect other)
Construct a
Rect object with the values in the specified
rectangle. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object other)
Check whether the specified object is a
Rect |
java.awt.Rectangle |
getRectangle()
Convert the current rectangle to
Rectangle |
int |
height()
Get the rectangle's height.
|
void |
set(int left,
int top,
int right,
int bottom)
Set the rectangle's coordinates to the specified values.
|
void |
set(Rect src)
Set the coordinates from source rectangle into this rectangle.
|
void |
setEmpty()
Set the rectangle to (0,0,0,0)
|
int |
width()
Get the rectangle's width.
|
public int left
public int top
public int right
public int bottom
public Rect()
Rect
object by the default way, and all coordinates are initialized to 0.public Rect(int left, int top, int right, int bottom)
Rect
object with the specified coordinates.
Note: no range checking is performed.
left
- The specified left side value.top
- The specified top side value.right
- The specified right side value.bottom
- The specified bottom side value.public Rect(Rect other)
Rect
object with the values in the specified
rectangle.
If the specified Rect
object is null, all coordinates will be initialized to 0.
other
- The rectangle whose coordinates are copied into the new
rectangle.public final int width()
public final int height()
public void setEmpty()
public void set(int left, int top, int right, int bottom)
Note: no range checking is performed.
left
- The specified left side value.top
- The specified top side value.right
- The specified right side value.bottom
- The specified bottom side value.public void set(Rect src)
src
- The rectangle whose coordinates are copied into this
rectangle.public java.awt.Rectangle getRectangle()
Rectangle .
Rectangle object.
public boolean equals(java.lang.Object other)
Rect class and its values equal our values.
equals
in class java.lang.Object
other
- The specified object to compare.boolean
value to indicate the result of checking.