Package noaa.coastwatch.gui
Class SortedTableModel
java.lang.Object
noaa.coastwatch.gui.SortedTableModel
- All Implemented Interfaces:
TableModel
A
SortedTableModel can be used to provide row
sorting services for any
javax.swing.table.TableModel. The new model
simply wraps the old one and translates row indicies through
the wrapper so as to make it appear that the table is sorted
according to the values held in a specific column of the
table.- Since:
- 3.2.1
- Author:
- Peter Hollemans
-
Constructor Summary
ConstructorsConstructorDescriptionSortedTableModel(TableModel model) Creates a sorted model using the specified unsorted model for its data. -
Method Summary
Modifier and TypeMethodDescriptionvoidintconvertRowIndexToModel(int row) Converts a row index in the sorted model to a row index in the underlying model.intconvertRowIndexToView(int row) Converts a row index in the underlying model to a row index in the sorted model.getColumnClass(int columnIndex) intgetColumnName(int columnIndex) booleanGets the current sorting order.intintGets the current sorting column, or -1 for no sorting.getValueAt(int rowIndex, int columnIndex) booleanisCellEditable(int rowIndex, int columnIndex) voidvoidsetSort(int sortColumn, boolean isAscending) Set the sorting column and order.voidsetValueAt(Object aValue, int rowIndex, int columnIndex)
-
Constructor Details
-
SortedTableModel
Creates a sorted model using the specified unsorted model for its data. The table is initially unsorted so that rows in the sorted table model are in exactly the same order as rows in the unsorted model.- Parameters:
model- the model to use for row and column data.
-
-
Method Details
-
setSort
public void setSort(int sortColumn, boolean isAscending) Set the sorting column and order.- Parameters:
sortColumn- the new sorting column, or -1 for no sorting.isAscending- the new sorting order, true for ascending.
-
getSortColumn
public int getSortColumn()Gets the current sorting column, or -1 for no sorting. -
getIsAscending
public boolean getIsAscending()Gets the current sorting order. -
convertRowIndexToModel
public int convertRowIndexToModel(int row) Converts a row index in the sorted model to a row index in the underlying model.- Parameters:
row- the row index to convert.- Returns:
- the row index in the underlying table model.
-
convertRowIndexToView
public int convertRowIndexToView(int row) Converts a row index in the underlying model to a row index in the sorted model.- Parameters:
row- the row index to convert.- Returns:
- the row index in the sorted table model.
-
getRowCount
public int getRowCount()- Specified by:
getRowCountin interfaceTableModel
-
getColumnCount
public int getColumnCount()- Specified by:
getColumnCountin interfaceTableModel
-
getColumnName
- Specified by:
getColumnNamein interfaceTableModel
-
getColumnClass
- Specified by:
getColumnClassin interfaceTableModel
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex) - Specified by:
isCellEditablein interfaceTableModel
-
getValueAt
- Specified by:
getValueAtin interfaceTableModel
-
setValueAt
- Specified by:
setValueAtin interfaceTableModel
-
addTableModelListener
- Specified by:
addTableModelListenerin interfaceTableModel
-
removeTableModelListener
- Specified by:
removeTableModelListenerin interfaceTableModel
-