net.pacbell.jfai.toh.ui
Class TowerOfHanoiEditor

java.lang.Object
  extended by net.pacbell.jfai.toh.ui.TowerOfHanoiEditor
All Implemented Interfaces:
IChangeStatus

public class TowerOfHanoiEditor
extends Object
implements IChangeStatus

Provides apply/cancel editor functions for the bound properties of the Solver model.

Author:
Jürgen Failenschmid

Field Summary
(package private) static Log LOG
          The trace log.
 
Constructor Summary
TowerOfHanoiEditor(TowerOfHanoiView aView)
          Creates an instance for the given view.
 
Method Summary
 void applyChanges()
          Commits all changes that have been made to buffered values.
 void cancelChanges()
          Cancels all changes that have been made to buffered values.
protected  CanvasPanel getCanvasPanel()
          Gets the panel with the drawing canvas.
protected  ControlPanel getControlPanel()
          Gets the panel with the controls.
protected  Solver getModel()
          Gets the model.
 int getNumberOfDisks()
          Answers the number of disks.
 BufferedValue getNumberOfDisksModel()
          Answers a buffered value for the number of disks for the puzzle.
 Pin getSourcePin()
          Answers the source pin.
 BufferedValue getSourcePinModel()
          Answers a buffered value for the source pin.
protected  StatusPanel getStatusPanel()
          Gets the panel with the status information.
 Pin getTargetPin()
          Answers the target pin.
 BufferedValue getTargetPinModel()
          Answers a buffered value for the target pin.
protected  TowerOfHanoiView getView()
          Gets the view.
 boolean isChanged()
          Checks for pending configuration changes.
 void setModel(Solver newModel)
          Hooks the receiver up to the bound properties of the new model.
protected  void setNumberOfDisks(int numDisks)
          The model's number of disks has changed.
protected  void setSourcePin(Pin source)
          The model's source pin has changed.
protected  void setTargetPin(Pin target)
          The model's target pin has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

static final Log LOG
The trace log.

Constructor Detail

TowerOfHanoiEditor

public TowerOfHanoiEditor(TowerOfHanoiView aView)
Creates an instance for the given view.

Parameters:
aView - the puzzle's view
Method Detail

applyChanges

public void applyChanges()
Commits all changes that have been made to buffered values.

This may be called outside of the event dispatch thread.


cancelChanges

public void cancelChanges()
Cancels all changes that have been made to buffered values.

Assumes that this method is called in the event dispatch thread, e.g. when a cancel button was pressed.


getNumberOfDisks

public int getNumberOfDisks()
Answers the number of disks.

Returns:
the number of disks of the puzzle

getNumberOfDisksModel

public BufferedValue getNumberOfDisksModel()
Answers a buffered value for the number of disks for the puzzle.

Returns:
a BufferedValue

getSourcePin

public Pin getSourcePin()
Answers the source pin.

Returns:
the source pin

getSourcePinModel

public BufferedValue getSourcePinModel()
Answers a buffered value for the source pin.

Returns:
a BufferedValue

getTargetPin

public Pin getTargetPin()
Answers the target pin.

Returns:
the target pin

getTargetPinModel

public BufferedValue getTargetPinModel()
Answers a buffered value for the target pin.

Returns:
a BufferedValue

isChanged

public boolean isChanged()
Checks for pending configuration changes.

Specified by:
isChanged in interface IChangeStatus
Returns:
Are there any pending changes to the puzzle configuration?
See Also:
IChangeStatus.isChanged()

setModel

public void setModel(Solver newModel)
Hooks the receiver up to the bound properties of the new model.

Parameters:
newModel - the model

getCanvasPanel

protected CanvasPanel getCanvasPanel()
Gets the panel with the drawing canvas.

Returns:
the panel

getControlPanel

protected ControlPanel getControlPanel()
Gets the panel with the controls.

Returns:
the panel

getModel

protected Solver getModel()
Gets the model.

Returns:
the model

getStatusPanel

protected StatusPanel getStatusPanel()
Gets the panel with the status information.

Returns:
the panel

getView

protected TowerOfHanoiView getView()
Gets the view.

Returns:
the puzzle's view

setNumberOfDisks

protected void setNumberOfDisks(int numDisks)
The model's number of disks has changed. Removes all DiskViews from the scene and creates new ones at the source pin.

Note: the implementation assumes that the object path of each DiskView has the same parent, the receiver's sceneTransformGroup.

Parameters:
numDisks - the number of disks of the puzzle

setSourcePin

protected void setSourcePin(Pin source)
The model's source pin has changed. Repositions all DiskViews in the scene to the source pin.

Parameters:
source - the source pin

setTargetPin

protected void setTargetPin(Pin target)
The model's target pin has changed. Makes sure that all disks are visible at the source pin: some of them might have moved before the animation was paused and only the target pin might have been changed.

Parameters:
target - the target pin