public interface Shape
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 other)
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 |
paint(java.awt.Graphics g)
Paint this shape onto the given graphics context.
|
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.
|
int getX()
int getY()
int getCenterX()
int getCenterY()
int getWidth()
int getHeight()
void moveBy(int deltaX, int deltaY)
deltaX
- offset in the X directiondeltaY
- offset in the Y directionvoid moveTo(int x, int y)
x
- new X coordinatey
- new Y coordinatevoid rotateAround(int pivotX, int pivotY, double degrees)
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 degreesjava.awt.Color getColor()
void setColor(java.awt.Color c)
c
- the new color of the shapevoid addTo(GWindow gw)
gw
- the graphics window to add the shape tovoid removeFromWindow()
Rectangle getBoundingBox()
boolean intersects(Shape other)
uwcse.graphics.InternalGWindow currentWindow()
void recordWindow(uwcse.graphics.InternalGWindow gw)
void paint(java.awt.Graphics g)