sm
Class StateMachine.State

java.lang.Object
  extended bysm.StateMachine.State
Enclosing class:
StateMachine

public abstract class StateMachine.State
extends java.lang.Object

A state of a state machine.

This is an inner class of StateMachine and is meant to be used as follows:

 	StateMachine sm = new StateMachine ("sm") {
 		...
 		public State myState = new State() {
  	 		... declare transitions ...
 		}
 		...
 	}
 
The string name of the state, which is used to specify output states in transitions, will be the name of the field ("myState" in this example). For this to work, the field must be declared public.

Author:
Caroline Appert
See Also:
StateMachine

Nested Class Summary
 class StateMachine.State.Click
          A transition triggered by a mouse clicked event anywhere in the canvas.
 class StateMachine.State.ClickOnShape
          A transition triggered by a mouse button clicked on an SMShape.
 class StateMachine.State.ClickOnTag
          A transition triggered by a mouse clicked event on an SMShape with a given tag.
 class StateMachine.State.Drag
          A transition triggered by a mouse moved event with a button pressed anywhere in the canvas.
 class StateMachine.State.DragOnShape
          A transition triggered by a mouse move event on an SMShape with a mouse button down.
 class StateMachine.State.DragOnTag
          A transition triggered by a mouse moved event with a button pressed on an SMShape with a given tag.
 class StateMachine.State.EnterOnShape
          A transition triggered with no modifier on a SMShape.
 class StateMachine.State.EnterOnTag
          A transition triggered when the cursor enters in an SMShape with a given tag.
 class StateMachine.State.Event
          A transition triggered in the canvas.
 class StateMachine.State.EventOnPosition
          A transition triggered on a location in the canvas.
 class StateMachine.State.EventOnShape
          A transition triggered on a SMShape in the canvas.
 class StateMachine.State.EventOnTag
          A transition triggered on a tagged shape in the canvas.
 class StateMachine.State.KeyPress
          A transition triggered by a key pressed event.
 class StateMachine.State.KeyRelease
          A transition triggered by a key released event.
 class StateMachine.State.KeyTransition
          A transition triggered by a key event.
 class StateMachine.State.KeyType
          A transition triggered by a key typed event.
 class StateMachine.State.LeaveOnShape
          A transition triggered with no modifier on a SMShape.
 class StateMachine.State.LeaveOnTag
          A transition triggered when the cursor leaves a SMShape with a given tag.
 class StateMachine.State.MouseOnPosition
          A transition triggered by a mouse event on a location in the canvas.
 class StateMachine.State.MouseOnShape
          A transition triggered by a mouse event on a SMShape in the canvas.
 class StateMachine.State.MouseOnTag
          A transition triggered by a mouse event on a tagged shape in the canvas.
 class StateMachine.State.Move
          A transition triggered by a mouse moved event with no button pressed anywhere in the canvas.
 class StateMachine.State.MoveOnShape
          A transition triggered by a mouse move event on an SMShape with no mouse button down.
 class StateMachine.State.MoveOnTag
          A transition triggered by a mouse moved event with no button pressed on an SMShape with a given tag.
 class StateMachine.State.Press
          A transition triggered by a mouse pressed event anywhere in the canvas.
 class StateMachine.State.PressOnShape
          A transition triggered by a mouse button pressed on an SMShape.
 class StateMachine.State.PressOnTag
          A transition triggered by a mouse pressed event on an SMShape with a given tag.
 class StateMachine.State.Release
          A transition triggered by a mouse released event anywhere in the canvas.
 class StateMachine.State.ReleaseOnShape
          A transition triggered by a mouse button released on an SMShape.
 class StateMachine.State.ReleaseOnTag
          A transition triggered by a mouse released event on an SMShape with a given tag.
 class StateMachine.State.TimeOut
          A transition triggered by a timer.
 class StateMachine.State.Transition
          A transition of a state machine.
 
Field Summary
static int ALT
          Specifies that the ALT keyboard modifier must be pressed.
static int ALT_CONTROL
          Specifies that the ALT and CONTROL keyboard modifiers must be pressed.
static int ALT_CONTROL_SHIFT
          Specifies that the ALT, CONTROL and SHIFT keyboard modifiers must be pressed.
static int ALT_SHIFT
          Specifies that the ALT and SHIFT keyboard modifiers must be pressed.
