objectdraw
Class Drawable2D
java.lang.Object
|
+--objectdraw.Drawable
|
+--objectdraw.Drawable2D
- All Implemented Interfaces:
- Drawable2DInterface, DrawableInterface, java.io.Serializable
- Direct Known Subclasses:
- Resizable2D, Text
- public abstract class Drawable2D
- extends Drawable
- implements Drawable2DInterface
Drawable2D extends Drawable and defines a set of accessor methods
for the width, height, and location of Drawable objects.
It also defines a paint method.
- See Also:
- Serialized Form
Method Summary |
boolean |
contains(Location point)
Determines if the object contains the
given point. |
void |
draw(java.awt.Graphics g)
Draws the object. |
double |
getHeight()
Gets the height of the object's bounding rectangle |
Location |
getLocation()
Get the coordinates of the object's bounding rectangle's
upper left corner. |
double |
getX()
Get the x coordinate of the object's bounding rectangle's
upper left corner. |
double |
getY()
Get the y coordinate of the object's bounding rectangle's
upper left corner. |
boolean |
overlaps(Drawable2DInterface item)
Determines if another Drawable's bounding box overlaps
with this object's bounding box. |
Methods inherited from class objectdraw.Drawable |
addToCanvas, getColor, hide, isHidden, move, moveTo, moveTo, removeFromCanvas, sendBackward, sendForward, sendToBack, sendToFront, setColor, setStateChanged, show |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface objectdraw.DrawableInterface |
addToCanvas, getColor, hide, isHidden, move, moveTo, moveTo, removeFromCanvas, sendBackward, sendForward, sendToBack, sendToFront, setColor, show |
Drawable2D
public Drawable2D()
draw
public void draw(java.awt.Graphics g)
- Draws the object.
- Specified by:
draw
in interface DrawableInterface
- Overrides:
draw
in class Drawable
- Parameters:
g
- the graphics context into which the object is drawn
getHeight
public double getHeight()
- Gets the height of the object's bounding rectangle
- Specified by:
getHeight
in interface Drawable2DInterface
- Returns:
- the height of the object's bounding rectangle
getX
public double getX()
- Get the x coordinate of the object's bounding rectangle's
upper left corner.
- Specified by:
getX
in interface Drawable2DInterface
- Returns:
- the x coordinate of the object's bounding
rectangle's upper left corner
getY
public double getY()
- Get the y coordinate of the object's bounding rectangle's
upper left corner.
- Specified by:
getY
in interface Drawable2DInterface
- Returns:
- the y coordinate of the object's bounding
rectangle's upper left corner
getLocation
public Location getLocation()
- Get the coordinates of the object's bounding rectangle's
upper left corner.
- Specified by:
getLocation
in interface Drawable2DInterface
- Returns:
- object's bounding rectangle's upper left corner
contains
public boolean contains(Location point)
- Determines if the object contains the
given point.
- Specified by:
contains
in interface DrawableInterface
- Overrides:
contains
in class Drawable
- Parameters:
point
- the point- Returns:
true
if point is contained in the object;
false
otherwise.
overlaps
public boolean overlaps(Drawable2DInterface item)
- Determines if another Drawable's bounding box overlaps
with this object's bounding box.
- Specified by:
overlaps
in interface Drawable2DInterface
- Parameters:
item
- the other object- Returns:
true
if item intersects this object;
false
otherwise.