objectdraw
Interface DrawableInterface

All Known Subinterfaces:
Drawable1DInterface, Drawable2DInterface, LocatableInterface, Resizable2DInterface
All Known Implementing Classes:
AngLine, Animation, FilledArc, FilledOval, FilledRect, FilledRoundedRect, FramedArc, FramedOval, FramedRect, FramedRoundedRect, Line, objectdraw.ObjectDrawRectangularShape, objectdraw.ObjectDrawShape, Text, Turtle, VisibleImage

public interface DrawableInterface

DrawableInterface is the interface shared by all objects that can be drawn on a canvas. It includes methods for moving objects, hiding and showing them, changing their order, and manipulating their color and canvas.

Author:
Russell Zahniser (russell@zahniser.net)

Method Summary
 void addToCanvas(DrawingCanvas c)
          Place this object on the specified canvas.
 boolean contains(Location point)
          Return true if the given location is inside this object, false otherwise.
 DrawingCanvas getCanvas()
          Return the canvas that this object is on.
 Color getColor()
          Return the color of this object
 void hide()
          Make this object invisible.
 boolean isHidden()
          Return true if this object has been rendered invisible with a call to its hide() method, false if it is still being drawn.
 void move(double dx, double dy)
          Shift (translate) this object left or right by an amount dx, and up or down by an amount dy.
 void moveTo(double x, double y)
          Move the reference point of this object to the given location.
 void moveTo(Location point)
          Move the reference point of this object to the given location.
 void removeFromCanvas()
          Remove this object from its canvas.
 void sendBackward()
          Move this object one step backward in the draw order, causing it to be drawn underneath the objects that are in front of it.
 void sendForward()
          Move this object one step forward in the draw order, causing it to be drawn on top of the objects that are behind it.
 void sendToBack()
          Move this object to the very back of the draw order, causing it to be drawn underneath all the other objects.
 void sendToFront()
          Move this object to the very front of the draw order, causing it to be drawn on top of all the other objects.
 void setColor(Color c)
          Change the color of this object.
 void show()
          Make an object visible again after it had been hidden.
 

Method Detail

addToCanvas

void addToCanvas(DrawingCanvas c)
Place this object on the specified canvas. The object will be removed from its current canvas, if it is on a canvas that is not the one it is being moved to. The object will be at the front of the canvas, as if it had just been drawn. If the given canvas is null the object is simply removed from its current canvas.

Parameters:
c - DrawingCanvas to place this object on

contains

boolean contains(Location point)
Return true if the given location is inside this object, false otherwise. Because Lines and FramedArcs have no "inside", a point is considered to be contained in one of them as long as it is within a few pixels of the line.

Parameters:
point - Location to test
Returns:
whether the given location is inside this shape

getCanvas

DrawingCanvas getCanvas()
Return the canvas that this object is on. If it has been removed from its canvas, this method will return null.

Returns:
the DrawingCanvas that this object is on.

getColor

Color getColor()
Return the color of this object

Returns:
the Color of this object

hide

void hide()
Make this object invisible. It stays in position on its canvas; it is simply not drawn. This method has no effect if the object was already hidden.


isHidden

boolean isHidden()
Return true if this object has been rendered invisible with a call to its hide() method, false if it is still being drawn.

Returns:
whether this object is hidden

move

void move(double dx,
          double dy)
Shift (translate) this object left or right by an amount dx, and up or down by an amount dy. A negative dx indicates a shift to the left; a negative dy indicates a shift up

Parameters:
dx - amount of x translation
dy - amount of y translation

moveTo

void moveTo(double x,
            double y)
Move the reference point of this object to the given location. For a Drawable2D object, the reference point is the top left corner; for a line, it is the start point.

Parameters:
x - x coordinate to move to
y - y coordinate to move to

moveTo

void moveTo(Location point)
Move the reference point of this object to the given location. For a Drawable2D object, the reference point is the top left corner; for a line, it is the start point.

Parameters:
point - Location to move to

removeFromCanvas

void removeFromCanvas()
Remove this object from its canvas.


sendBackward

void sendBackward()
Move this object one step backward in the draw order, causing it to be drawn underneath the objects that are in front of it.


sendForward

void sendForward()
Move this object one step forward in the draw order, causing it to be drawn on top of the objects that are behind it.


sendToBack

void sendToBack()
Move this object to the very back of the draw order, causing it to be drawn underneath all the other objects.


sendToFront

void sendToFront()
Move this object to the very front of the draw order, causing it to be drawn on top of all the other objects.


setColor

void setColor(Color c)
Change the color of this object.

Parameters:
c - new Color for this object

show

void show()
Make an object visible again after it had been hidden. This method has no effect if the object was already visible.