static int ANYMODIFIER
          Specifies that any keyboard modifiers can be pressed.
static int BUTTON1
          Specifies that the mouse must have the button 1 pressed.
static int BUTTON2
          Specify that the mouse must have the button 2 pressed.
static int BUTTON3
          Specifies that the mouse must have the button 3 pressed.
static int CONTROL
          Specifies that the CONTROL keyboard modifier must be pressed.
static int CONTROL_SHIFT
          Specifies that the CONTROL and SHIFT keyboard modifiers must be pressed.
static int NOBUTTON
          Specifies that the mouse must have all buttons released.
static int NOMODIFIER
          Specifies that no keyboard modifiers must be pressed.
static int SHIFT
          Specifies that the SHIFT keyboard modifier must be pressed.
 
Constructor Summary
StateMachine.State()
          Builds a new state.
StateMachine.State(java.lang.String n)
          Builds a new state with a given name.
 
Method Summary
 void enter()
          The method called when the parent state machine enters this state.
 java.lang.String getName()
           
 java.util.Hashtable getTransitions()
           
 void leave()
          The method called when the parent state machine leaves this state.
 java.lang.String oldToString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOBUTTON

public static final int NOBUTTON
Specifies that the mouse must have all buttons released.

See Also:
Constant Field Values

BUTTON1

public static final int BUTTON1
Specifies that the mouse must have the button 1 pressed.

See Also:
Constant Field Values

BUTTON2

public static final int BUTTON2
Specify that the mouse must have the button 2 pressed.

See Also:
Constant Field Values

BUTTON3

public static final int BUTTON3
Specifies that the mouse must have the button 3 pressed.

See Also:
Constant Field Values

NOMODIFIER

public static final int NOMODIFIER
Specifies that no keyboard modifiers must be pressed.

See Also:
Constant Field Values

SHIFT

public static final int SHIFT
Specifies that the SHIFT keyboard modifier must be pressed.

See Also:
Constant Field Values

CONTROL

public static final int CONTROL
Specifies that the CONTROL keyboard modifier must be pressed.

See Also:
Constant Field Values

ALT

public static final int ALT
Specifies that the ALT keyboard modifier must be pressed.

See Also:
Constant Field Values

CONTROL_SHIFT

public static final int CONTROL_SHIFT
Specifies that the CONTROL and SHIFT keyboard modifiers must be pressed.

See Also:
Constant Field Values

ALT_SHIFT

public static final int ALT_SHIFT
Specifies that the ALT and SHIFT keyboard modifiers must be pressed.

See Also:
Constant Field Values

ALT_CONTROL

public static final int ALT_CONTROL
Specifies that the ALT and CONTROL keyboard modifiers must be pressed.

See Also:
Constant Field Values

ALT_CONTROL_SHIFT

public static final int ALT_CONTROL_SHIFT
Specifies that the ALT, CONTROL and SHIFT keyboard modifiers must be pressed.

See Also:
Constant Field Values

ANYMODIFIER

public static final int ANYMODIFIER
Specifies that any keyboard modifiers can be pressed.

See Also:
Constant Field Values
Constructor Detail

StateMachine.State

public StateMachine.State()
Builds a new state. The string name of the state, which is used to specify output states in transitions, will be the name of the field this object is assigned to in the parent state machine. For this to work, the field must be declared public. The first state in a state machine is its initial state, i.e. the current state when the machine is first created and when it is reset.


StateMachine.State

public StateMachine.State(java.lang.String n)
Builds a new state with a given name. THe names of the states must be unique within a state machine. The first state in a state machine is its initial state, i.e. the current state when the machine is first created and when it is reset.

Parameters:
n - The string name of the state, which is used to specify destination state in transitions.
Method Detail

getName

public java.lang.String getName()

oldToString

public java.lang.String oldToString()

getTransitions

public java.util.Hashtable getTransitions()

enter

public void enter()
The method called when the parent state machine enters this state. This method does nothing. It can be redefined in derived classes to specify what to do when this state becomes active. This is done as follows when using an anoynous class:
 	State s = new State () {
 		public void enter () { ... do something ...}
 		...
 	}
 


leave

public void leave()
The method called when the parent state machine leaves this state. This method does nothing. It can be redefined in derived classes to specify what to do when this state becomes active. This is done as follows when using an anoynous class:
 	State s = new State () {
 		public void leave () { ... do something ...}
 		...
 	}