Package com.aparapi.util.swing
Class MultiPassKernelSwingWorker
- All Implemented Interfaces:
Runnable
,Future<Void>
,RunnableFuture<Void>
Implementation of SwingWorker to assist in progress tracking and cancellation of multi-pass
Kernel
s.-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.SwingWorker
SwingWorker.StateValue
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Utility method which just invokesKernel.cancelMultiPass()
on the executing kernel.private void
protected final Void
Executes thekernel
viaexecuteKernel(Kernel)
, whilst also managing progress updates for the kernel's passId.protected abstract void
executeKernel
(Kernel kernel) This method must invoke one of thekernel
's execute() methods.protected int
The interval at which the Kernel's current passId is polled.private void
private void
protected abstract void
updatePassId
(int passId) This method, which is always invoked on the swing event dispatch thread, should be used to update any components (such as aJProgressBar
) so as to reflect the progress of the multi-pass Kernel being executed.Methods inherited from class javax.swing.SwingWorker
addPropertyChangeListener, cancel, done, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, process, publish, removePropertyChangeListener, run, setProgress
-
Field Details
-
DEFAULT_POLL_INTERVAL
public static final int DEFAULT_POLL_INTERVAL- See Also:
-
kernel
-
timer
-
-
Constructor Details
-
MultiPassKernelSwingWorker
-
-
Method Details
-
cancelExecution
public void cancelExecution()Utility method which just invokesKernel.cancelMultiPass()
on the executing kernel. -
executeKernel
This method must invoke one of thekernel
's execute() methods. -
updatePassId
protected abstract void updatePassId(int passId) This method, which is always invoked on the swing event dispatch thread, should be used to update any components (such as aJProgressBar
) so as to reflect the progress of the multi-pass Kernel being executed.- Parameters:
passId
- The passId for the Kernel's current pass, or one of the constant fields returnable byKernelRunner.getCurrentPass()
.
-
doInBackground
Executes thekernel
viaexecuteKernel(Kernel)
, whilst also managing progress updates for the kernel's passId.- Specified by:
doInBackground
in classSwingWorker<Void,
Void> - Throws:
Exception
-
setUpExecution
private void setUpExecution() -
cleanUpExecution
private void cleanUpExecution() -
updatePassId
private void updatePassId() -
getPollIntervalMillis
protected int getPollIntervalMillis()The interval at which the Kernel's current passId is polled. Unless overridden, returnsDEFAULT_POLL_INTERVAL
.
-