sm
Class StateMachine.State.Event

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

public class StateMachine.State.Event
extends StateMachine.State.Transition

A transition triggered in the canvas. The Event class can be directly used or extended to define specific event. The above example shows how a state machine, sm1, can receive "longPress" events provided by another state machine, sm2.

 StateMachine sm1, sm2;
 ...
 sm1 = new StateMachine("sm1", c) {

			public State start = new State("start") {
				public Transition event = new Event("longPress") {
					public void action() {
						System.out.println("a long press event");
				}
	        };
		};
 };

 sm2 = new StateMachine("sm2", c) {
 	
 	public State start = new State("start") {
		public Transition press = new Press(BUTTON1, ">> wait") {
			public void action() {
				armTimer(1000);
			}
		};
	};
	
	public State wait = new State("wait") {
		public Transition release = new Release(BUTTON1, ">> start") {
			public void action() {
				disarmTimer();
			}
		};
		
		public Transition longPress = new TimeOut(">> start") {
			public void action() {
				sm1.processEvent(new SMVirtualEvent("longPress"));
			}
		};
	};
 };

 

Author:
Caroline Appert

Constructor Summary
StateMachine.State.Event(java.lang.String e)
          Constructs a transition on a position with no modifier that loops on the current state.
StateMachine.State.Event(java.lang.String e, int m)
          Constructs a transition.
StateMachine.State.Event(java.lang.String e, int m, java.lang.String a)
          Constructs a transition.
StateMachine.State.Event(java.lang.String e, java.lang.String a)
          Constructs a transition with no modifier.
 
Method Summary
 java.lang.String hashKey()
          Returns the hashkey of this transition.
 
Methods inherited from class sm.StateMachine.State.Transition
action, getModifier, getOutputStateName, getVirtualEvent, guard, oldToString, setVirtualEvent, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StateMachine.State.Event

public StateMachine.State.Event(java.lang.String e,
                                int m,
                                java.lang.String a)
Constructs a transition.

Parameters:
e - The string describing the events for which this transition must be triggered: "Down", "Motion", "Move", "Up", "Click" or "Gesture"*
m - The modifier: NOMODIFIER, CONTROL, ALT, SHIFT, ALT_CONTROL, CONTROL_SHIFT, ALT_SHIFT or ALT_CONTROL_SHIFT
a - The name of the output state

StateMachine.State.Event

public StateMachine.State.Event(java.lang.String e,
                                int m)
Constructs a transition.

Parameters:
e - The string describing the events for which this transition must be triggered: "Down", "Motion", "Move", "Up", "Click" or "Gesture"*
m - The modifier: NOMODIFIER, CONTROL, ALT, SHIFT, ALT_CONTROL, CONTROL_SHIFT, ALT_SHIFT or ALT_CONTROL_SHIFT

StateMachine.State.Event

public StateMachine.State.Event(java.lang.String e,
                                java.lang.String a)
Constructs a transition with no modifier.

Parameters:
e - The string describing the events for which this transition must be triggered: "Down", "Motion", "Move", "Up", "Click" or "Gesture"*
a - The name of the output state

StateMachine.State.Event

public StateMachine.State.Event(java.lang.String e)
Constructs a transition on a position with no modifier that loops on the current state.

Parameters:
e - The string describing the events for which this transition must be triggered: "Down", "Motion", "Move", "Up", "Click" or "Gesture"*
Method Detail

hashKey

public java.lang.String hashKey()
Description copied from class: StateMachine.State.Transition
Returns the hashkey of this transition. Used for recording the transition in the state's hashtable.

Overrides:
hashKey in class StateMachine.State.Transition
Returns:
Returns the hashkey of this transition.