Packagecom.yworks.canvas.input
Classpublic class StateMachineInputMode
InheritanceStateMachineInputMode Inheritance AbstractConcurrentInputMode Inheritance AbstractInputMode Inheritance flash.events.EventDispatcher
Subclasses ClickInputMode, CreateEdgeInputMode, EdgeDragInputModeBase, HandleInputMode, MarqueeSelectionInputMode, MoveInputMode, MoveViewportInputMode, ResizeStripeInputMode

An IConcurrentInputMode implementation that uses a StateMachine to manage its state.

This instance does nothing and needs to be subclassed in order to be useful.



Public Properties
 PropertyDefined By
  canceledState : State
[read-only] Returns the canceled state of the state machine.
StateMachineInputMode
 Inheritedcanvas : CanvasComponent
[read-only] The canvas instance this mode is currently installed in or null
AbstractInputMode
 Inheritedcontroller : ConcurrencyController
Gets or injects the ConcurrencyController for this instance.
AbstractConcurrentInputMode
 Inheritedenabled : Boolean
Gets or sets the enabled state of this input mode.
AbstractConcurrentInputMode
 InheritedinputModeContext : IInputModeContext
[read-only] The context instance this mode is currently installed in or null if this instance is not installed.
AbstractInputMode
 Inheritedinstalled : Boolean
[read-only] Whether this mode is currently installed, i.e if a call to the canvas property will yield a non-null result.
AbstractInputMode
  lastMouseEvent : CanvasMouseEvent
[read-only] Returns the last mouse event.
StateMachineInputMode
 InheritedpreferredCursor : Cursor
Gets or sets the cursor this mode would like to have displayed in the CanvasComponent.
AbstractConcurrentInputMode
  startState : State
[read-only] Returns the start state of the state machine.
StateMachineInputMode
  stateMachine : StateMachine
[read-only] Gets the state machine.
StateMachineInputMode
  stoppedState : State
[read-only] Returns the stopped state of the state machine.
StateMachineInputMode
Protected Properties
 PropertyDefined By
  _lastEvent : Event
The last Event that has been delivered to this instance.
StateMachineInputMode
  _lastMouseEvent : CanvasMouseEvent
The last MouseEvent that has been delivered to this instance.
StateMachineInputMode
  stopEventRecognizer : Function
[read-only] An event recognizer for the state machine that is triggered if this mode has been stoppped.
StateMachineInputMode
Public Methods
 MethodDefined By
  
StateMachineInputMode(stateMachine:StateMachine = null, startState:State = null, canceledState:State = null, stoppedState:State = null)
Creates a new instance using the given state machine and states.
StateMachineInputMode
  
cancel():void
[override] Runs the machine using the cancel and reset events, releases the input mutex and returns.
StateMachineInputMode
 Inherited
dispose():void
Disposes this input mode.
AbstractInputMode
 Inherited
Installs this mode into the canvas of the given context.
AbstractInputMode
  
Runs the machine using a special reset event.
StateMachineInputMode
  
run(evt:Event):void
Tries to run the virtual machine using the pair of source and event argument to determine which transition to take.
StateMachineInputMode
  
stop():Boolean
[override] Runs the machine using a special stop event.
StateMachineInputMode
 Inherited
Uninstalls this mode from the canvas.
AbstractInputMode
Protected Methods
 MethodDefined By
 Inherited
canRequestMutex():Boolean
Determines whether this instance can request the InputMutex.
AbstractConcurrentInputMode
  
Factory method that creates a canceled State for the given machine.
StateMachineInputMode
  
Factory method that creates a start State for the given machine.
StateMachineInputMode
  
Factory method that creates the state machine.
StateMachineInputMode
  
Factory method that creates a stopped State for the given machine.
StateMachineInputMode
 Inherited
AbstractInputMode
 Inherited
AbstractInputMode
 Inherited
AbstractInputMode
 Inherited
AbstractInputMode
 Inherited
hasMutex():Boolean
Determines whether this instance owns the input mutex.
AbstractConcurrentInputMode
 Inherited
