Package com.j3d.threads
Class BlinkerSwingWorker
- All Implemented Interfaces:
Runnable,Future<Void>,RunnableFuture<Void>
A SwingWorker implementation designed to perform a blinking effect on a UI component.
It repeatedly executes a given
Runnable, repainting the main panel,
with a specified delay between repetitions. After the blinking sequence completes,
it removes an overlap identified by a UUID from the scene manager.- Author:
- Lehlogonolo Poole
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.SwingWorker
SwingWorker.StateValueNested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBlinkerSwingWorker(long waitMs, int repeatAmtTimes, Runnable set, UUID uuid) Constructs a new BlinkerSwingWorker. -
Method Summary
Methods inherited from class javax.swing.SwingWorker
addPropertyChangeListener, cancel, done, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, process, publish, removePropertyChangeListener, run, setProgressMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.concurrent.Future
exceptionNow, resultNow, state
-
Field Details
-
waitMs
private final long waitMs -
repeatAmtTimes
private final int repeatAmtTimes -
runnable
-
idToRemove
-
-
Constructor Details
-
BlinkerSwingWorker
Constructs a new BlinkerSwingWorker.- Parameters:
waitMs- The delay in milliseconds between each blink cycle (repaint, run, repaint).repeatAmtTimes- The number of times the blink cycle should be repeated.set- TheRunnableto be executed during each blink cycle. This typically toggles the visibility or state of the element to be blinked.uuid- TheUUIDof the overlap to be removed from the scene manager once the blinking sequence is complete.
-
-
Method Details
-
repeat
private void repeat()Executes the blinking sequence. It loops `repeatAmtTimes` times, performing the following steps in each iteration:- Sleeps for
waitMsmilliseconds. - Executes the provided
runnable. - Repaints the
StaticRefs.getMainPanel().
- Sleeps for
-
doInBackground
The main task to be executed in the background by this SwingWorker. It first calls therepeat()method to perform the blinking, and then removes the specified overlap from the scene manager.- Specified by:
doInBackgroundin classSwingWorker<Void,Void> - Returns:
nullas this worker does not produce any intermediate results or a final result.- Throws:
Exception
-