fr.lri.swingstates.canvas
Class CStateMachine.CElementEvent

java.lang.Object
  extended by fr.lri.swingstates.sm.Transition
      extended by fr.lri.swingstates.sm.transitions.Event
          extended by fr.lri.swingstates.canvas.CStateMachine.CElementEvent
Enclosing class:
CStateMachine

public class CStateMachine.CElementEvent
extends Event

A transition triggered by a CElement each time this CElement is modified. For example, one can want to track the potential collisions of a given shape ball with the left edge of the canvas.

        Transition tshape = CElementEvent(ball) {
                public boolean guard() {
                        return ((CShape)getCElement()).getMinX() < 0;
                }
                public void action() {
                        ... // do something
                }
        }
        
 

Author:
Caroline Appert

Constructor Summary
CStateMachine.CElementEvent(CElement cElement)
          Builds a transition that loops on the current state triggered by any changes on a CElement.
CStateMachine.CElementEvent(CElement cElement, java.lang.String outState)
          Builds a transition triggered by any changes on a CElement.
 
Method Summary
 CElement getCElement()
           
 VirtualCElementEvent getCElementEvent()
           
 boolean matches(java.util.EventObject eventObject)
          Tests if an event can trigger that transition.
 
Methods inherited from class fr.lri.swingstates.sm.transitions.Event
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.CElementEvent

public CStateMachine.CElementEvent(CElement cElement)
Builds a transition that loops on the current state triggered by any changes on a CElement.

Parameters:
cElement - The CElement to track.

CStateMachine.CElementEvent

public CStateMachine.CElementEvent(CElement cElement,
                                   java.lang.String outState)
Builds a transition triggered by any changes on a CElement.

Parameters:
cElement - The CElement to track.
outState - The name of the output state.
Method Detail

getCElement

public CElement getCElement()
Returns:
the CElement that has just triggered this animation.

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.

getCElementEvent

public VirtualCElementEvent getCElementEvent()
Returns:
the event that has just triggered this transition.