initialize():void
Performs one-time initialization of this instance.
AbstractInputMode
  
initializeStateMachine(machine:StateMachine, startState:State, canceledState:State, stoppedState:State, finishedState:State):void
Called to initialize the state machine.
StateMachineInputMode
  
[override] Installs this mode into the given canvas.
StateMachineInputMode
  
Installs all necessary listeners to trigger the run method.
StateMachineInputMode
 Inherited
invalidate():void
Convenience method for subclass implementations that invalidates the canvasComponent this mode is currently installed in.
AbstractInputMode
  
isCancelEvent(evt:Event):Boolean
Method that identifies an event as a cancel event.
StateMachineInputMode
  
isDisabledEvent(evt:Event):Boolean
Method that identifies an event as a disabled event.
StateMachineInputMode
  
isEnabledEvent(evt:Event):Boolean
Method that identifies an event as an enabled event.
StateMachineInputMode
  
isMutexAquiredEvent(evt:Event):Boolean
Method that identifies an event as a mutexAquired event.
StateMachineInputMode
  
isMutexLostEvent(evt:Event):Boolean
Method that identifies an event as a mutexLost event.
StateMachineInputMode
  
isStopEvent(evt:Event):Boolean
Method that identifies an event as a stop event.
StateMachineInputMode
  
Called when the cancel state has been entered.
StateMachineInputMode
  
onDisable():void
Runs the state machine using a disable event.
StateMachineInputMode
 Inherited
onDisabled():void
Called when the enabled property changes to false.
AbstractConcurrentInputMode
  
onEnable():void
Runs the state machine using a enable event.
StateMachineInputMode
 Inherited
onEnabled():void
Called when the enabled property changes to true.
AbstractConcurrentInputMode
  
StateMachineInputMode
  
[override] Runs the state machine using a mutex obtained event.
StateMachineInputMode
  
[override] Runs the state machine using a mutex lost event.
StateMachineInputMode
 Inherited
onPreferredCursorChanged(oldValue:Cursor, newValue:Cursor):void
Called when the preferredCursor property changes.
AbstractConcurrentInputMode
  
onRun(evt:Event):void
Callback method that will be called after the state machine has been run using the arguments provided.
StateMachineInputMode
  
Called when the cancel state has been entered.
StateMachineInputMode
 Inherited
Releases the mutex that is currently owned by this instance.
AbstractConcurrentInputMode
 Inherited
Requests the InputMutex from the current controller.
AbstractConcurrentInputMode
  
StateMachineInputMode
  
setPreferredCursorTransition(cursorClass:Class):Function
Factory method that can be used to obtain an listener implementation that sets the given preferredCursor.
StateMachineInputMode
  
Factory method that can be used to obtain a listener implementation that resets the preferredCursor.
StateMachineInputMode
  
[override] Uninstalls this mode from the canvas.
StateMachineInputMode
  
Uninstalls all listeners, this instance has installed on calling intallListeners()
StateMachineInputMode
Events
 Event Summary Defined By
 InheritedDispatched after the input mode was installed.AbstractInputMode
 InheritedDispatched before the input mode will be installed.AbstractInputMode
 InheritedDispatched when the default cursor changed.AbstractConcurrentInputMode
 InheritedDispatched after the input mode was uninstalled.AbstractInputMode
 InheritedDispatched before the input mode will be uninstalled.AbstractInputMode
Public Constants
 ConstantDefined By
 InheritedINSTALLED : String = installed
[static]
AbstractInputMode
 InheritedINSTALLING : String = installing
[static]
AbstractInputMode
 InheritedPREFERRED_CURSOR_CHANGED : String = preferredCursorChanged
[static]
AbstractConcurrentInputMode
 InheritedUNINSTALLED : String = uninstalled
[static]
AbstractInputMode
 InheritedUNINSTALLING : String = uninstalling
[static]
AbstractInputMode
Property Detail
_lastEventproperty
protected var _lastEvent:Event

The last Event that has been delivered to this instance.

_lastMouseEventproperty 
protected var _lastMouseEvent:CanvasMouseEvent

