objectdraw
Interface DrawableInterface

All Known Subinterfaces:
Drawable1DInterface, Drawable2DInterface, Resizable2DInterface
All Known Implementing Classes:
objectdraw.Drawable, objectdraw.Drawable2D, FilledArc, FilledOval, FilledRect, FilledRoundedRect, FramedArc, FramedOval, FramedRect, FramedRoundedRect, Line, objectdraw.Rectangular, Text, VisibleImage

public interface DrawableInterface

DrawableInterface describes the methods available for manipulating any graphical object placed on a DrawingCanvas.

Version:
1.1.2 released July 2006

Method Summary
 void addToCanvas(DrawingCanvas c)
          Places an existing object on a specified DrawingCanvas.
 boolean contains(Location point)
          Determines if a particular position on the DrawingCanvas is contained within the object.
 DrawingCanvas getCanvas()
          Determine which (if any) DrawingCanvas this object is positioned on
 java.awt.Color getColor()
          Retrieves the color of the object.
 void hide()
          Temporarily hides an object on a DrawingCanvas from view.
 boolean isHidden()
          Determine whether an object is currently visible on its canvas
 void move(double dx, double dy)
          Moves the object within the canvas in the x and y direction by the amounts specified as 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

hide

public void hide()
Temporarily hides an object on a DrawingCanvas from view. This method should only be used if the object may later be made visible again using the show() method. If the goal is to remove an object from the display permanently, the removeFromCanvas() method should be used instead.


show

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


addToCanvas

public void addToCanvas(DrawingCanvas c)
Places an existing object on a specified DrawingCanvas. This method will fail if the object is already on a canvas. Therefore, to move an object from one canvas to another one must use removeFromCanvas() followed by addToCanvas. This method can also be invoked to place a Drawable object on a DrawingCanvas after the object is loaded from a file or other stream.

Parameters:
c - the canvas on which the object should 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, use hide() instead.


getCanvas

public DrawingCanvas getCanvas()
Determine which (if any) DrawingCanvas this object is positioned on

Returns:
the DrawingCanvas holding this object or null if it the object is not currently associated with any canvas

isHidden

public boolean isHidden()
Determine whether an object is currently visible on its canvas

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 by the amounts specified as 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.

Returns:
the object's color.

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 particular position on the DrawingCanvas is contained within the object.

Parameters:
point - the position on the canvas.
Returns:
true if point is contained in the object, false otherwise.