fr.lri.swingstates.canvas
Class CStateMachine.EventOnShape

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
              extended by fr.lri.swingstates.canvas.CStateMachine.EventOnShape
Direct Known Subclasses:
CStateMachine.EventOnTag, CStateMachine.MouseOnShape
Enclosing class:
CStateMachine

public abstract class CStateMachine.EventOnShape
extends EventOnPosition

A transition triggered on a CShape in the canvas. OnShape transitions allow developpers to retrieve the shape in the canvas where this transition has been fired:

        Transition tshape = new EventOnShape ("anEvent") {
                public void action() {
                        // colors in red the shape on which the transition has been fired
                        getShape().setFillPaint(Color.RED);
                }
        }
        
 

Author:
Caroline Appert

Constructor Summary
CStateMachine.EventOnShape(java.lang.Class eventClass)
          Builds a transition on a CShape with no modifier that can be triggered by any virtual events whose type is a subclass of eventClass.
CStateMachine.EventOnShape(java.lang.Class eventClass, java.lang.String outState)
          Builds a transition on a CShape with no modifier that can be triggered by any virtual events whose type is a subclass of eventClass.
CStateMachine.EventOnShape(java.lang.String keyEvent)
          Builds a transition on a CShape with no modifier that loops on the current state.
CStateMachine.EventOnShape(java.lang.String keyEvent, java.lang.String outState)
          Builds a transition on a CShape with no modifier.
 
Method Summary
 java.awt.geom.Point2D getPoint()
          Returns the location at which this transition has occured.
 CShape getShape()
          Returns the CShape on which the event firing 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

CStateMachine.EventOnShape

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

Parameters:
keyEvent - The string describing the events for which this transition must be triggered

CStateMachine.EventOnShape

public CStateMachine.EventOnShape(java.lang.String keyEvent,
                                  java.lang.String outState)
Builds a transition on a CShape with no modifier.

Parameters:
keyEvent - The string describing the events for which this transition must be triggered
outState - The name of the output state

CStateMachine.EventOnShape

public CStateMachine.EventOnShape(java.lang.Class eventClass,
                                  java.lang.String outState)
Builds a transition on a CShape 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

CStateMachine.EventOnShape

public CStateMachine.EventOnShape(java.lang.Class eventClass)
Builds a transition on a CShape 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

getShape

public CShape getShape()
Returns the CShape on which the event firing this transition has occured.

Returns:
the CShape on which the event firing this transition has occured.

toString

public java.lang.String toString()

Overrides:
toString in class EventOnPosition

getPoint

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

Overrides:
getPoint in class EventOnPosition
Returns:
the location at which the mouse event firing this transition has occured.

matches

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

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