Package com.aparapi.util.swing
Class MultiPassKernelSwingWorker
- java.lang.Object
-
- javax.swing.SwingWorker<java.lang.Void,java.lang.Void>
-
- com.aparapi.util.swing.MultiPassKernelSwingWorker
-
- All Implemented Interfaces:
java.lang.Runnable
,java.util.concurrent.Future<java.lang.Void>
,java.util.concurrent.RunnableFuture<java.lang.Void>
public abstract class MultiPassKernelSwingWorker extends javax.swing.SwingWorker<java.lang.Void,java.lang.Void>
Implementation of SwingWorker to assist in progress tracking and cancellation of multi-passKernel
s.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_POLL_INTERVAL
private Kernel
kernel
private javax.swing.Timer
timer
-
Constructor Summary
Constructors Modifier Constructor Description protected
MultiPassKernelSwingWorker(Kernel kernel)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
cancelExecution()
Utility method which just invokesKernel.cancelMultiPass()
on the executing kernel.private void
cleanUpExecution()
protected java.lang.Void
doInBackground()
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
getPollIntervalMillis()
The interval at which the Kernel's current passId is polled.private void
setUpExecution()
private void
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.
-
-
-
Field Detail
-
DEFAULT_POLL_INTERVAL
public static final int DEFAULT_POLL_INTERVAL
- See Also:
- Constant Field Values
-
kernel
private Kernel kernel
-
timer
private javax.swing.Timer timer
-
-
Constructor Detail
-
MultiPassKernelSwingWorker
protected MultiPassKernelSwingWorker(Kernel kernel)
-
-
Method Detail
-
cancelExecution
public void cancelExecution()
Utility method which just invokesKernel.cancelMultiPass()
on the executing kernel.
-
executeKernel
protected abstract void executeKernel(Kernel kernel)
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
protected final java.lang.Void doInBackground() throws java.lang.Exception
Executes thekernel
viaexecuteKernel(Kernel)
, whilst also managing progress updates for the kernel's passId.- Specified by:
doInBackground
in classjavax.swing.SwingWorker<java.lang.Void,java.lang.Void>
- Throws:
java.lang.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
.
-
-