01: /*
02: * Author: Chris Seguin
03: *
04: * This software has been developed under the copyleft
05: * rules of the GNU General Public License. Please
06: * consult the GNU General Public License for more
07: * details about use and distribution of this software.
08: */
09: package org.acm.seguin.metrics;
10:
11: import java.awt.Component;
12: import java.awt.Font;
13: import javax.swing.JLabel;
14: import javax.swing.JTable;
15: import javax.swing.SwingConstants;
16: import javax.swing.border.EmptyBorder;
17: import javax.swing.table.TableCellRenderer;
18:
19: /**
20: * Metrics table cell renderer
21: *
22: *@author Chris Seguin
23: *@created July 28, 1999
24: */
25: class MetricsTableCellRenderer implements TableCellRenderer {
26: Font headerFont;
27: Font normalFont;
28:
29: /**
30: * Constructor for the MetricsTableCellRenderer object
31: */
32: MetricsTableCellRenderer() {
33: headerFont = new Font("Serif", Font.BOLD, 14);
34: normalFont = new Font("Serif", Font.PLAIN, 14);
35: }
36:
37: /**
38: * Description of the Method
39: *
40: *@param table Description of Parameter
41: *@param value Description of Parameter
42: *@param isSelected Description of Parameter
43: *@param hasFocus Description of Parameter
44: *@param row Description of Parameter
45: *@param column Description of Parameter
46: *@return Description of the Returned Value
47: */
48: public Component getTableCellRendererComponent(JTable table,
49: Object value, boolean isSelected, boolean hasFocus,
50: int row, int column) {
51: JLabel label = new JLabel((String) value);
52: label.setBorder(new EmptyBorder(4, 10, 4, 10));
53:
54: if (row == 0) {
55: label.setFont(headerFont);
56: } else {
57: label.setFont(normalFont);
58: }
59:
60: if (row == 0) {
61: label.setHorizontalAlignment(SwingConstants.CENTER);
62: } else if (column == 1) {
63: label.setHorizontalAlignment(SwingConstants.RIGHT);
64: } else {
65: label.setHorizontalAlignment(SwingConstants.LEFT);
66: }
67:
68: return label;
69: }
70: }
|