Package adams.gui.core
Interface SortableTableModel
-
- All Superinterfaces:
TableModel
- All Known Implementing Classes:
SortableAndSearchableWrapperTableModel
public interface SortableTableModel extends TableModel
Interface for table models that are sortable.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
getActualRow(int visibleRow)
Returns the actual underlying row the given visible one represents.int
getDisplayRow(int internalRow)
Returns the "visible" row derived from row in the actual table model.int
getSortColumn()
Returns the sort column.TableModel
getUnsortedModel()
returns the underlying model, can be null.boolean
isAscending()
Returns whether sorting is ascending or not.boolean
isCaseSensitive()
Returns whether the sorting is case-sensitive.boolean
isSorted()
returns whether the table was sorted.void
setCaseSensitive(boolean value)
Sets whether the sorting is case-sensitive.void
setUnsortedModel(TableModel value)
Sets the base model to use.void
sort(int columnIndex)
sorts the table over the given column (ascending).void
sort(int columnIndex, boolean ascending)
sorts the table over the given column, either ascending or descending.-
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, removeTableModelListener, setValueAt
-
-
-
-
Method Detail
-
setUnsortedModel
void setUnsortedModel(TableModel value)
Sets the base model to use.- Parameters:
value
- the base model
-
getUnsortedModel
TableModel getUnsortedModel()
returns the underlying model, can be null.- Returns:
- the current model
-
setCaseSensitive
void setCaseSensitive(boolean value)
Sets whether the sorting is case-sensitive.- Parameters:
value
- true if case-sensitive
-
isCaseSensitive
boolean isCaseSensitive()
Returns whether the sorting is case-sensitive.- Returns:
- true if case-sensitive
-
isSorted
boolean isSorted()
returns whether the table was sorted.- Returns:
- true if the table was sorted
-
getSortColumn
int getSortColumn()
Returns the sort column.- Returns:
- the sort column
-
isAscending
boolean isAscending()
Returns whether sorting is ascending or not.- Returns:
- true if ascending
- See Also:
isSorted()
,getSortColumn()
-
getActualRow
int getActualRow(int visibleRow)
Returns the actual underlying row the given visible one represents. Useful for retrieving "non-visual" data that is also stored in a TableModel.- Parameters:
visibleRow
- the displayed row to retrieve the original row for- Returns:
- the original row
-
getDisplayRow
int getDisplayRow(int internalRow)
Returns the "visible" row derived from row in the actual table model.- Parameters:
internalRow
- the row in the actual model- Returns:
- the row in the sorted model, -1 in case of an error
-
sort
void sort(int columnIndex)
sorts the table over the given column (ascending).- Parameters:
columnIndex
- the column to sort over
-
sort
void sort(int columnIndex, boolean ascending)
sorts the table over the given column, either ascending or descending.- Parameters:
columnIndex
- the column to sort overascending
- ascending if true, otherwise descending
-
-