# Class MetaColumnTableSorter

java.lang.Object
uk.ac.starlink.topcat.MetaColumnTableSorter

public class MetaColumnTableSorter extends Object
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
Constructor
Description
`MetaColumnTableSorter(MetaColumnTableModel model)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`int`
`getSortIndex()`
Returns the index of the column on which sorting is in effect.
`JComponent`
`getUnsortLabel()`
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`
`isDescending()`
Returns sort sense.
`void`
`setSorting(int icol, boolean descending)`
Instructs this sorter to keep the table model sorted according to a given column.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### MetaColumnTableSorter

public MetaColumnTableSorter(MetaColumnTableModel model)
Constructor.

Parameters:
  `model` - the model whose sorting this sorter orchestrates

## Method Details

### install

public void install(JTableHeader header)
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

public JComponent 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 sorting
  `descending` - 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