| Constructor and Description |
|---|
Rectangle2D()
Creates a new instance of Rectangle
|
Rectangle2D(double x,
double y,
Dimension2D size)
Creates a new instance of Rectangle at position (x, y) and with
predefine dimension
|
Rectangle2D(double x,
double y,
double w,
double h)
Creates a new instance of Rectangle at position (x, y) and with
predefine width and height
|
Rectangle2D(Rectangle2D rect)
A copy Constructor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(double rX,
double rY)
Checks whether or not this Rectangle contains the point at the specified
location (rX, rY).
|
boolean |
contains(double rX,
double rY,
double rWidth,
double rHeight)
Checks whether this Rectangle entirely contains the Rectangle
at the specified location (rX, rY) with the specified
dimensions (rWidth, rHeight).
|
static boolean |
contains(double x1,
double y1,
double w1,
double h1,
double x2,
double y2,
double w2,
double h2)
Checks wheather the 2nd rectangle is contained in the first rectangle
|
boolean |
contains(int x,
int y)
Checks if the shape contains the given point.
|
boolean |
contains(Rectangle2D rect)
Checks whether or not this Rectangle entirely contains the specified
Rectangle.
|
Rectangle |
getBounds()
{Returns the bounding rectangle for the shape.}
|
float[] |
getBounds2D()
{Gets the bounds of the shape as a 4-element array representing the (x,y,width,height)
tuple.}
|
double |
getHeight()
Convenience method for getSize().getHeight();
|
PathIterator |
getPathIterator()
{Gets an iterator to walk all of the path segments of the shape.}
|
PathIterator |
getPathIterator(Transform m)
{Gets an iterator where all points are transformed by the provided transform.}
|
Dimension2D |
getSize()
Return the dimension of the rectangle
|
double |
getWidth()
Convenience method for getSize().getWidth();
|
double |
getX()
Return the x coordinate of the rectangle
|
double |
getY()
Return the y coordinate of the rectangle
|
Rectangle2D |
intersection(double rX,
double rY,
double rW,
double rH)
Returns a rectangle that intersects the given rectangle with this rectangle
|
static void |
intersection(double rrX,
double rrY,
double rrW,
double rrH,
double rtx1,
double rty1,
double rtw2,
double rth2,
Rectangle2D dest)
Returns a rectangle that intersects the given rectangle with this rectangle
|
Shape |
intersection(Rectangle rect)
Returns the shape formed by the intersection of this shape and the provided
rectangle.
|
Rectangle2D |
intersection(Rectangle2D r)
Returns a rectangle that intersects the given rectangle with this rectangle
|
boolean |
intersects(double x,
double y,
double width,
double height)
Determines whether or not this Rectangle and the specified Rectangle
location (x, y) with the specified dimensions (width, height),
intersect.
|
static boolean |
intersects(double tx,
double ty,
double tw,
double th,
double x,
double y,
double width,
double height)
Helper method allowing us to determine if two coordinate sets intersect.
|
boolean |
intersects(Rectangle2D rect)
Determines whether or not this Rectangle and the specified Rectangle
location (x, y) with the specified dimensions (width, height),
intersect.
|
boolean |
isRectangle()
{Checks if this shape is a rectangle.}
|
void |
setBounds(double x,
double y,
double w,
double h)
Helper method to set coordinates
|
void |
setHeight(double h)
Convenience method for getSize().setHeight();
|
void |
setWidth(double w)
Convenience method for getSize().setWidth();
|
void |
setX(double x)
Sets the x position of the rectangle as a double.
|
void |
setX(int x)
Sets the x position of the rectangle
|
void |
setY(double y)
Sets the y position of the rectangle as a double.
|
void |
setY(int y)
Sets the y position of the rectangle
|
String |
toString()
Returns a string representation of the object.
|
void |
translate(double x,
double y) |
public Rectangle2D()
public Rectangle2D(double x,
double y,
Dimension2D size)
x - the x coordinate of the rectangley - the y coordinate of the rectanglesize - the Dimension of the rectanglepublic Rectangle2D(double x,
double y,
double w,
double h)
x - the x coordinate of the rectangley - the y coordinate of the rectanglew - the width of the rectangleh - the height of the rectanglepublic Rectangle2D(Rectangle2D rect)
rect - the Rectangle to copypublic void setBounds(double x,
double y,
double w,
double h)
public double getWidth()
public void setWidth(double w)
w - the widthpublic void setHeight(double h)
h - the heightpublic double getHeight()
public Dimension2D getSize()
public double getX()
public double getY()
public String toString()
public void setX(int x)
x - the x coordinate of the rectanglepublic void setX(double x)
x - public void setY(int y)
y - the y coordinate of the rectanglepublic void setY(double y)
y - The y positionpublic boolean contains(Rectangle2D rect)
rect - the specified Rectanglepublic boolean contains(double rX,
double rY,
double rWidth,
double rHeight)
rX - the specified x coordinaterY - the specified y coordinaterWidth - the width of the RectanglerHeight - the height of the Rectanglepublic static boolean contains(double x1,
double y1,
double w1,
double h1,
double x2,
double y2,
double w2,
double h2)
x1 - first rect xy1 - first rect yw1 - first rect wh1 - first rect hx2 - second rect xy2 - second rect yw2 - second rect wh2 - second rect hpublic boolean contains(double rX,
double rY)
rX - the specified x coordinaterY - the specified y coordinatepublic Rectangle2D intersection(double rX, double rY, double rW, double rH)
rX - rectangle to intersect with this rectanglerY - rectangle to intersect with this rectanglerW - rectangle to intersect with this rectanglerH - rectangle to intersect with this rectanglepublic static void intersection(double rrX,
double rrY,
double rrW,
double rrH,
double rtx1,
double rty1,
double rtw2,
double rth2,
Rectangle2D dest)
rrX - rectangle to intersect with this rectanglerrY - rectangle to intersect with this rectanglerrW - rectangle to intersect with this rectanglerrH - rectangle to intersect with this rectanglertx1 - rectangle to intersect with this rectanglerty1 - rectangle to intersect with this rectanglertw2 - rectangle to intersect with this rectanglerth2 - rectangle to intersect with this rectangledest - result of the intersection are stored herepublic Rectangle2D intersection(Rectangle2D r)
r - rectangle to intersect with this rectanglepublic boolean intersects(double x,
double y,
double width,
double height)
x - the specified x coordinatey - the specified y coordinatewidth - the width of the Rectangleheight - the height of the Rectanglepublic boolean intersects(Rectangle2D rect)
rect - the Rectangle to check intersection withpublic static boolean intersects(double tx,
double ty,
double tw,
double th,
double x,
double y,
double width,
double height)
tx - x of first rectanglety - y of first rectangletw - width of first rectangleth - height of first rectanglex - x of second rectangley - y of second rectanglewidth - width of second rectangleheight - height of second rectanglepublic PathIterator getPathIterator(Transform m)
Note: If Transform.isSupported() is false, then using this iterator will throw a Runtime Exception.
getPathIterator in interface Shapepublic PathIterator getPathIterator()
getPathIterator in interface Shapepublic Rectangle getBounds()
public float[] getBounds2D()
getBounds2D in interface Shapepublic boolean isRectangle()
isRectangle in interface Shapepublic boolean contains(int x,
int y)
Shapepublic Shape intersection(Rectangle rect)
Shapeintersection in interface Shaperect - A rectangle with which to form an intersection.public void translate(double x,
double y)