1
2
3
4
5
6
7
8 package hoplugins.trainingExperience.ui.renderer;
9
10 import hoplugins.trainingExperience.constants.Skills;
11
12 import plugins.ISkillup;
13
14 import java.awt.Color;
15 import java.awt.Component;
16
17 import javax.swing.JTable;
18 import javax.swing.table.DefaultTableCellRenderer;
19
20
21 /***
22 * DOCUMENT ME!
23 *
24 * @author Mirtillo To change the template for this generated type comment go to
25 * Window>Preferences>Java>Code Generation>Code and Comments
26 */
27 public class SkillupTableRenderer extends DefaultTableCellRenderer {
28
29
30
31
32
33 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
34 boolean hasFocus, int row, int column) {
35 Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
36 row, column);
37
38 int type = ISkillup.SKILLUP_REAL;
39
40 try {
41 type = Integer.parseInt((String) table.getValueAt(row, 3));
42 } catch (NumberFormatException e) {
43 }
44
45 if (type == ISkillup.SKILLUP_FUTURE) {
46 try {
47 int skill = Integer.parseInt((String) table.getValueAt(row, 5));
48
49 cell.setForeground(Skills.getSkillColor(skill));
50
51 return cell;
52 } catch (NumberFormatException e) {
53 cell.setForeground(Color.BLACK);
54 }
55 } else {
56 cell.setForeground(Color.BLACK);
57 }
58
59 return cell;
60 }
61 }