Module interacto.java.api
Package io.github.interacto.interaction
Class InteractionImpl<D extends InteractionData,E,F extends FSM<E>>
- java.lang.Object
-
- io.github.interacto.interaction.InteractionImpl<D,E,F>
-
public abstract class InteractionImpl<D extends InteractionData,E,F extends FSM<E>> extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanactivatedDefines whether the interaction is activated.protected EcurrentThrottledEventprotected Ffsmprotected Loggerloggerprotected AtomicLongthrottleCounterprotected longthrottleTimeout
-
Constructor Summary
Constructors Modifier Constructor Description protectedInteractionImpl(F fsm)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidfullReinit()abstract DgetData()FgetFsm()booleanisActivated()protected abstract booleanisEventsOfSameType(E evt1, E evt2)Defines whether the two given events are of the same type.booleanisRunning()voidlog(boolean log)voidprocessEvent(E event)protected voidreinit()protected abstract voidreinitData()protected abstract voidrunInUIThread(Runnable cmd)Runs the given command in the UI thread.voidsetActivated(boolean activated)static voidsetLogger(Logger logger)Sets the logger to use.voidsetThrottleTimeout(long timeout)voiduninstall()protected abstract voidupdateEventsRegistered(OutputState<E> newState, OutputState<E> oldState)
-
-
-
Field Detail
-
activated
protected boolean activated
Defines whether the interaction is activated. If not, the interaction will not change on events.
-
logger
protected Logger logger
-
throttleTimeout
protected long throttleTimeout
-
throttleCounter
protected final AtomicLong throttleCounter
-
currentThrottledEvent
protected E currentThrottledEvent
-
-
Constructor Detail
-
InteractionImpl
protected InteractionImpl(F fsm)
-
-
Method Detail
-
setLogger
public static void setLogger(Logger logger)
Sets the logger to use. Cannot be null. Does not change the loggers of existing user interactions.- Parameters:
logger- The new logger to use.
-
getData
public abstract D getData()
-
setThrottleTimeout
public void setThrottleTimeout(long timeout)
-
updateEventsRegistered
protected abstract void updateEventsRegistered(OutputState<E> newState, OutputState<E> oldState)
-
isRunning
public boolean isRunning()
-
fullReinit
public void fullReinit()
-
isEventsOfSameType
protected abstract boolean isEventsOfSameType(E evt1, E evt2)
Defines whether the two given events are of the same type. For example, whether they are both mouse move events. This check is platform specific.- Parameters:
evt1- The first event to check.evt2- The second event to check.- Returns:
- True: the two events are of the same type.
-
runInUIThread
protected abstract void runInUIThread(Runnable cmd)
Runs the given command in the UI thread. This is necessary since some created threads (e.g. throttling, timeout transition) exit the UI thread but may require some job to be executed in the UI thread.- Parameters:
cmd- The job to execute in the UI thread.
-
processEvent
public void processEvent(E event)
-
log
public void log(boolean log)
-
isActivated
public boolean isActivated()
-
setActivated
public void setActivated(boolean activated)
-
getFsm
public F getFsm()
-
reinit
protected void reinit()
-
reinitData
protected abstract void reinitData()
-
uninstall
public void uninstall()
-
-