fr.lri.swingstates.sm
Class JStateMachine

java.lang.Object
  extended by fr.lri.swingstates.sm.StateMachine
      extended by fr.lri.swingstates.sm.BasicInputStateMachine
          extended by fr.lri.swingstates.sm.JStateMachine
All Implemented Interfaces:
StateMachineListener, java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.util.EventListener
Direct Known Subclasses:
PressDragReleaseStateMachine

public class JStateMachine
extends BasicInputStateMachine
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener

A state machine to monitor events with one or more Component.

The complete list of event types, i.e. classes of transitions, of a JStateMachine is:

Author:
Caroline Appert
See Also:
BasicInputStateMachine

Nested Class Summary
 class JStateMachine.ClickOnComponent
          A transition triggered by a mouse button clicked on a JComponent.
 class JStateMachine.ClickOnTag
          A transition triggered by a mouse clicked event on a component with a given tag.
 class JStateMachine.DragOnComponent
          A transition triggered by a mouse move event on a component with a mouse button down.
 class JStateMachine.DragOnTag
          A transition triggered by a mouse moved event with a button pressed on a component with a given tag.
 class JStateMachine.EnterOnComponent
          A Transition triggered when the mouse enters in a JComponent.
 class JStateMachine.EnterOnTag
          A transition triggered when the cursor enters in a component with a given tag.
 class JStateMachine.EventOnComponent
          A transition triggered on a JComponent.
 class JStateMachine.EventOnTag
          A transition triggered on a tagged component.
 class JStateMachine.LeaveOnComponent
          A transition triggered with no modifier on a component.
 class JStateMachine.LeaveOnTag
          A transition triggered when the cursor leaves a component with a given tag.
 class JStateMachine.MouseOnComponent
          A transition triggered by a mouse event on a component.
 class JStateMachine.MouseOnTag
          A transition triggered by a mouse event on a tagged component.
 class JStateMachine.MoveOnComponent
          A transition triggered by a mouse move event on a component with no mouse button down.
 class JStateMachine.MoveOnTag
          A transition triggered by a mouse moved event with no button pressed on a component with a given tag.
 class JStateMachine.PressOnComponent
          A transition triggered by a mouse button pressed on a component.
 class JStateMachine.PressOnTag
          A transition triggered by a mouse pressed event on a component with a given tag.
 class JStateMachine.ReleaseOnComponent
          A transition triggered by a mouse button released on a component.
 class JStateMachine.ReleaseOnTag
          A transition triggered by a mouse released event on a component with a given tag.
 class JStateMachine.WheelOnComponent
          A transition triggered by a mouse wheel event on a component with no mouse button down.
 class JStateMachine.WheelOnTag
          A transition triggered by a mouse wheel event with no button pressed on a component with a given tag.
 
Field Summary
 
Fields inherited from class fr.lri.swingstates.sm.BasicInputStateMachine
ALT, ALT_CONTROL, ALT_CONTROL_SHIFT, ALT_SHIFT, ANYBUTTON, ANYMODIFIER, BUTTON1, BUTTON2, BUTTON3, CONTROL, CONTROL_SHIFT, NOBUTTON, NOMODIFIER, SHIFT
 
Fields inherited from class fr.lri.swingstates.sm.StateMachine
TIME_OUT
 
Constructor Summary
JStateMachine()
          Builds a JStateMachine.
 
Method Summary
 StateMachine attachTo(java.awt.Component c)
          Attaches a component to this state machine.
 StateMachine detachFrom(java.awt.Component c)
          Removes a component from the control of this state machine.
 java.util.LinkedList getControlledObjects()
           
 void keyPressed(java.awt.event.KeyEvent e)
          
 void keyReleased(java.awt.event.KeyEvent e)
          
 void keyTyped(java.awt.event.KeyEvent e)
          
 void mouseClicked(java.awt.event.MouseEvent e)
          
 void mouseDragged(java.awt.event.MouseEvent e)
          
 void mouseEntered(java.awt.event.MouseEvent e)
          
 void mouseExited(java.awt.event.MouseEvent e)
          
 void mouseMoved(java.awt.event.MouseEvent e)
          
 void mousePressed(java.awt.event.MouseEvent e)
          
 void mouseReleased(java.awt.event.MouseEvent e)
          
 
Methods inherited from class fr.lri.swingstates.sm.BasicInputStateMachine
addAsListenerOf, mouseWheelMoved, removeAsListenerOf
 
Methods inherited from class fr.lri.swingstates.sm.StateMachine
actionPerformed, addStateMachineListener, addStateMachineListener, armTimer, armTimer, consumes, disarmTimer, disarmTimer, doReset, doResume, doSuspend, eventOccured, fireEvent, fireEvent, getAllStates, getCurrentState, getInitialState, getState, hasConsumed, init, initStatesAndTransitions, isActive, processEvent, processEvent, removeStateMachineListener, removeStateMachineListener, reset, resume, setActive, suspend
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JStateMachine

public JStateMachine()
Builds a JStateMachine.

Method Detail

attachTo

public StateMachine attachTo(java.awt.Component c)
Attaches a component to this state machine. Events coming on this component and its children are catched by this state machine. If this component has a glasspane, events will still reach the underlying widgets in a JStateMachine (the glasspane must be set before calling this attachTo method).

Parameters:
c - The component to attach.
Returns:
This state machine.

detachFrom

public StateMachine detachFrom(java.awt.Component c)
Removes a component from the control of this state machine.

Parameters:
c - The component to detach.
Returns:
This state machine.

getControlledObjects

public java.util.LinkedList getControlledObjects()
Returns:
The Components monitored by this state machine as a linked list.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Overrides:
mouseClicked in class BasicInputStateMachine

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)

Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class BasicInputStateMachine

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class BasicInputStateMachine

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Overrides:
mouseEntered in class BasicInputStateMachine

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)

Specified by:
mouseExited in interface java.awt.event.MouseListener
Overrides:
mouseExited in class BasicInputStateMachine

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Overrides:
mouseDragged in class BasicInputStateMachine

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Overrides:
mouseMoved in class BasicInputStateMachine

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)

Specified by:
keyTyped in interface java.awt.event.KeyListener
Overrides:
keyTyped in class BasicInputStateMachine

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)

Specified by:
keyPressed in interface java.awt.event.KeyListener
Overrides:
keyPressed in class BasicInputStateMachine

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)

Specified by:
keyReleased in interface java.awt.event.KeyListener
Overrides:
keyReleased in class BasicInputStateMachine