public class Rectangle extends java.lang.Object implements BoundingBox
Rectangle
specifies an area in a coordinate space that is enclosed by the Rectangle
object's upper-left point Point
in the coordinate space, its width, and its
height.Constructor and Description |
---|
Rectangle(double x,
double y,
double width,
double height)
Constructs a new
Rectangle whose upper-left corner is specified as (x,y) and
whose width and height are specified by the arguments of the same name. |
Rectangle(Point point,
double width,
double height)
Constructs a new
Rectangle whose upper-left corner is specified as coordinate point and whose width and height are specified by the arguments of the same name. |
Modifier and Type | Method and Description |
---|---|
void |
draw(java.awt.Graphics2D g,
int imageWidth,
int imageHeight)
Draws the bounding box using the
Graphics2D . |
Rectangle |
getBounds()
Returns the bounding
Rectangle of this BoundingBox . |
double |
getHeight()
Returns the height of the Rectangle.
|
PathIterator |
getPath()
Returns an iterator object that iterates along the
BoundingBox boundary and provides
access to the geometry of the BoundingBox outline. |
Point |
getPoint()
Returns the top left point of the bounding box.
|
double |
getWidth()
Returns the width of the Rectangle.
|
double |
getX()
Returns the left x-coordinate of the Rectangle.
|
double |
getY()
Returns the top y-coordinate of the Rectangle.
|
java.lang.String |
toString() |
public Rectangle(double x, double y, double width, double height)
Rectangle
whose upper-left corner is specified as (x,y)
and
whose width and height are specified by the arguments of the same name.x
- the specified X coordinatey
- the specified Y coordinatewidth
- the width of the Rectangle
height
- the height of the Rectangle
public Rectangle(Point point, double width, double height)
Rectangle
whose upper-left corner is specified as coordinate point
and whose width and height are specified by the arguments of the same name.point
- the upper-left corner of the coordinatewidth
- the width of the Rectangle
height
- the height of the Rectangle
public Rectangle getBounds()
Rectangle
of this BoundingBox
.getBounds
in interface BoundingBox
Rectangle
for this BoundingBox
public PathIterator getPath()
BoundingBox
boundary and provides
access to the geometry of the BoundingBox
outline.getPath
in interface BoundingBox
PathIterator
object, which independently traverses the geometry of the
BoundingBox
public Point getPoint()
getPoint
in interface BoundingBox
Point
of the top left cornerpublic void draw(java.awt.Graphics2D g, int imageWidth, int imageHeight)
Graphics2D
.draw
in interface BoundingBox
g
- the Graphics2D object of the imageimageWidth
- the width of the imageimageHeight
- the height of the imagepublic double getX()
public double getY()
public double getWidth()
public double getHeight()
public java.lang.String toString()
toString
in class java.lang.Object