Package | com.yworks.canvas.input |
Class | public class StateMachineInputMode |
Inheritance | StateMachineInputMode AbstractConcurrentInputMode AbstractInputMode flash.events.EventDispatcher |
Subclasses | ClickInputMode, CreateEdgeInputMode, EdgeDragInputModeBase, HandleInputMode, MarqueeSelectionInputMode, MoveInputMode, MoveViewportInputMode, ResizeStripeInputMode |
IConcurrentInputMode
implementation that uses a StateMachine
to manage its state.
This instance does nothing and needs to be subclassed in order to be useful.
Property | Defined By | ||
---|---|---|---|
canceledState : State [read-only]
Returns the canceled state of the state machine. | StateMachineInputMode | ||
canvas : CanvasComponent [read-only]
The canvas instance this mode is currently installed in or null
| AbstractInputMode | ||
controller : ConcurrencyController
Gets or injects the ConcurrencyController for this instance. | AbstractConcurrentInputMode | ||
enabled : Boolean
Gets or sets the enabled state of this input mode. | AbstractConcurrentInputMode | ||
inputModeContext : IInputModeContext [read-only]
The context instance this mode is currently installed in or
null if this instance is not installed. | AbstractInputMode | ||
installed : 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 | ||
preferredCursor : 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 |
Property | Defined 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 |
Method | Defined 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 | ||
dispose():void
Disposes this input mode. | AbstractInputMode | ||
install(context:IInputModeContext):void
Installs this mode into the canvas of the given context. | AbstractInputMode | ||
resetMachine():void
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 | ||
uninstall(context:IInputModeContext):void
Uninstalls this mode from the canvas. | AbstractInputMode |
Method | Defined By | ||
---|---|---|---|
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 | ||
fireInstalled():void | AbstractInputMode | ||
fireInstalling():void | AbstractInputMode | ||
fireUninstalled():void | AbstractInputMode | ||
fireUninstalling():void | AbstractInputMode | ||
hasMutex():Boolean
Determines whether this instance owns the input mutex. | AbstractConcurrentInputMode | ||
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 | ||
installCore(context:IInputModeContext):void [override]
Installs this mode into the given canvas. | StateMachineInputMode | ||
installListeners():void
Installs all necessary listeners to trigger the run method. | StateMachineInputMode | ||
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 | ||
onCancelStateEntered(evt:StateChangeEvent):void
Called when the cancel state has been entered. | StateMachineInputMode | ||
onDisable():void
Runs the state machine using a disable event. | StateMachineInputMode | ||
onDisabled():void
Called when the enabled property changes to false. | AbstractConcurrentInputMode | ||
onEnable():void
Runs the state machine using a enable event. | StateMachineInputMode | ||
onEnabled():void
Called when the enabled property changes to true. | AbstractConcurrentInputMode | ||
onMachineReset():void | StateMachineInputMode | ||
onMutexObtained():void [override]
Runs the state machine using a mutex obtained event. | StateMachineInputMode | ||
onMutexReleased():void [override]
Runs the state machine using a mutex lost event. | StateMachineInputMode | ||
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 | ||
onStopStateEntered(evt:StateChangeEvent):void
Called when the cancel state has been entered. | StateMachineInputMode | ||
releaseMutex():void
Releases the mutex that is currently owned by this instance. | AbstractConcurrentInputMode | ||
requestMutex():void
Requests the InputMutex from the current controller. | AbstractConcurrentInputMode | ||
setLastMouseEvent(evt:CanvasMouseEvent):void | StateMachineInputMode | ||
setPreferredCursorTransition(cursorClass:Class):Function
Factory method that can be used to obtain an listener
implementation that sets the given preferredCursor. | StateMachineInputMode | ||
setResetCursorTransition():Function
Factory method that can be used to obtain a listener implementation
that resets the preferredCursor. | StateMachineInputMode | ||
uninstallCore(context:IInputModeContext):void [override]
Uninstalls this mode from the canvas. | StateMachineInputMode | ||
uninstallListeners():void
Uninstalls all listeners, this instance has installed on calling intallListeners()
| StateMachineInputMode |
_lastEvent | property |
protected var _lastEvent:Event
The last Event
that has been delivered to this instance.
_lastMouseEvent | property |
protected var _lastMouseEvent:CanvasMouseEvent
The last MouseEvent
that has been delivered to this instance.
canceledState | property |
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.
public function get canceledState():State
lastMouseEvent | property |
lastMouseEvent:CanvasMouseEvent
[read-only] Returns the last mouse event.
public function get lastMouseEvent():CanvasMouseEvent
startState | property |
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.
public function get startState():State
stateMachine | property |
stateMachine:StateMachine
[read-only] Gets the state machine.
Upon first access to instance, the machine will be initialized using initializeStateMachine
.
public function get stateMachine():StateMachine
stopEventRecognizer | property |
stopEventRecognizer:Function
[read-only] An event recognizer for the state machine that is triggered if this mode has been stoppped.
protected function get stopEventRecognizer():Function
stoppedState | property |
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.
public function get stoppedState():State
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.
ParametersstateMachine: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.
|
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.
|
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.
|
State — This implementation returns machine.startState
|
createStateMachine | () | method |
protected function createStateMachine():StateMachine
Factory method that creates the state machine.
ReturnsStateMachine — 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.
|
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
|
Boolean — true 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
|
Boolean — true 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
|
Boolean — true 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
|
Boolean — true 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
|
Boolean — true 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
|
Boolean — true 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 |
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.
|
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
.
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
.
Boolean — true 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()