sm
Class StateMachine.State.EventOnPosition

java.lang.Object
  extended bysm.StateMachine.State.Transition
      extended bysm.StateMachine.State.EventOnPosition
Direct Known Subclasses:
StateMachine.State.EventOnShape, StateMachine.State.MouseOnPosition
Enclosing class:
StateMachine.State

public class StateMachine.State.EventOnPosition
extends StateMachine.State.Transition

A transition triggered on a location in the canvas. In order to specify a transition that fires only on the background of the canvas, where no shape is displayed, first specify an empty transition that fires on any shape, then a transition that fires anywhere on the canvas. For example:

 	public State s = new State () {
 		Transition tshape = new EventOnShape (BUTTON1);	// captures button presses on shapes
 		Transition tbackground = new EventOnPosition (BUTTON1) { ... }	// captures button presses on background
 	}
 
OnPosition transitions allow developpers to retrieve the location in the canvas where this transition has been triggered:
 	Transition tshape = new EventOnPosition (BUTTON1) {
 		public void action() {
 			// creates an ellipse at the location where the transition has been triggered
 			canvas.newEllipse(getPoint().x, getPoint().y, 20, 30);
 		}
 	}

Author:
Caroline Appert

Constructor Summary
StateMachine.State.EventOnPosition(java.lang.String e)
          Constructs a transition on a position with no modifier that loops on the current state.
StateMachine.State.EventOnPosition(java.lang.String e, int m)
          Constructs a transition on a position that loops on the current state.
StateMachine.State.EventOnPosition(java.lang.String e, int m, java.lang.String a)
          Constructs a transition on a position.
StateMachine.State.EventOnPosition(java.lang.String e, java.lang.String a)
          Constructs a transition on a position with no modifier.
 
Method Summary
 java.awt.event.InputEvent getInputEvent()
           
 java.awt.geom.Point2D getPoint()
          Returns the position at which this transition has occured.
 java.lang.String hashKey()
          Returns the hashkey of this transition.
 void setInputEvent(java.awt.event.InputEvent inputEvent)
           
 
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.EventOnPosition

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

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.EventOnPosition

public StateMachine.State.EventOnPosition(java.lang.String e,
                                          int m)
Constructs a transition on a position 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"*
m - The modifier: NOMODIFIER, CONTROL, ALT, SHIFT, ALT_CONTROL, CONTROL_SHIFT, ALT_SHIFT or ALT_CONTROL_SHIFT

StateMachine.State.EventOnPosition

public StateMachine.State.EventOnPosition(java.lang.String e,
                                          java.lang.String a)
Constructs a transition on a position 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.EventOnPosition

public StateMachine.State.EventOnPosition(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

getPoint

public java.awt.geom.Point2D getPoint()
Returns the position at which this transition has occured.

Returns:
Returns the position at which the mouse event firing this transition has occured.

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.

getInputEvent

public java.awt.event.InputEvent getInputEvent()

setInputEvent

public void setInputEvent(java.awt.event.InputEvent inputEvent)