net.pacbell.jfai.toh.ui
Class DiskView

java.lang.Object
  extended by net.pacbell.jfai.toh.ui.DiskView
All Implemented Interfaces:
Observer

public class DiskView
extends Object
implements Observer

Visualizes a disk of the Tower Of Hanoi puzzle.


Constructor Summary
DiskView(Disk aModel, Point3f position, int numberOfDisks, BaseView aBaseView)
          Create a new instance given a Disk as the model, the position (relative to the path that leads to the instance), the number of disks for the puzzle, and the base view.
 
Method Summary
 void disappear()
          Removes the receiver's visual from the scene.
 BaseView getBaseView()
          Gets the base view.
 BranchGroup getGroup()
          Gets the branch group.
static float getHeight()
          Gets the absolute height.
 Disk getModel()
          Gets the Model.
 Point3f getPosition()
          Answers the center point of the disk.
 float getRadius()
          Gets the radius.
 Point3f modelPosition()
          Answer the position where the receiver should be based on where its model is.
static void setHeight(float newHeight)
          Sets the absolute height.
 void setPosition(Point3f newPosition)
          Sets the center point of the disk.
 void update(Observable o, Object arg)
          The model has changed and notifies the receiver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiskView

public DiskView(Disk aModel,
                Point3f position,
                int numberOfDisks,
                BaseView aBaseView)
Create a new instance given a Disk as the model, the position (relative to the path that leads to the instance), the number of disks for the puzzle, and the base view.

Parameters:
aModel - a Disk
position - relative position
numberOfDisks - number of disks of the puzzle
aBaseView - the view of the Base
Method Detail

getHeight

public static final float getHeight()
Gets the absolute height.

Returns:
the absolute height

setHeight

public static final void setHeight(float newHeight)
Sets the absolute height.

Parameters:
newHeight - the absolute height

disappear

public void disappear()
Removes the receiver's visual from the scene. Removes the receiver from the model's observer list.


getBaseView

public BaseView getBaseView()
Gets the base view.

Returns:
the view of the Base

getGroup

public BranchGroup getGroup()
Gets the branch group.

Returns:
the BranchGroup

getModel

public Disk getModel()
Gets the Model.

Returns:
a Disk

getPosition

public Point3f getPosition()
Answers the center point of the disk.

Returns:
the absolute coordinates of the disk's center

getRadius

public float getRadius()
Gets the radius.

Returns:
the absolute radius

modelPosition

public Point3f modelPosition()
Answer the position where the receiver should be based on where its model is.

Returns:
The absolute coordinates of the disk's center point corresponding to the model's position.

setPosition

public void setPosition(Point3f newPosition)
Sets the center point of the disk.

Parameters:
newPosition - the absolute coordinates of the disk's center

update

public void update(Observable o,
                   Object arg)
The model has changed and notifies the receiver. The first argument is a Disk. The change involved changing the position of the disk by moving it between pins. The second argument is ignored. The change of position is animated.

Specified by:
update in interface Observer
Parameters:
o - a Disk that changed its position
arg - ignored