public class ResizableRectangle
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
NUM_SIDES |
Constructor and Description |
---|
ResizableRectangle()
Creates a rectangle with horizontal and vertical positions and sizes equal to 1.0.
|
ResizableRectangle(double x,
double y,
double xSize,
double ySize)
Creates a rectangle with the specified horizontal and vertical positions and sizes.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Returns
true if the rectangle is equal to another rectangle. |
double |
getXPos()
Returns the horizontal position of the rectangle.
|
double |
getXSize()
Returns the horizontal size of the rectangle.
|
double |
getYPos()
Returns the vertical position of the rectangle.
|
double |
getYSize()
Returns the vertical size of the rectangle.
|
boolean |
intersect(ResizableRectangle other)
Returns
true if the rectangle intersects another rectangle. |
static int |
numInstances()
Returns number of times the class has been instantiated.
|
void |
setPos(double x,
double y)
Sets the horizontal and vertical positions of the rectangle.
|
void |
setSize(double xSize,
double ySize)
Sets the horizontal and vertical size of the rectangle.
|
void |
setXPos(double x)
Sets the horizontal position of the rectangle.
|
void |
setXSize(double xSize)
Sets the horizontal size of the rectangle.
|
void |
setYPos(double y)
Sets the vertical position of the rectangle.
|
void |
setYSize(double ySize)
Sets the vertical size of the rectangle.
|
java.lang.String |
toString()
Returns the string representation of the rectangle.
|
public static final int NUM_SIDES
public ResizableRectangle()
public ResizableRectangle(double x, double y, double xSize, double ySize)
x
- horizontal positiony
- vertical positionxSize
- horizontal sizeySize
- vertical sizepublic double getXPos()
public double getYPos()
public double getXSize()
public double getYSize()
public void setPos(double x, double y)
x
- horizontal position, top left corner of the rectangley
- vertical position, top left corner of the rectanglepublic void setXPos(double x)
x
- horizontal position, top left corner of the rectanglepublic void setYPos(double y)
y
- vertical position, top left corner of the rectanglepublic void setSize(double xSize, double ySize)
xSize
- horizontal sizeySize
- vertical sizepublic void setXSize(double xSize)
xSize
- horizontal sizepublic void setYSize(double ySize)
ySize
- horizontal sizepublic boolean intersect(ResizableRectangle other)
true
if the rectangle intersects another rectangle.
The rectangles intersect when their sides or vertices are adjacent, when the rectangles intersect, and when one rectangle is completely inside the other.other
- another rectanglepublic static int numInstances()
public boolean equals(java.lang.Object obj)
true
if the rectangle is equal to another rectangle.
The rectangles are equal if they have the same vertical and horizontal size.equals
in class java.lang.Object
obj
- another rectanglepublic java.lang.String toString()
toString
in class java.lang.Object