objectdraw
Interface DrawableInterface

All Known Subinterfaces:
Drawable2DInterface, Resizable2DInterface
All Known Implementing Classes:
Drawable

public interface DrawableInterface

DrawableInterface is an interface for objects being placed on a DrawingCanvas.


Method Summary
 void addToCanvas(DrawingCanvas c)
          Sets the drawing canvas for the object.
 boolean contains(Location point)
          Determines if a point is contained in the object.
 void draw(java.awt.Graphics g)
          Draws the object.
 java.awt.Color getColor()
          Retrieves the color of the object.
 void hide()
          Hides the object.
 boolean isHidden()
           
 void move(double dx, double dy)
          Moves the object within the canvas in the x and y direction the amount specified by the parameters.
 void moveTo(double x, double y)
          Moves the object within the canvas to the x and y coordinates provided.
 void moveTo(Location point)
          Moves the object within the canvas to the specified Location
 void removeFromCanvas()
          Permanently removes the object from the canvas it is currently on.
 void sendBackward()
          Sends the object backward.
 void sendForward()
          Sends the object forward.
 void sendToBack()
          Sends the object to the back.
 void sendToFront()
          Sends the object to the front.
 void setColor(java.awt.Color c)
          Sets the color of the object.
 void show()
          Shows the object if it has been hidden.
 

Method Detail

draw

public void draw(java.awt.Graphics g)
Draws the object.
Parameters:
g - the graphics context into which the object is drawn.

hide

public void hide()
Hides the object.

show

public void show()
Shows the object if it has been hidden.

isHidden

public boolean isHidden()
Returns:
True if the object is currently hidden.

moveTo

public void moveTo(Location point)
Moves the object within the canvas to the specified Location
Parameters:
point - the destination for moving the object.

moveTo

public void moveTo(double x,
                   double y)
Moves the object within the canvas to the x and y coordinates provided.
Parameters:
x - horizontal coordinate of destination.
y - horizontal coordinate of destination.

move

public void move(double dx,
                 double dy)
Moves the object within the canvas in the x and y direction the amount specified by the parameters.
Parameters:
dx - the amount to move in the x-direction.
dy - the amount to move in the y-direction.

setColor

public void setColor(java.awt.Color c)
Sets the color of the object.
Parameters:
c - the color.

getColor

public java.awt.Color getColor()
Retrieves the color of the object.

sendForward

public void sendForward()
Sends the object forward.

sendBackward

public void sendBackward()
Sends the object backward.

sendToFront

public void sendToFront()
Sends the object to the front.

sendToBack

public void sendToBack()
Sends the object to the back.

contains

public boolean contains(Location point)
Determines if a point is contained in the object.
Parameters:
point - the point.
Returns:
true if point is contained in the object, false otherwise.

addToCanvas

public void addToCanvas(DrawingCanvas c)
Sets the drawing canvas for the object. This should be called when a Drawable object is loaded from a file or other stream since the DrawingCanvas is not serialized. This does nothing if the object is already on a canvas.
Parameters:
c - the canvas on which the object will be drawn

removeFromCanvas

public void removeFromCanvas()
Permanently removes the object from the canvas it is currently on. If you want to just make an object temporarily invisible, call hide instead.