The last MouseEvent that has been delivered to this instance.

canceledStateproperty 
canceledState:State  [read-only]

Returns the canceled state of the state machine.

The canceled state is the state the machine will be put into if the mode is canceled. This method will create a cancaled state using createCanceledState the first time it is queried.


Implementation
    public function get canceledState():State
lastMouseEventproperty 
lastMouseEvent:CanvasMouseEvent  [read-only]

Returns the last mouse event.


Implementation
    public function get lastMouseEvent():CanvasMouseEvent
startStateproperty 
startState:State  [read-only]

Returns the start state of the state machine.

The start state is the state the machine will be reset to if the mode is reset. This method will create a start state using createStartState the first time it is queried.


Implementation
    public function get startState():State
stateMachineproperty 
stateMachine:StateMachine  [read-only]

Gets the state machine.

Upon first access to instance, the machine will be initialized using initializeStateMachine.


Implementation
    public function get stateMachine():StateMachine
stopEventRecognizerproperty 
stopEventRecognizer:Function  [read-only]

An event recognizer for the state machine that is triggered if this mode has been stoppped.


Implementation
    protected function get stopEventRecognizer():Function
stoppedStateproperty 
stoppedState:State  [read-only]

Returns the stopped state of the state machine.

The stopped state is the state the machine will be put into if the mode is stopped. This method will create a stopped state using createStoppedState the first time it is queried.


Implementation
    public function get stoppedState():State
Constructor Detail
StateMachineInputMode()Constructor
public function StateMachineInputMode(stateMachine:StateMachine = null, startState:State = null, canceledState:State = null, stoppedState:State = null)

Creates a new instance using the given state machine and states.

Parameters
stateMachine:StateMachine (default = null) — The machine to use.
 
startState:State (default = null) — The state to use as the start state.
 
canceledState:State (default = null) — The state to use as the canceled state.
 
stoppedState:State (default = null) — The state to use as the stopped state.
Method Detail
cancel()method
override public function cancel():void

Runs the machine using the cancel and reset events, releases the input mutex and returns.

createCanceledState()method 
protected function createCanceledState(machine:StateMachine):State

Factory method that creates a canceled State for the given machine.

This implementation automatically connects the returned state to the start state.

Parameters

machine:StateMachine — The machine to create a state for.

Returns
State — This implementation returns a new state.
createStartState()method 
protected function createStartState(machine:StateMachine):State

Factory method that creates a start State for the given machine.

Parameters

machine:StateMachine — The machine to create a state for.

Returns
State — This implementation returns machine.startState
createStateMachine()method 
protected function createStateMachine():StateMachine

Factory method that creates the state machine.

Returns
StateMachine — A new StateMachine
createStoppedState()method 
protected function createStoppedState(machine:StateMachine):State

Factory method that creates a stopped State for the given machine.

This implementation automatically connects the stopped state to the start state.

Parameters

machine:StateMachine — The machine to create a state for.

Returns
State — This implementation returns a new state.
initializeStateMachine()method 
protected function initializeStateMachine(machine:StateMachine, startState:State, canceledState:State, stoppedState:State, finishedState:State):void

Called to initialize the state machine.

This implementation does nothing.

Parameters

machine:StateMachine — The machine to initialize and configure
 
startState:State — The start state to use.
 
canceledState:State — The canceled state to use.
 
stoppedState:State — The stopped state to use.
 
finishedState:State — The finished state to use.

installCore()method 
override protected function installCore(context:IInputModeContext):void

Installs this mode into the given canvas.

Subclasses should override this method and call super.install(canvas), first. One-time initialization should be performed in the initialize method. The install method will call the initialize method the first time this mode gets installed.

This implementation calls installListeners.

Parameters

context:IInputModeContext — The canvas to install this mode into

installListeners()method 
protected function installListeners():void

Installs all necessary listeners to trigger the run method.

This implementation registers for all mouse events and keyboard events.

isCancelEvent()method 
protected function isCancelEvent(evt:Event):Boolean

Method that identifies an event as a cancel event.

Parameters

evt:Event — The event to identify

