Class ProgressBarStarTable

java.lang.Object
uk.ac.starlink.table.WrapperStarTable
uk.ac.starlink.table.gui.ProgressBarStarTable
All Implemented Interfaces:
Closeable, AutoCloseable, StarTable

public class ProgressBarStarTable extends WrapperStarTable
A WrapperStarTable which behaves the same as its base, except that UI intervention is permitted on any RowSequence which is taken out on it. It provides two services:
  1. Iteration using getRowSequence() or getRowSplittable() will update a supplied JProgressBar as it goes.
  2. Iteration can be forced to terminate based on the behaviour of a given BooleanSupplier.

You might think this should be based on a BoundedRangeModel (JProgressBar's model) instead, but unfortunately that doesn't allow you use of indeterminate progress states.

Author:
Mark Taylor (Starlink)
  • Constructor Details

    • ProgressBarStarTable

      public ProgressBarStarTable(StarTable baseTable, JProgressBar progBar)
      Constructor with default cancellation control. Iteration is cancelled if the calling thread is interrupted. This may be appropriate for single-threaded iteration (using a RowSequence), but is unlikely to achieve cancellation of multi-threaded iteration (using a RowSplittable).
      Parameters:
      baseTable - table supplying data
      progBar - progress bar to update
    • ProgressBarStarTable

      public ProgressBarStarTable(StarTable baseTable, JProgressBar progBar, BooleanSupplier isCancelled)
      Constructor with supplied cancellation control.
      Parameters:
      baseTable - table supplying data
      progBar - progress bar to update
      isCancelled - object controlling cancellation: if it supplies a true value, the next method of any RowSequence or RowSplittable taken out on this table will (probably, at some point) throw IOExceptions
  • Method Details

    • setProgressBar

      public void setProgressBar(JProgressBar progBar)
      Sets the progress bar which this table controls.
      Parameters:
      progBar - progress bar
    • getProgressBar

      public JProgressBar getProgressBar()
      Returns the progress bar which this table controls.
      Returns:
      progress bar
    • setActiveLabel

      public void setActiveLabel(String label)
      Sets a label which will be visible in the progress bar when a RowSequence acquired from this table is being iterated over.
      Parameters:
      label - label text
    • getActiveLabel

      public String getActiveLabel()
      Returns the text of the label which is visible in the progress bar when a RowSequence acquired from this table is active.
      Returns:
      label text
    • getRowSequence

      public RowSequence getRowSequence() throws IOException
      Description copied from interface: StarTable
      Returns an object which can iterate over all the rows in the table sequentially. Each such returned object is safe for use within a single thread, but not in general from multiple threads concurrently.
      Specified by:
      getRowSequence in interface StarTable
      Overrides:
      getRowSequence in class WrapperStarTable
      Returns:
      new RowSequence
      Throws:
      IOException - if there is an error providing access
    • getRowSplittable

      public RowSplittable getRowSplittable() throws IOException
      Description copied from interface: StarTable
      Returns an object which can iterate over all the rows in the table, but which may also be requested to split recursively for potentially parallel processing.

      The return value must be non-null, and may provide splitting arrangements specially appropriate for the implementation. If this table 'wraps' an upstream table, it is usually best to base the implementation on calls to the the upstream getRowSplittable method, so that upstream policy about how to divide up the table is respected. However, implementations without special requirements may return Tables.getDefaultRowSplittable(this).

      Specified by:
      getRowSplittable in interface StarTable
      Overrides:
      getRowSplittable in class WrapperStarTable
      Returns:
      new RowSplittable
      Throws:
      IOException
      See Also: