Package uk.ac.starlink.util.gui
Class SortingHeaderRenderer
java.lang.Object
uk.ac.starlink.util.gui.SortingHeaderRenderer
- All Implemented Interfaces:
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
ConstructorsModifierConstructorDescriptionprotected
SortingHeaderRenderer
(TableCellRenderer baseRenderer) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic Icon
createArrowIcon
(boolean isDescending, int size) Returns an icon suitable for marking a column as sorted.Returns the renderer on which this one is based.abstract int
Indicates the index of the table column on which sorting is performed.getTableCellRendererComponent
(JTable table, Object value, boolean isSelected, boolean hasFocus, int irow, int icol) abstract boolean
Indicates the sense of the sorting.
-
Constructor Details
-
SortingHeaderRenderer
Constructor.- Parameters:
baseRenderer
- renderer on which this one is based
-
-
Method Details
-
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 interfaceTableCellRenderer
-
createArrowIcon
Returns an icon suitable for marking a column as sorted.- Parameters:
isDescending
- false for sort up, true for sort downsize
- icon size, for instance font size of associated text- Returns:
- icon
-