easik.states
Class GetPathState

java.lang.Object
  extended by easik.states.EasikState
      extended by easik.states.GetPathState

public class GetPathState
extends EasikState

The GetPathState is a state which can be used to retrieve a single path from the user. It ensures that the only edges which are selectable are those which are attached to the previous edge.

Version:
2006-07-13 Kevin Green
Author:
Rob Fletcher 2005, Kevin Green 2006, Vera Ranieri 2006

Field Summary
private  boolean _finishState
          Stores whether the next state is the finish state
private  boolean _nextState
          Stores whether the next state is to add a new path
private  SketchPath _pathToReturn
          The path created from the edges chosen
private  java.util.Map _selectable
          Contains elements of the sketch that are selectable
private  java.util.Map _unselectable
          Contains elements of the sketch that are not selectable
 
Fields inherited from class easik.states.EasikState
_ourSketch
 
Constructor Summary
GetPathState(boolean next, boolean finish)
          Default Constructor
 
Method Summary
 void cancelClicked()
          If path collection has been cancelled, then pop off, and set the path to be null.
 void finishClicked()
          When finish is clicked, the stack is popped off after an array containing the path is created.
 void nextClicked()
          When next is clicked, pop off after preparing an array containing the edges in the path.
 void poppedOff()
          When the state gets popped, then it should tell the new top item what path it had collected before being popped.
 void pushedOn()
          When pushed on, the first thing done is clearing the selection and then disabling selection for all items except for edges.
private  void resetSelection()
          Set everything to be selectable
 void selectionUpdated()
          Update the selection so that the only selectable items will be those within reach of the existing edges.
 java.lang.String toString()
          State string identifier.
 
Methods inherited from class easik.states.EasikState
gotFocus, resetColors, setCancelButton, setFinishButton, setNextButton
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_selectable

private java.util.Map _selectable
Contains elements of the sketch that are selectable


_unselectable

private java.util.Map _unselectable
Contains elements of the sketch that are not selectable


_pathToReturn

private SketchPath _pathToReturn
The path created from the edges chosen


_nextState

private boolean _nextState
Stores whether the next state is to add a new path


_finishState

private boolean _finishState
Stores whether the next state is the finish state

Constructor Detail

GetPathState

public GetPathState(boolean next,
                    boolean finish)
Default Constructor

Parameters:
next - Boolean determining whether the user shoulbe be allowed to select next on this round. True if next could be selected, false otherwise.
finish - Boolean determining whether the user should be allowed to select finish on this round. True if finish could be selected, false otherwise.
Method Detail

pushedOn

public void pushedOn()
When pushed on, the first thing done is clearing the selection and then disabling selection for all items except for edges.

Specified by:
pushedOn in class EasikState

selectionUpdated

public void selectionUpdated()
Update the selection so that the only selectable items will be those within reach of the existing edges.

Overrides:
selectionUpdated in class EasikState

poppedOff

public void poppedOff()
When the state gets popped, then it should tell the new top item what path it had collected before being popped. Since this is called AFTER popping, it can use peek() to get the top item.

Specified by:
poppedOff in class EasikState

cancelClicked

public void cancelClicked()
If path collection has been cancelled, then pop off, and set the path to be null.

Overrides:
cancelClicked in class EasikState

nextClicked

public void nextClicked()
When next is clicked, pop off after preparing an array containing the edges in the path. Convert to the proper graph edge of the sketch.

Overrides:
nextClicked in class EasikState

finishClicked

public void finishClicked()
When finish is clicked, the stack is popped off after an array containing the path is created.

Overrides:
finishClicked in class EasikState

toString

public java.lang.String toString()
State string identifier.

Specified by:
toString in class EasikState
Returns:
String literal "Select a path"

resetSelection

private void resetSelection()
Set everything to be selectable