Class MultiPassKernelSwingWorker

java.lang.Object
javax.swing.SwingWorker<Void,Void>
com.aparapi.util.swing.MultiPassKernelSwingWorker
All Implemented Interfaces:
Runnable, Future<Void>, RunnableFuture<Void>

public abstract class MultiPassKernelSwingWorker extends SwingWorker<Void,Void>
Implementation of SwingWorker to assist in progress tracking and cancellation of multi-pass Kernels.
  • Field Details

    • DEFAULT_POLL_INTERVAL

      public static final int DEFAULT_POLL_INTERVAL
      See Also:
    • kernel

      private Kernel kernel
    • timer

      private Timer timer
  • Constructor Details

    • MultiPassKernelSwingWorker

      protected MultiPassKernelSwingWorker(Kernel kernel)
  • Method Details

    • cancelExecution

      public void cancelExecution()
      Utility method which just invokes Kernel.cancelMultiPass() on the executing kernel.
    • executeKernel

      protected abstract void executeKernel(Kernel kernel)
      This method must invoke one of the kernel'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 a JProgressBar) 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 by KernelRunner.getCurrentPass().
    • doInBackground

      protected final Void doInBackground() throws Exception
      Executes the kernel via executeKernel(Kernel), whilst also managing progress updates for the kernel's passId.
      Specified by:
      doInBackground in class SwingWorker<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, returns DEFAULT_POLL_INTERVAL.