Constructor Summary |
GRectangle()
Constructs a new empty GRectangle. |
GRectangle(double width,
double height)
Constructs a GRectangle at the origin with the specified width and height. |
GRectangle(double x,
double y,
double width,
double height)
Constructs a new GRectangle with the specified coordinates and size. |
GRectangle(GDimension size)
Constructs a new GRectangle at the origin with the specified size. |
GRectangle(GPoint pt)
Constructs a new empty GRectangle at the specified location. |
GRectangle(GPoint pt,
GDimension size)
Constructs a new GRectangle with the specified location and size. |
GRectangle(GRectangle r)
Constructs a new GRectangle from an existing one. |
Method Summary |
void |
add(double x,
double y)
Adds the specified point to the rectangle. |
void |
add(GRectangle r)
Adjusts the bounds of the current GRectangle so that it contains
the rectangle represented by the argument. |
boolean |
contains(double x,
double y)
Returns true if the GRectangle contains the specified point. |
boolean |
contains(GPoint pt)
Returns true if the GRectangle contains the specified point. |
GRectangle |
getBounds()
Returns a new GRectangle whose bounds are the same as this one. |
double |
getHeight()
Returns the height of this GDimension. |
GPoint |
getLocation()
Returns a new GPoint with the location of the rectangle. |
GDimension |
getSize()
Returns a new GDimension object with the size of the GRectangle. |
double |
getWidth()
Returns the width of this GDimension. |
double |
getX()
Returns the x coordinate of this GRectangle. |
double |
getY()
Returns the y coordinate of this GRectangle. |
void |
grow(double dx,
double dy)
Adjusts the edges of a rectangle by the specified dx and dy offsets along each of its borders. |
GRectangle |
intersection(GRectangle r)
Returns the largest rectangle that is contained in both
r1 and r2. |
boolean |
intersects(GRectangle r)
Returns true if r1 and r2 have a nonempty
intersection. |
boolean |
isEmpty()
Returns true if the rectangle is empty. |
void |
setBounds(double x,
double y,
double width,
double height)
Sets the components of a GRectangle from the specified values. |
void |
setBounds(GPoint pt,
GDimension size)
Sets the components of a GRectangle from the specified location and size. |
void |
setBounds(GRectangle bounds)
Sets the bounds of one GRectangle equal to that of another. |
void |
setLocation(double x,
double y)
Sets the location of the GRectangle to the specified x and y values. |
void |
setLocation(GPoint pt)
Sets the location of the GRectangle to the specified point. |
void |
setSize(double width,
double height)
Sets the size of the GRectangle to the specified values. |
void |
setSize(GDimension size)
Sets the size of the GRectangle to the specified dimension. |
Rectangle |
toRectangle()
Converts this GRectangle to the nearest integer-based Rectangle. |
void |
translate(double dx,
double dy)
Adjusts the coordinates of a rectangle by the specified dx and
dy offsets. |
GRectangle |
union(GRectangle r)
Returns the smallest rectangle that contains both
r1 and r2. |