public class Rectangle
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static Rectangle |
NULL_RECTANGLE
Denotes an empty rectangle.
|
| Constructor and Description |
|---|
Rectangle(int x1,
int y1,
int x2,
int y2)
Creates a rectangle specifying its 4 coordinates.
|
Rectangle(Rectangle rectangle)
Creates a rectangle from another one.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(Rectangle rectangleCandidate)
Checks whether a rectangle is included or equal to this rectangle.
|
int |
getHeight()
Gets the height of this rectangle.
|
int |
getSize()
Gets the size of the rectangle.
|
int |
getWidth()
Gets the width of this rectangle.
|
int |
getX1()
Gets the left x coordinate.
|
int |
getX2()
Gets the right x coordinate.
|
int |
getY1()
Gets the top y coordinate.
|
int |
getY2()
Gets the bottom y coordinate.
|
boolean |
isEmpty()
Tells whether the rectangle is empty.
|
boolean |
isEqual(Rectangle rectangleCandidate)
Tells whether a rectangle is equal to this rectangle.
|
void |
setX1(int x)
Sets the left x.
|
void |
setX2(int x)
Sets the right x.
|
void |
setY1(int y)
Sets the top y.
|
void |
setY2(int y)
Sets the bottom y.
|
public static final Rectangle NULL_RECTANGLE
public Rectangle(int x1,
int y1,
int x2,
int y2)
x1 - the left x coordinatey1 - the top y coordinatex2 - the right x coordinatey2 - the bottom y coordinatepublic Rectangle(Rectangle rectangle)
rectangle - the rectangle to copypublic int getX1()
public int getY1()
public int getX2()
public int getY2()
public void setX1(int x)
x - the x to set.public void setY1(int y)
y - the y to set.public void setX2(int x)
x - the x to set.public void setY2(int y)
y - the y to set.public int getWidth()
public int getHeight()
public boolean contains(Rectangle rectangleCandidate)
rectangleCandidate - the rectangle to checktrue if the given rectangle is included in this one, false otherwisepublic boolean isEqual(Rectangle rectangleCandidate)
rectangleCandidate - the rectangle to checktrue if the given rectangle is equal to this one, false otherwisepublic boolean isEmpty()
true if the rectangle has a null areapublic int getSize()