1
2
3
4
5
6
7
8 package hoplugins.commons.ui.sorter;
9
10 import javax.swing.JLabel;
11 import javax.swing.JTable;
12 import javax.swing.table.TableCellRenderer;
13
14 import java.awt.Component;
15
16 /***
17 * DOCUMENT ME!
18 *
19 * @author
20 */
21 class SortableHeaderRenderer implements TableCellRenderer {
22 /*** TODO Missing Parameter Documentation */
23 private final AbstractTableSorter sorter;
24 private TableCellRenderer tableCellRenderer;
25
26 /***
27 * Creates a new SortableHeaderRenderer object.
28 *
29 * @param sorter
30 * @param tableCellRenderer
31 */
32 public SortableHeaderRenderer(AbstractTableSorter sorter,
33 TableCellRenderer tableCellRenderer) {
34 this.tableCellRenderer = tableCellRenderer;
35 this.sorter = sorter;
36 }
37
38 /***
39 * DOCUMENT ME!
40 *
41 * @return
42 */
43 public TableCellRenderer getTableCellRenderer() {
44 return tableCellRenderer;
45 }
46
47 /***
48 * DOCUMENT ME!
49 *
50 * @param table
51 * @param value
52 * @param isSelected
53 * @param hasFocus
54 * @param row
55 * @param column
56 *
57 * @return
58 */
59 public Component getTableCellRendererComponent(JTable table, Object value,
60 boolean isSelected, boolean hasFocus, int row, int column) {
61 Component c = tableCellRenderer.getTableCellRendererComponent(table,
62 value, isSelected, hasFocus, row, column);
63
64 if (c instanceof JLabel) {
65 JLabel l = (JLabel) c;
66
67 l.setHorizontalTextPosition(JLabel.LEFT);
68
69 int modelColumn = table.convertColumnIndexToModel(column);
70
71 l.setIcon(this.sorter.getHeaderRendererIcon(modelColumn,
72 l.getFont().getSize()));
73 }
74
75 return c;
76 }
77 }