Package uk.ac.starlink.table.gui
Class ProgressBarStarTable
- java.lang.Object
-
- uk.ac.starlink.table.WrapperStarTable
-
- uk.ac.starlink.table.gui.ProgressBarStarTable
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.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:- Iteration using
getRowSequence()
orgetRowSplittable()
will update a suppliedJProgressBar
as it goes. - 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)
-
-
Field Summary
-
Fields inherited from class uk.ac.starlink.table.WrapperStarTable
baseTable
-
-
Constructor Summary
Constructors Constructor Description ProgressBarStarTable(StarTable baseTable, javax.swing.JProgressBar progBar)
Constructor with default cancellation control.ProgressBarStarTable(StarTable baseTable, javax.swing.JProgressBar progBar, java.util.function.BooleanSupplier isCancelled)
Constructor with supplied cancellation control.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getActiveLabel()
Returns the text of the label which is visible in the progress bar when a RowSequence acquired from this table is active.javax.swing.JProgressBar
getProgressBar()
Returns the progress bar which this table controls.RowSequence
getRowSequence()
Returns an object which can iterate over all the rows in the table sequentially.RowSplittable
getRowSplittable()
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.void
setActiveLabel(java.lang.String label)
Sets a label which will be visible in the progress bar when a RowSequence acquired from this table is being iterated over.void
setProgressBar(javax.swing.JProgressBar progBar)
Sets the progress bar which this table controls.-
Methods inherited from class uk.ac.starlink.table.WrapperStarTable
checkedLongToInt, close, getBaseTable, getCell, getColumnAuxDataInfos, getColumnCount, getColumnInfo, getName, getParameterByName, getParameters, getRow, getRowAccess, getRowCount, getURL, isRandom, setName, setParameter, setURL, toString
-
-
-
-
Constructor Detail
-
ProgressBarStarTable
public ProgressBarStarTable(StarTable baseTable, javax.swing.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 aRowSequence
), but is unlikely to achieve cancellation of multi-threaded iteration (using aRowSplittable
).- Parameters:
baseTable
- table supplying dataprogBar
- progress bar to update
-
ProgressBarStarTable
public ProgressBarStarTable(StarTable baseTable, javax.swing.JProgressBar progBar, java.util.function.BooleanSupplier isCancelled)
Constructor with supplied cancellation control.- Parameters:
baseTable
- table supplying dataprogBar
- progress bar to updateisCancelled
- object controlling cancellation: if it supplies a true value, thenext
method of anyRowSequence
orRowSplittable
taken out on this table will (probably, at some point) throw IOExceptions
-
-
Method Detail
-
setProgressBar
public void setProgressBar(javax.swing.JProgressBar progBar)
Sets the progress bar which this table controls.- Parameters:
progBar
- progress bar
-
getProgressBar
public javax.swing.JProgressBar getProgressBar()
Returns the progress bar which this table controls.- Returns:
- progress bar
-
setActiveLabel
public void setActiveLabel(java.lang.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 java.lang.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 java.io.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 interfaceStarTable
- Overrides:
getRowSequence
in classWrapperStarTable
- Returns:
- new RowSequence
- Throws:
java.io.IOException
- if there is an error providing access
-
getRowSplittable
public RowSplittable getRowSplittable() throws java.io.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 returnTables.getDefaultRowSplittable
(this)
.- Specified by:
getRowSplittable
in interfaceStarTable
- Overrides:
getRowSplittable
in classWrapperStarTable
- Returns:
- new RowSplittable
- Throws:
java.io.IOException
- See Also:
RowRunner
-
-