public abstract class PolyShape extends ShapeImpl
Constructor and Description |
---|
PolyShape(java.awt.Color c,
boolean filled)
Create a new polygon of the given color and filledness.
|
Modifier and Type | Method and Description |
---|---|
void |
addPoint(int x,
int y)
Add a new vertex to the polygon.
|
void |
moveTo(int x,
int y)
Move the polygon so that the upper-left corner of its bounding
rectangle is the given coordinates.
|
void |
paint(java.awt.Graphics g)
Paint this shape onto the given graphics context.
|
void |
resize(int newWidth,
int newHeight)
Change the width and height of the polygon
|
void |
rotateAround(int pivotX,
int pivotY,
double degrees)
Rotate the shape around the argument coordinates by the given
number of degrees, counter-clockwise.
|
java.lang.String |
toString()
Answer the printed representation of this shape.
|
addTo, currentWindow, getBoundingBox, getCenterX, getCenterY, getColor, getHeight, getWidth, getX, getY, intersects, moveBy, recordWindow, removeFromWindow, setColor
public PolyShape(java.awt.Color c, boolean filled)
c
- the color of the polygonfilled
- should it be filled?public void addPoint(int x, int y)
x
- the X coordinate of the new vertexy
- the Y coordinate of the new vertexpublic void paint(java.awt.Graphics g)
Shape
public void moveTo(int x, int y)
public void rotateAround(int pivotX, int pivotY, double degrees)
Shape
rotateAround
in interface Shape
rotateAround
in class ShapeImpl
pivotX
- the X coordinate of the point around which to
rotate the shapepivotY
- the Y coordinate of the point around which to
rotate the shapedegrees
- the angle to rotate by counter-clockwise, in degreespublic void resize(int newWidth, int newHeight)
newWidth
- the new widthnewHeight
- the new height