# Class SortingHeaderRenderer

java.lang.Object
uk.ac.starlink.util.gui.SortingHeaderRenderer

All Implemented Interfaces:
  `TableCellRenderer`

public abstract class SortingHeaderRenderer extends Object implements TableCellRenderer
Renderer for JTable (header) cells that can indicate sorting status. It modifies a supplied default renderer by adding a little arrow pointing up or down for the single sorted column in a table as reported by a couple of abstract methods.

Since:
  15 Aug 2017
Author:
  Mark Taylor

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`SortingHeaderRenderer(TableCellRenderer baseRenderer)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static Icon`
`createArrowIcon(boolean isDescending, int size)`
Returns an icon suitable for marking a column as sorted.
`TableCellRenderer`
`getBaseRenderer()`
Returns the renderer on which this one is based.
`abstract int`
`getSortColumnIndex()`
Indicates the index of the table column on which sorting is performed.
`Component`
`getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int irow, int icol)`
`abstract boolean`
`isSortDescending()`
Indicates the sense of the sorting.

### Methods inherited from class Object

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

## Constructor Details

### SortingHeaderRenderer

protected SortingHeaderRenderer(TableCellRenderer baseRenderer)
Constructor.

Parameters:
  `baseRenderer` - renderer on which this one is based

## Method Details

### getBaseRenderer

public TableCellRenderer getBaseRenderer()
Returns the renderer on which this one is based.

Returns:
  base renderer

### getSortColumnIndex

public abstract int getSortColumnIndex()
Indicates the index of the table column on which sorting is performed. If the table is unsorted (uses natural order) this method should return a negative number.

Returns:
  index of sorting column, or negative value

### isSortDescending

public abstract boolean isSortDescending()
Indicates the sense of the sorting.

Returns:
  true for descending sort, false for ascending

### getTableCellRendererComponent

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int irow, int icol)

Specified by:
  `getTableCellRendererComponent` in interface `TableCellRenderer`

### createArrowIcon

public static Icon createArrowIcon(boolean isDescending, int size)
Returns an icon suitable for marking a column as sorted.

Parameters:
  `isDescending` - false for sort up, true for sort down
  `size` - icon size, for instance font size of associated text
Returns:
  icon