Class FSM<E>


  • public class FSM<E>
    extends Object
    • Field Detail

      • logger

        protected Logger logger
      • inner

        protected boolean inner
      • startingState

        protected State<E> startingState
        By default an FSM triggers its 'start' event when it leaves its initial state. In some cases, this is not the case. For example, a double-click interaction is an FSM that must trigger its start event when the FSM reaches... its terminal state. Similarly, a DnD must trigger its start event on the first move, not on the first press. The goal of this attribute is to identify the state of the FSM that must trigger the start event. By default, this attribute is set with the initial state of the FSM.
      • started

        protected boolean started
        Goes with 'startingState'. It permits to know whether the FSM has started, ie whether the 'starting state' has been reached.
      • initState

        protected final InitState<E> initState
      • states

        protected final Set<State<E>> states
        The states that compose the finite state machine.
      • handlers

        protected final Set<FSMHandler> handlers
        The handler that want to be notified when the state machine of the interaction changed.
      • eventsToProcess

        protected final List<E> eventsToProcess
        The events still in process. For example when the user press key ctrl and scroll one time using the wheel of the mouse, the interaction scrolling is finished but the event keyPressed 'ctrl' is still in process. At the end of the interaction, these events are re-introduced into the state machine of the interaction for processing.
      • currentTimeout

        protected TimeoutTransition<E> currentTimeout
        The current timeout in progress.
      • currentSubFSM

        protected FSM<E> currentSubFSM
    • Constructor Detail

      • FSM

        public FSM()
    • Method Detail

      • setInner

        public void setInner​(boolean inner)
      • isInner

        public boolean isInner()
      • process

        public boolean process​(E event)
      • isStarted

        public boolean isStarted()
      • setCurrentState

        protected void setCurrentState​(OutputState<E> state)
      • processRemainingEvents

        protected void processRemainingEvents()
        At the end of the FSM execution, the events still (eg keyPress) in process must be recycled to be reused in the FSM.
      • addRemaningEventsToProcess

        protected void addRemaningEventsToProcess​(E event)
      • onCancelling

        protected void onCancelling()
        Cancels the state machine.
      • addState

        protected void addState​(InputState<E> state)
        Adds a state to the state machine.
        Parameters:
        state - The state to add. Must not be null.
      • log

        public void log​(boolean log)
      • reinit

        public void reinit()
      • fullReinit

        public void fullReinit()
      • onTimeout

        protected void onTimeout()
        Jobs to do when a timeout transition is executed. Because the timeout transition is based on a separated thread, the job done by this method must be executed in the UI thread. UI Platforms must override this method to do that.
      • stopCurrentTimeout

        protected void stopCurrentTimeout()
        Stops the current timeout transition.
      • checkTimeoutTransition

        protected void checkTimeoutTransition()
        Checks whether the current state has a timeout transition. If it is the case, the timeout transition is launched.
      • addHandler

        public void addHandler​(FSMHandler handler)
      • removeHandler

        public void removeHandler​(FSMHandler handler)
      • notifyHandlerOnCancel

        protected void notifyHandlerOnCancel()
        Notifies handler that the interaction is cancelled.
      • getStates

        public Set<State<E>> getStates()
      • uninstall

        public void uninstall()