Returns
Booleantrue if the given event is a cancel event.
isDisabledEvent()method 
protected function isDisabledEvent(evt:Event):Boolean

Method that identifies an event as a disabled event.

Parameters

evt:Event — The event to identify

Returns
Booleantrue if the given event is a disabled event.
isEnabledEvent()method 
protected function isEnabledEvent(evt:Event):Boolean

Method that identifies an event as an enabled event.

Parameters

evt:Event — The event to identify

Returns
Booleantrue if the given event is an enabled event.
isMutexAquiredEvent()method 
protected function isMutexAquiredEvent(evt:Event):Boolean

Method that identifies an event as a mutexAquired event.

Parameters

evt:Event — The event to identify

Returns
Booleantrue if the given event is a mutexAquired event.
isMutexLostEvent()method 
protected function isMutexLostEvent(evt:Event):Boolean

Method that identifies an event as a mutexLost event.

Parameters

evt:Event — The event to identify

Returns
Booleantrue if the given event is a mutexLost event.
isStopEvent()method 
protected function isStopEvent(evt:Event):Boolean

Method that identifies an event as a stop event.

Parameters

evt:Event — The event to identify

Returns
Booleantrue if the given event is a stop event.
onCancelStateEntered()method 
protected function onCancelStateEntered(evt:StateChangeEvent):void

Called when the cancel state has been entered.

This implementation will release the input mutex and reset the preferred cursor. This will trigger another run of the machine which will normally bring the machine back to the start state.

Parameters

evt:StateChangeEvent

onDisable()method 
protected function onDisable():void

Runs the state machine using a disable event.

onEnable()method 
protected function onEnable():void

Runs the state machine using a enable event.

onMachineReset()method 
protected function onMachineReset():void

onMutexObtained()method 
override protected function onMutexObtained():void

Runs the state machine using a mutex obtained event.

onMutexReleased()method 
override protected function onMutexReleased():void

Runs the state machine using a mutex lost event.

onRun()method 
protected function onRun(evt:Event):void

Callback method that will be called after the state machine has been run using the arguments provided.

This will trigger a run event.

Parameters

evt:Event — The event that triggered the run

onStopStateEntered()method 
protected function onStopStateEntered(evt:StateChangeEvent):void

Called when the cancel state has been entered.

This will trigger another run of the machine which will normally bring the machine back to the start state.

Parameters

evt:StateChangeEvent

resetMachine()method 
public function resetMachine():void

Runs the machine using a special reset event.

run()method 
public function run(evt:Event):void

Tries to run the virtual machine using the pair of source and event argument to determine which transition to take.

If this method is called reentrantly it will not immediately execute the transition but queue the event.

Parameters

evt:Event — event to use to decide whether to make the transition.

setLastMouseEvent()method 
protected function setLastMouseEvent(evt:CanvasMouseEvent):void

Parameters

evt:CanvasMouseEvent

setPreferredCursorTransition()method 
protected function setPreferredCursorTransition(cursorClass:Class):Function

Factory method that can be used to obtain an listener implementation that sets the given preferredCursor.

Parameters

cursorClass:Class — The cursor to set if the transition is done.

Returns
Function — A listener for the transitionDone event that can be added to a Transition.
setResetCursorTransition()method 
protected function setResetCursorTransition():Function

Factory method that can be used to obtain a listener implementation that resets the preferredCursor.

Returns
Function — A listener for the transitionDone event that can be added to a Transition.
stop()method 
override public function stop():Boolean

Runs the machine using a special stop event.

If the machine arrives at the startState, this method will release the input mutex and return true.

Returns
Booleantrue if the machine arrived at the start state and stopped.
uninstallCore()method 
override protected function uninstallCore(context:IInputModeContext):void

Uninstalls this mode from the canvas.

Subclasses should always call super.uninstallCore( canvas ) as the last statement. This implementation calls uninstallListeners.

Parameters

context:IInputModeContext — The canvas component to uninstall this input mode from.

uninstallListeners()method 
protected function uninstallListeners():void

Uninstalls all listeners, this instance has installed on calling intallListeners()