Class ViewerTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
uk.ac.starlink.topcat.ViewerTableModel
- All Implemented Interfaces:
Serializable, TableModel
A
TableModel which is based on a StarTable but
also provides methods for ordering rows and selecting which rows will
be visible. This class is used as the TableModel for the
TableViewer widget.- Author:
- Mark Taylor (Starlink)
- See Also:
-
Field Summary
Fields inherited from class AbstractTableModel
listenerList -
Constructor Summary
ConstructorsConstructorDescriptionViewerTableModel(PlasticStarTable startable) Constructs aViewerTableModelfrom aStarTable. -
Method Summary
Modifier and TypeMethodDescriptionlonggetBaseRow(int irow) Returns the index of the data model row corresponding to a given row in this view model.intintReturns an iterator over the base table row indices represented by this view.int[]Returns the mapping from row index visible in this model to row index in the base table.uk.ac.starlink.table.StarTablegetRowPermutedView(uk.ac.starlink.table.StarTable table) Returns a view of a given table whose rows are permuted in the same way as the current view is permuted with respect to the basic table.uk.ac.starlink.table.StarTableReturns a new StarTable whose data corresponds to the current state of this ViewerTableModel.Returns the RowSubset currently used by the viewer model.getValueAt(int irow, int icol) intgetViewRow(long lrow) Returns the index at which a given table row appears in this view model.booleanisCellEditable(int irow, int icol) voidsetOrder(int[] order) Configures this view to view the rows of the base model in a given order.voidsetRowMap(int[] rowMap) Sets the mapping from row index visible in this model to row index in the base table.voidConfigures this view to view only a subset of the rows of the base model.voidsetValueAt(Object val, int irow, int icol) Methods inherited from class AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, removeTableModelListener
-
Constructor Details
-
ViewerTableModel
Constructs aViewerTableModelfrom aStarTable. The suppliedStarTablemust provide random access.- Parameters:
startable- theStarTableobject- Throws:
IllegalArgumentException- ifstartable.isRandomreturnsfalse
-
-
Method Details
-
setOrder
public void setOrder(int[] order) Configures this view to view the rows of the base model in a given order. The supplied order array should be a 1:1 mapping of rows in the base table to the order in which they will be viewed. This method triggers a suitableTableModelEventto listeners.- Parameters:
order- mapping of rows in the table view, ornullto indicate natural ordering
-
setSubset
Configures this view to view only a subset of the rows of the base model. This method triggers a suitableTableModelEventto listeners.- Parameters:
rset- RowSubset object indicating inclusion in subset of rows to be viewed
-
getSubset
Returns the RowSubset currently used by the viewer model.- Returns:
- the row subset
-
getRowMap
public int[] getRowMap()Returns the mapping from row index visible in this model to row index in the base table.- Returns:
- row mapping; may be
nullto indicate a unit map
-
getRowIndexIterator
Returns an iterator over the base table row indices represented by this view. This is an iteration over the values in therowMapif it is non-null, or an iterator over all the rows if it is null. The number of elements iterated over is given bygetRowCount().- Returns:
- row index iterator
-
setRowMap
public void setRowMap(int[] rowMap) Sets the mapping from row index visible in this model to row index in the base table.- Parameters:
rowMap- row mapping; may benullto indicate a unit map
-
getColumnCount
public int getColumnCount() -
getRowCount
public int getRowCount() -
getBaseRow
public long getBaseRow(int irow) Returns the index of the data model row corresponding to a given row in this view model.- Parameters:
irow- index of the row in this view model- Returns:
- index of the row in the base table
-
getViewRow
public int getViewRow(long lrow) Returns the index at which a given table row appears in this view model. If the given table row doesn't appear in the view model (it's not included in the current subset) then -1 is returned.- Parameters:
lrow- index of the row in the base table- Returns:
- index of the row in this view model, or -1
-
getValueAt
-
isCellEditable
public boolean isCellEditable(int irow, int icol) - Specified by:
isCellEditablein interfaceTableModel- Overrides:
isCellEditablein classAbstractTableModel
-
setValueAt
- Specified by:
setValueAtin interfaceTableModel- Overrides:
setValueAtin classAbstractTableModel
-
getSnapshot
public uk.ac.starlink.table.StarTable getSnapshot()Returns a new StarTable whose data corresponds to the current state of this ViewerTableModel. It has the same row ordering and subset, but subsequent changes to this model will not affect the data viewed from the resulting object.- Returns:
- StarTable view of a snapshot of the data available from this model
-
getRowPermutedView
public uk.ac.starlink.table.StarTable getRowPermutedView(uk.ac.starlink.table.StarTable table) Returns a view of a given table whose rows are permuted in the same way as the current view is permuted with respect to the basic table. The submitted table may be returned if no permutation is in force.- Parameters:
table- table to be permuted- Returns:
- a table which is a possibly permuted view of
table
-