|
||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uwcse.graphics.ShapeImpl
This is an abstract superclass of all shape objects. All dimensions are in pixels. Shapes are either filled or unfilled. If they are unfilled they are drawn as outlines of the shape. Shapes are always drawn/filled in their color.
Constructor Summary | |
ShapeImpl(java.awt.Color c,
boolean filled)
A new shaped, possibly filled with the given color. |
Method Summary | |
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. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface uwcse.graphics.Shape |
paint |
Constructor Detail |
public ShapeImpl(java.awt.Color c, boolean filled)
c
- the color of the shapefilled
- whether or not to fill the shape's outline with colorMethod Detail |
public void addTo(GWindow gw)
Shape
addTo
in interface Shape
uwcse.graphics.Shape
gw
- the graphics window to add the shape topublic uwcse.graphics.InternalGWindow currentWindow()
Shape
currentWindow
in interface Shape
public Rectangle getBoundingBox()
Shape
getBoundingBox
in interface Shape
public int getCenterX()
Shape
getCenterX
in interface Shape
public int getCenterY()
Shape
getCenterY
in interface Shape
public java.awt.Color getColor()
Shape
getColor
in interface Shape
public int getHeight()
Shape
getHeight
in interface Shape
public int getWidth()
Shape
getWidth
in interface Shape
public int getX()
Shape
getX
in interface Shape
public int getY()
Shape
getY
in interface Shape
public boolean intersects(Shape s)
Shape
intersects
in interface Shape
public void moveBy(int deltaX, int deltaY)
Shape
moveBy
in interface Shape
uwcse.graphics.Shape
deltaX
- offset in the X directiondeltaY
- offset in the Y directionpublic void moveTo(int x, int y)
Shape
moveTo
in interface Shape
uwcse.graphics.Shape
x
- new X coordinatey
- new Y coordinatepublic void recordWindow(uwcse.graphics.InternalGWindow gw)
Shape
recordWindow
in interface Shape
public void removeFromWindow()
Shape
removeFromWindow
in interface Shape
public void rotateAround(int pivotX, int pivotY, double degrees)
Shape
rotateAround
in interface Shape
uwcse.graphics.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 void setColor(java.awt.Color c)
Shape
setColor
in interface Shape
uwcse.graphics.Shape
c
- the new color of the shapepublic java.lang.String toString()
toString
in class java.lang.Object
|
||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |