objectdraw
Interface DrawableInterface

All Known Subinterfaces:
Drawable1DInterface, Drawable2DInterface, Resizable2DInterface
All Known Implementing Classes:
AngLine, Arc, Drawable, Drawable2D, FilledArc, FilledOval, FilledRect, FilledRoundedRect, FramedArc, FramedOval, FramedRect, FramedRoundedRect, Line, Oval, Rect, Rectangular, Resizable2D, RoundedRect, Text, VisibleImage

public interface DrawableInterface

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

Version:
1.1.1 released February 2005

Method Summary
abstract  void addToCanvas(DrawingCanvas c)
          Places an existing object on a specified DrawingCanvas.
abstract  boolean contains(Location point)
          Determines if a particular position on the DrawingCanvas is contained within the object.
abstract  DrawingCanvas getCanvas()
          Determine which (if any) DrawingCanvas this object is positioned on
abstract  Color getColor()
          Retrieves the color of the object.
abstract  void hide()
          Temporarily hides an object on a DrawingCanvas from view.
abstract  boolean isHidden()
          Determine whether an object is currently visible on its canvas
abstract  void move(double dx, double dy)
          Moves the object within the canvas in the x and y direction by the amounts specified as parameters.
abstract  void moveTo(double x, double y)
          Moves the object within the canvas to the x and y coordinates provided.
abstract  void moveTo(Location point)
          Moves the object within the canvas to the specified Location
abstract  void removeFromCanvas()
          Permanently removes the object from the canvas it is currently on.
abstract  void sendBackward()
          Sends the object backward.
abstract  void sendForward()
          Sends the object forward.
abstract  void sendToBack()
          Sends the object to the back.
abstract  void sendToFront()
          Sends the object to the front.
abstract  void setColor(Color c)
          Sets the color of the object.
abstract  void show()
          Shows the object if it has been hidden.
 

Method Detail

addToCanvas

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

contains

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.

getCanvas

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

getColor

Color getColor()
Retrieves the color of the object.

Returns:
the object's color.

hide

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.


isHidden

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

Returns:
true if the object is currently hidden.

move

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.

moveTo

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.

moveTo

void moveTo(Location point)
Moves the object within the canvas to the specified Location

Parameters:
point - the destination for moving the object.

removeFromCanvas

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.


sendBackward

void sendBackward()
Sends the object backward.


sendForward

void sendForward()
Sends the object forward.


sendToBack

void sendToBack()
Sends the object to the back.


sendToFront

void sendToFront()
Sends the object to the front.


setColor

void setColor(Color c)
Sets the color of the object.

Parameters:
c - the color.

show

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