ciips.animation
Class Drawable

java.lang.Object
  extended byciips.animation.Drawable
All Implemented Interfaces:
DrawingObj
Direct Known Subclasses:
ComBox, IntMatrix, Legend, ShadowLabel

public abstract class Drawable
extends java.lang.Object
implements DrawingObj

Interface for the drawing object to be drawn in the drawing panel.

Any graphical objects to be displayed on the DrawingPanel should implement this interface. All the abstract methods of the interface must be defined in the object class defining the graphical object.

For example, if Box is a class which implements DrawingObj, i.e. the class declaration of Box starts with the following line:

      class Box implements DrawingObj {
        ...
 
Then any instance of class Box can be added to the drawing canvas as follows:
      Box box = new Box(...);
      drawingPanel.addDrawingObj(box);
      box.move(x, y);
      drawingPanel.redraw();
 
The first line declares an instance of class Box called box. The next line uses the method addDrawingObj to add box into the canvas drawingPanel, which is an instance of the object class DrawingPanel.

The move method of the drawing object (which must be specified) is then called to move the corresponding object to position (x, y). Finally, the redraw() method of DrawingPanel class is called to refresh the panel and delay for the object to be visible.

See Also:
DrawingPanel, DrawingPanel.addDrawingObj(ciips.animation.DrawingObj), DrawingPanel.redraw()

Field Summary
protected  java.awt.Color colour
           
static int DEFAULT_START
           
protected  boolean grey
           
protected  boolean highlight
           
protected  java.lang.String label
           
protected  int x
           
protected  int y
           
 
Constructor Summary
Drawable()
           
 
Method Summary
abstract  void draw(java.awt.Graphics g)
          Paint method of the drawing object.
 java.awt.Color getCurrentColour()
          Return the colour to be used to draw this object based on it's current status.
 int getX()
          Returns the x coordinate of the drawing object's reference point.
 int getY()
          Returns the y coordinate of the drawing object's reference point.
 void move(int x, int y)
          This method repositions the drawing object to the new location specified by the paramters.
 void setGrey(boolean on)
          Set the grey attribute
 void setHighlight(boolean on)
          Set the highlight attribute
 void setText(java.lang.String t)
          Set an object's label
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

protected int x

y

protected int y

highlight

protected boolean highlight

grey

protected boolean grey

colour

protected java.awt.Color colour

label

protected java.lang.String label

DEFAULT_START

public static final int DEFAULT_START
See Also:
Constant Field Values
Constructor Detail

Drawable

public Drawable()
Method Detail

draw

public abstract void draw(java.awt.Graphics g)
Description copied from interface: DrawingObj
Paint method of the drawing object.

Specified by:
draw in interface DrawingObj
Parameters:
g - A reference to the graphical context.

move

public void move(int x,
                 int y)
This method repositions the drawing object to the new location specified by the paramters.

Specified by:
move in interface DrawingObj
Parameters:
x - The x coordinate of the drawing object's new position.
y - The y coordinate of the drawing object's new position.

getX

public int getX()
Returns the x coordinate of the drawing object's reference point.

Specified by:
getX in interface DrawingObj
Returns:
The x coordinate of the drawing object's reference point.

getY

public int getY()
Returns the y coordinate of the drawing object's reference point.

Specified by:
getY in interface DrawingObj
Returns:
The y coordinate of the drawing object's reference point.

setHighlight

public void setHighlight(boolean on)
Set the highlight attribute

Specified by:
setHighlight in interface DrawingObj

setGrey

public void setGrey(boolean on)
Set the grey attribute

Specified by:
setGrey in interface DrawingObj

getCurrentColour

public java.awt.Color getCurrentColour()
Return the colour to be used to draw this object based on it's current status. Note that highlight takes precedence over grey


setText

public void setText(java.lang.String t)
Set an object's label