Package uk.ac.starlink.topcat
Class MetaColumnTableSorter
java.lang.Object
uk.ac.starlink.topcat.MetaColumnTableSorter
Handles the GUI aspects of sorting a MetaColumnTableModel.
It provides the mouse listeners that set up sorting and
ensures that the sorting methods are called on the table model
as required to keep the row order up to date.
- Since:
- 15 Aug 2017
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the index of the column on which sorting is in effect.Returns a component that will display an indication of when the natural (unsorted) sequence is in use.void
install
(JTableHeader header) Sets this object up to allow sorting its model by clicking on a given JTable header.boolean
Returns sort sense.void
setSorting
(int icol, boolean descending) Instructs this sorter to keep the table model sorted according to a given column.
-
Constructor Details
-
MetaColumnTableSorter
Constructor.- Parameters:
model
- the model whose sorting this sorter orchestrates
-
-
Method Details
-
install
Sets this object up to allow sorting its model by clicking on a given JTable header. Currently only one header can be installed at a time. You can uninstall it by calling this method with a null argument.- Parameters:
header
- table header component
-
getUnsortLabel
Returns a component that will display an indication of when the natural (unsorted) sequence is in use. Clicking on this component will cause natural order to resume.- Returns:
- small label indicating unsortedness
-
setSorting
public void setSorting(int icol, boolean descending) Instructs this sorter to keep the table model sorted according to a given column. If no sort order is defined for the requested column, nothing happens.- Parameters:
icol
- sort column index, or -1 for no sortingdescending
- true for descending sequence, false for ascending; ignored for no sort column
-
getSortIndex
public int getSortIndex()Returns the index of the column on which sorting is in effect.- Returns:
- index of column in this sorter's table model on which sorting is being performed, or -1 for natural order
-
isDescending
public boolean isDescending()Returns sort sense. Irrelevant if no sort column.- Returns:
- true for descending, false for ascending
-