Package uk.ac.starlink.topcat
Class MetaColumnTableModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- uk.ac.starlink.topcat.MetaColumnTableModel
-
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.table.TableModel
public abstract class MetaColumnTableModel extends javax.swing.table.AbstractTableModel
Makes a TableModel out of a list of MetaColumn objects.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MetaColumnTableModel(java.util.List<MetaColumn> metaList)
Constructs a new MetaColumnTableModel.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
canSort(MetaColumn sortCol)
Indicates whether the supplied column has a defined sort order.java.lang.Class
getColumnClass(int icol)
int
getColumnCount()
java.util.List<MetaColumn>
getColumnList()
Returns the list of columns which provide the data for this model.java.lang.String
getColumnName(int icol)
int
getListIndex(int irow)
Returns the index in the natural row sequence for a row index in the table model.abstract int
getRowCount()
java.lang.Object
getValueAt(int irow, int icol)
boolean
isCellEditable(int irow, int icol)
void
setValueAt(java.lang.Object value, int irow, int icol)
boolean
sortRows(MetaColumn sortCol, boolean isDescending)
Reorders the rows of this table model based on the contents of one of its columns.-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
-
-
-
-
Constructor Detail
-
MetaColumnTableModel
public MetaColumnTableModel(java.util.List<MetaColumn> metaList)
Constructs a new MetaColumnTableModel.- Parameters:
metaList
- a list ofMetaColumn
objects
-
-
Method Detail
-
getColumnCount
public int getColumnCount()
-
getRowCount
public abstract int getRowCount()
-
getValueAt
public java.lang.Object getValueAt(int irow, int icol)
-
setValueAt
public void setValueAt(java.lang.Object value, int irow, int icol)
- Specified by:
setValueAt
in interfacejavax.swing.table.TableModel
- Overrides:
setValueAt
in classjavax.swing.table.AbstractTableModel
-
getColumnClass
public java.lang.Class getColumnClass(int icol)
- Specified by:
getColumnClass
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnClass
in classjavax.swing.table.AbstractTableModel
-
getColumnName
public java.lang.String getColumnName(int icol)
- Specified by:
getColumnName
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnName
in classjavax.swing.table.AbstractTableModel
-
isCellEditable
public boolean isCellEditable(int irow, int icol)
- Specified by:
isCellEditable
in interfacejavax.swing.table.TableModel
- Overrides:
isCellEditable
in classjavax.swing.table.AbstractTableModel
-
getColumnList
public java.util.List<MetaColumn> getColumnList()
Returns the list of columns which provide the data for this model. The list may be altered (but fire appropriate events if you do it on a live instance).- Returns:
- column list
-
canSort
public boolean canSort(MetaColumn sortCol)
Indicates whether the supplied column has a defined sort order.- Parameters:
sortCol
- column, not null- Returns:
- true iff sortCol can be sorted on
-
sortRows
public boolean sortRows(MetaColumn sortCol, boolean isDescending)
Reorders the rows of this table model based on the contents of one of its columns. This method does not inform listeners that the table data may have changed, so calling code should do that where appropriate. It only needs to do so if the return value of this method is true.- Parameters:
sortCol
- column to sort on, or null for natural orderingisDescending
- false to sort up, true to sort down- Returns:
- true if changes may have been made to the rows, false if no changes were made
-
getListIndex
public int getListIndex(int irow)
Returns the index in the natural row sequence for a row index in the table model.- Parameters:
irow
- table row index- Returns:
- list row index
-
-