fr.lri.swingstates.sm.transitions
Class EventOnPosition

java.lang.Object
  extended by fr.lri.swingstates.sm.Transition
      extended by fr.lri.swingstates.sm.transitions.Event
          extended by fr.lri.swingstates.sm.transitions.EventOnPosition
Direct Known Subclasses:
CStateMachine.EventOnShape, JStateMachine.EventOnComponent, MouseOnPosition

public class EventOnPosition
extends Event

A transition triggered on a location. OnPosition transitions allow developpers to retrieve the location where this transition has been triggered:

        Transition tshape = new EventOnPosition (BUTTON1) {
                public void action() {
                        System.out.println("The transition has been triggered at "+getPoint());
                }
        }
        

Author:
Caroline Appert

Constructor Summary
EventOnPosition(java.lang.Class eventClass)
          Builds a transition on a position with no modifier that can be triggered by any virtual events whose type is a subclass of eventClass.
EventOnPosition(java.lang.Class eventClass, java.lang.String outState)
          Builds a transition on a position with no modifier that can be triggered by any virtual events whose type is a subclass of eventClass.
EventOnPosition(java.lang.String keyEvent)
          Builds a transition on a position with no modifier that loops on the current state.
EventOnPosition(java.lang.String keyEvent, java.lang.String outState)
          Builds a transition on a position with no modifier.
 
Method Summary
 java.awt.geom.Point2D getPoint()
          Returns the location at which this transition has occured.
 boolean matches(java.util.EventObject eventObject)
          Tests if an event can trigger that transition.
 java.lang.String toString()
          
 
Methods inherited from class fr.lri.swingstates.sm.Transition
action, getEvent, getInputState, getOutputState, guard, oldToString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EventOnPosition

public EventOnPosition(java.lang.String keyEvent,
                       java.lang.String outState)
Builds a transition on a position with no modifier.

Parameters:
keyEvent - The string describing the events for which this transition must be triggered: "Down", "Move", "Drag", "Release", "Click"
outState - The name of the output state

EventOnPosition

public EventOnPosition(java.lang.String keyEvent)
Builds a transition on a position with no modifier that loops on the current state.

Parameters:
keyEvent - The string describing the events for which this transition must be triggered: "Down", "Move", "Drag", "Release", "Click"

EventOnPosition

public EventOnPosition(java.lang.Class eventClass,
                       java.lang.String outState)
Builds a transition on a position with no modifier that can be triggered by any virtual events whose type is a subclass of eventClass.

Parameters:
eventClass - The class of events
outState - The name of the output state

EventOnPosition

public EventOnPosition(java.lang.Class eventClass)
Builds a transition on a position with no modifier that can be triggered by any virtual events whose type is a subclass of eventClass.

Parameters:
eventClass - The class of events
Method Detail

getPoint

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

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

toString

public java.lang.String toString()

Overrides:
toString in class Event

matches

public boolean matches(java.util.EventObject eventObject)
Tests if an event can trigger that transition.

Overrides:
matches in class Event
Parameters:
eventObject - The event to test
Returns:
True if the eventObject can trigger this transition.