Package generic.timer
Class GhidraSwinglessTimer
java.lang.Object
generic.timer.GhidraSwinglessTimer
- All Implemented Interfaces:
GhidraTimer
The GhidraSwinglessTimer is similar to the javax.swing.Timer class. The big difference is
that it does NOT use the swing thread for its callbacks. Similar to the swing timer, only
one timer thread is ever used no matter how many GhidraSwinglessTimers are instantiated.
It fires one or more
TimerCallbacks at specified
intervals.
Setting up a timer
involves creating a GhidraSwinglessTimer object,
registering one or more TimerCallbacks on it,
and starting the timer using
the start method.-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new repeating timer with a initial delay of 100ms and a continual delay of 100ms.GhidraSwinglessTimer(int initialDelay, int delay, TimerCallback callback) Creates a new repeating timer with an initial and continual delay.GhidraSwinglessTimer(int delay, TimerCallback callback) Creates a new repeating timer with a initial and continual delay with the given delay. -
Method Summary
Modifier and TypeMethodDescriptionintgetDelay()Returns the delay for all callbacks after the first callback.intReturns the delay for the first callback.booleanReturns true if this timer is set to repeating.booleanReturns true if the timer is running.static voidvoidsetDelay(int delay) Sets the delay for all callbacks after the first callbackvoidsetInitialDelay(int initialDelay) Sets the delay for the first callbacks.voidsetRepeats(boolean repeats) Sets whether this timer repeats.voidsetTimerCallback(TimerCallback callback) Sets the callback to be called when the timer fires.voidstart()Starts the timer.voidstop()Stops the timer.
-
Constructor Details
-
GhidraSwinglessTimer
public GhidraSwinglessTimer()Creates a new repeating timer with a initial delay of 100ms and a continual delay of 100ms. -
GhidraSwinglessTimer
Creates a new repeating timer with a initial and continual delay with the given delay.- Parameters:
delay- the delay to use for the first and subsequent timer callbacks.callback- the callback the be called with the timer fires.
-
GhidraSwinglessTimer
Creates a new repeating timer with an initial and continual delay.- Parameters:
initialDelay- the delay to use for the first timer callbacks.delay- the delay to use for subsequent timer callbacks.callback- the callback the be called with the timer fires.
-
-
Method Details
-
getDelay
public int getDelay()Returns the delay for all callbacks after the first callback.- Specified by:
getDelayin interfaceGhidraTimer- Returns:
- the delay for all callbacks after the first callback.
-
getInitialDelay
public int getInitialDelay()Returns the delay for the first callback.- Specified by:
getInitialDelayin interfaceGhidraTimer- Returns:
- the delay for the first callback.
-
isRepeats
public boolean isRepeats()Returns true if this timer is set to repeating.- Specified by:
isRepeatsin interfaceGhidraTimer- Returns:
- true if this timer is set to repeating.
-
setDelay
public void setDelay(int delay) Sets the delay for all callbacks after the first callback- Specified by:
setDelayin interfaceGhidraTimer
-
setInitialDelay
public void setInitialDelay(int initialDelay) Sets the delay for the first callbacks.- Specified by:
setInitialDelayin interfaceGhidraTimer
-
setRepeats
public void setRepeats(boolean repeats) Sets whether this timer repeats.- Specified by:
setRepeatsin interfaceGhidraTimer- Parameters:
repeats- if true, the timer will repeat, if false the timer will only fire once.
-
setTimerCallback
Sets the callback to be called when the timer fires.- Specified by:
setTimerCallbackin interfaceGhidraTimer
-
start
public void start()Starts the timer.- Specified by:
startin interfaceGhidraTimer
-
stop
public void stop()Stops the timer.- Specified by:
stopin interfaceGhidraTimer
-
isRunning
public boolean isRunning()Returns true if the timer is running.- Specified by:
isRunningin interfaceGhidraTimer
-
main
- Throws:
InterruptedException
-