RectangleShape
public abstract class AbstractShape
extends java.lang.Object
Modifier and Type | Field | Description |
---|---|---|
protected java.awt.Color |
color |
the color of this shape
|
static java.lang.String |
OVAL |
|
protected java.awt.Point |
p1 |
the first point in the shape
|
protected java.awt.Point |
p2 |
the second point in the shape
|
static java.lang.String |
RECTANGLE |
Constructor | Description |
---|---|
AbstractShape() |
Constructor that takes no arguments
|
AbstractShape(int x1,
int y1,
int x2,
int y2) |
Constructor that takes x1,y1,x2,y2
|
AbstractShape(java.awt.Point firstPoint,
java.awt.Point secondPoint) |
Constructor that takes the first and second point
|
Modifier and Type | Method | Description |
---|---|---|
abstract void |
draw(java.awt.Graphics g) |
Abstract method to draw the shape given the graphics context
|
int |
getHeight() |
Method to get the height of the bounding rectangle
|
int |
getMinX() |
Method to get minimum x value of the bounding rectangle
|
int |
getMinY() |
Method to get the minimum y value of the bounding rectangle
|
int |
getWidth() |
Method to get the width of the bounding rectangle
|
void |
setPoint1Values(int newX,
int newY) |
Method to set the point values for point1 that defines the shape
|
void |
setPoint2Values(int newX,
int newY) |
Method to set the point values for point2 that defines the shape
|
public static final java.lang.String RECTANGLE
public static final java.lang.String OVAL
protected java.awt.Color color
protected java.awt.Point p1
protected java.awt.Point p2
public AbstractShape()
public AbstractShape(java.awt.Point firstPoint, java.awt.Point secondPoint)
firstPoint
- the first point that defines the shapesecondPoint
- the second point that defines the shapepublic AbstractShape(int x1, int y1, int x2, int y2)
x1
- x value of the first point that defines the shapey1
- y value of the first point that defines the shapex2
- x value of the second point that defines the shapey2
- y value of the second point that defines the shapepublic int getMinX()
public int getMinY()
public int getWidth()
public int getHeight()
public void setPoint1Values(int newX, int newY)
newX
- the new x value for point 1newY
- the new y value for point 1public void setPoint2Values(int newX, int newY)
newX
- the new x value for point 2newY
- the new y value for point 2public abstract void draw(java.awt.Graphics g)
g
- the graphics context to draw the shape on