objectdraw
Class Drawable2D

java.lang.Object
  extended by objectdraw.Drawable
      extended by objectdraw.Drawable2D
All Implemented Interfaces:
Serializable, Drawable2DInterface, DrawableInterface
Direct Known Subclasses:
Resizable2D, Text

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 methods to determine if objects overlap.

Version:
1.1.1 released February 2005

Field Summary
 
Fields inherited from class objectdraw.Drawable
canvasContent, color, shown
 
Constructor Summary
Drawable2D()
           
 
Method Summary
 boolean contains(Location point)
          Determines if a particular position on the DrawingCanvas is contained within the object.
(package private)  void draw(Graphics g)
          Draws the object.
(package private) abstract  Bounds getBounds()
          Gets the object's bounding rectangle
abstract  double getHeight()
          Get the height of a graphical object
 Location getLocation()
          Get a graphical object's position
abstract  double getWidth()
          Get the width of a graphical object
 double getX()
          Get the x coordinate of left edge of rectangle bounding the object
 double getY()
          Get the y coordinate of top edge of rectangle bounding the object
 boolean overlaps(Drawable2DInterface item)
          Determines if another Drawable's bounding rectangle overlaps with this object's bounding rectangle.
 
Methods inherited from class objectdraw.Drawable
addToCanvas, clearCanvasContent, getCanvas, getColor, hide, isHidden, move, moveTo, moveTo, removeFromCanvas, sendBackward, sendForward, sendToBack, sendToFront, setCanvasContent, 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, getCanvas, getColor, hide, isHidden, move, moveTo, moveTo, removeFromCanvas, sendBackward, sendForward, sendToBack, sendToFront, setColor, show
 

Constructor Detail

Drawable2D

Drawable2D()
Method Detail

contains

public boolean contains(Location point)
Description copied from interface: DrawableInterface
Determines if a particular position on the DrawingCanvas is contained within the object.

Specified by:
contains in interface DrawableInterface
Specified by:
contains in class Drawable
Parameters:
point - the position on the canvas.
Returns:
true if point is contained in the object, false otherwise.

draw

void draw(Graphics g)
Draws the object.

Overrides:
draw in class Drawable
Parameters:
g - the graphics context into which the object is drawn

getBounds

abstract Bounds getBounds()
Gets the object's bounding rectangle

Returns:
the object's bounding rectangle

getHeight

public abstract double getHeight()
Description copied from interface: Drawable2DInterface
Get the height of a graphical object

Specified by:
getHeight in interface Drawable2DInterface
Returns:
the height of the object's bounding rectangle

getLocation

public Location getLocation()
Description copied from interface: Drawable2DInterface
Get a graphical object's position

Specified by:
getLocation in interface Drawable2DInterface
Returns:
the location of the upper left corner of the object's bounding rectangle

getWidth

public abstract double getWidth()
Description copied from interface: Drawable2DInterface
Get the width of a graphical object

Specified by:
getWidth in interface Drawable2DInterface
Returns:
the width of the object's bounding rectangle

getX

public double getX()
Description copied from interface: Drawable2DInterface
Get the x coordinate of left edge of rectangle bounding the object

Specified by:
getX in interface Drawable2DInterface
Returns:
the x coordinate of the upper left corner of the object's bounding rectangle

getY

public double getY()
Description copied from interface: Drawable2DInterface
Get the y coordinate of top edge of rectangle bounding the object

Specified by:
getY in interface Drawable2DInterface
Returns:
the y coordinate of the upper left corner of the object's bounding rectangle

overlaps

public boolean overlaps(Drawable2DInterface item)
Description copied from interface: Drawable2DInterface
Determines if another Drawable's bounding rectangle overlaps with this object's bounding rectangle.

Specified by:
overlaps in interface Drawable2DInterface
Parameters:
item - the other object
Returns:
true if item intersects this object; false otherwise.