public abstract class ShapeImpl extends java.lang.Object implements Shape
Constructor and Description |
---|
ShapeImpl(java.awt.Color c,
boolean filled)
A new shaped, possibly filled with the given color.
|
Modifier and Type | Method and Description |
---|---|
void |
addTo(GWindow gw)
Add the shape to the given graphics window, if non-null.
|
uwcse.graphics.InternalGWindow |
currentWindow()
Return the window this shape is currently displayed on, or null
if not displayed on any window.
|
Rectangle |
getBoundingBox()
Return the shape's bounding box (the smallest rectangle
enclosing the shape).
|
int |
getCenterX()
Return the X coordinate of the shape's center
|
int |
getCenterY()
Return the Y coordinate of the shape's center
|
java.awt.Color |
getColor()
Answer the color of this shape.
|
int |
getHeight()
Return the height of the shape's bounding box (the smallest rectangle
enclosing the shape).
|
int |
getWidth()
Return the width of the shape's bounding box (the smallest rectangle
enclosing the shape).
|
int |
getX()
Return the X coordinate of the shape's upper-left corner
|
int |
getY()
Return the Y coordinate of the shape's upper-left corner
|
boolean |
intersects(Shape s)
Return whether this shape's bounding box intersects with the
argument shape's bounding box.
|
void |
moveBy(int deltaX,
int deltaY)
Change this shape's position.
|
void |
moveTo(int x,
int y)
Change this shape's position.
|
void |
recordWindow(uwcse.graphics.InternalGWindow gw)
Tell the shape that it belongs to the given window.
|
void |
removeFromWindow()
Remove the shape from its graphics window, if it is added to one.
|
void |
rotateAround(int pivotX,
int pivotY,
double degrees)
Rotate the shape around the argument coordinates by the given
number of degrees, counter-clockwise.
|
void |
setColor(java.awt.Color c)
Set the color of this shape.
|
java.lang.String |
toString()
Answer the printed representation of this shape.
|
public ShapeImpl(java.awt.Color c, boolean filled)
c
- the color of the shapefilled
- whether or not to fill the shape's outline with colorpublic void addTo(GWindow gw)
Shape
public void removeFromWindow()
Shape
removeFromWindow
in interface Shape
public boolean intersects(Shape s)
Shape
intersects
in interface Shape
public Rectangle getBoundingBox()
Shape
getBoundingBox
in interface Shape
public void moveBy(int deltaX, int deltaY)
Shape
public void moveTo(int x, int y)
Shape
public int getX()
Shape
public int getY()
Shape
public int getWidth()
Shape
public int getHeight()
Shape
public int getCenterX()
Shape
getCenterX
in interface Shape
public int getCenterY()
Shape
getCenterY
in interface Shape
public java.awt.Color getColor()
Shape
public void setColor(java.awt.Color c)
Shape
public void rotateAround(int pivotX, int pivotY, double degrees)
Shape
rotateAround
in interface Shape
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 uwcse.graphics.InternalGWindow currentWindow()
Shape
currentWindow
in interface Shape
public void recordWindow(uwcse.graphics.InternalGWindow gw)
Shape
recordWindow
in interface Shape
public java.lang.String toString()
toString
in class java.lang.Object