fr.lri.swingstates.canvas
Class CStateMachine.MouseOnShape

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
                  extended by fr.lri.swingstates.canvas.CStateMachine.MouseOnShape
Direct Known Subclasses:
CStateMachine.ClickOnShape, CStateMachine.DragOnShape, CStateMachine.EnterOnShape, CStateMachine.LeaveOnShape, CStateMachine.MoveOnShape, CStateMachine.PressOnShape, CStateMachine.ReleaseOnShape, CStateMachine.WheelOnShape
Enclosing class:
CStateMachine

public class CStateMachine.MouseOnShape
extends CStateMachine.EventOnShape

A transition triggered by a mouse event on a CShape in the canvas. MouseOnShape is the super class of

For instance, the following code allows 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 PressOnShape (BUTTON1) { ... }; // captures button presses on shapes
                Transition tbackground = new Press (BUTTON1) { ... };   // captures button presses on background
        }
 

Author:
Caroline Appert

Constructor Summary
CStateMachine.MouseOnShape()
          Builds a mouse transition with any modifier that loops on the current state.
CStateMachine.MouseOnShape(int button)
          Builds a mouse transition with any modifier that loops on the current state.
CStateMachine.MouseOnShape(int button, int modifier)
          Builds a mouse transition that loops on the current state.
CStateMachine.MouseOnShape(int button, int modifier, java.lang.String outState)
          Builds a mouse transition.
CStateMachine.MouseOnShape(int button, java.lang.String outState)
          Builds a mouse transition with any modifier.
CStateMachine.MouseOnShape(java.lang.String outState)
          Builds a mouse transition with any modifier.
 
Method Summary
 int getButton()
          Returns the button of the mouse event that fires this transition.
 java.awt.event.InputEvent getInputEvent()
           
 int getModifier()
          Returns the modifier of the event that fires this transition.
 java.awt.event.MouseEvent getMouseEvent()
           
 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.
 java.lang.String toString()
          
 
Methods inherited from class fr.lri.swingstates.canvas.CStateMachine.EventOnShape
matches
 
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.MouseOnShape

public CStateMachine.MouseOnShape(java.lang.String outState)
Builds a mouse transition with any modifier.

Parameters:
outState - The name of the output state

CStateMachine.MouseOnShape

public CStateMachine.MouseOnShape()
Builds a mouse transition with any modifier that loops on the current state.


CStateMachine.MouseOnShape

public CStateMachine.MouseOnShape(int button,
                                  int modifier,
                                  java.lang.String outState)
Builds a mouse transition.

Parameters:
button - The button of the mouse event: NOBUTTON, BUTTON1, BUTTON2 or BUTTON3
modifier - The modifier: NOMODIFIER, CONTROL, ALT, SHIFT, ALT_CONTROL, CONTROL_SHIFT, ALT_SHIFT or ALT_CONTROL_SHIFT
outState - The name of the output state

CStateMachine.MouseOnShape

public CStateMachine.MouseOnShape(int button,
                                  int modifier)
Builds a mouse transition that loops on the current state.

Parameters:
button - The button of the mouse event: NOBUTTON, BUTTON1, BUTTON2 or BUTTON3
modifier - The modifier: NOMODIFIER, CONTROL, ALT, SHIFT, ALT_CONTROL, CONTROL_SHIFT, ALT_SHIFT or ALT_CONTROL_SHIFT

CStateMachine.MouseOnShape

public CStateMachine.MouseOnShape(int button,
                                  java.lang.String outState)
Builds a mouse transition with any modifier.

Parameters:
button - The button of the mouse event: NOBUTTON, BUTTON1, BUTTON2 or BUTTON3
outState - The name of the output state

CStateMachine.MouseOnShape

public CStateMachine.MouseOnShape(int button)
Builds a mouse transition with any modifier that loops on the current state.

Parameters:
button - The button of the mouse event: NOBUTTON, BUTTON1, BUTTON2 or BUTTON3
Method Detail

getButton

public int getButton()
Returns the button of the mouse event that fires this transition.

Returns:
the button of the mouse event that fires this transition (NOBUTTON, BUTTON1, BUTTON2 or BUTTON3).

getModifier

public int getModifier()
Returns the modifier of the event that fires this transition.

Returns:
the modifier of the event that fires this transition (NOMODIFIER, CONTROL, ALT, SHIFT, ALT_CONTROL, CONTROL_SHIFT, ALT_SHIFT or ALT_CONTROL_SHIFT).

getInputEvent

public java.awt.event.InputEvent getInputEvent()
Returns:
the input event that has just fired this transition.

getMouseEvent

public java.awt.event.MouseEvent getMouseEvent()
Returns:
the awt mouse event that fires this transition.

getPoint

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

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

getShape

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

Overrides:
getShape in class CStateMachine.EventOnShape
Returns:
the CShape on which the event firing this transition has occured.

toString

public java.lang.String toString()

Overrides:
toString in class CStateMachine.EventOnShape