1
2 package hoplugins.trainingExperience.ui.renderer;
3
4 import hoplugins.Commons;
5
6 import hoplugins.trainingExperience.constants.Skills;
7 import hoplugins.trainingExperience.ui.TrainingLegendPanel;
8
9 import java.awt.Color;
10 import java.awt.Component;
11
12 import javax.swing.Icon;
13 import javax.swing.JTable;
14 import javax.swing.table.DefaultTableCellRenderer;
15
16
17 /***
18 * Rendered for the TrainingRecap Table
19 *
20 * @author <a href=mailto:draghetto@users.sourceforge.net>Massimiliano Amato</a>
21 */
22 public class TrainingRecapRenderer extends DefaultTableCellRenderer {
23
24
25
26
27
28 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
29 boolean hasFocus, int row, int column) {
30 super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
31
32 this.setForeground(Color.BLACK);
33
34 String s = (String) table.getValueAt(row, column);
35 String[] skills = s.split(" ");
36 Icon icon = null;
37
38 this.setIcon(null);
39
40 try {
41 int skillType = Integer.parseInt(skills[0]);
42 Color color = Skills.getSkillColor(skillType);
43
44 this.setForeground(color);
45 icon = TrainingLegendPanel.getSkillupTypeIcon(skillType);
46 } catch (Exception e) {
47 }
48
49 try {
50 int val = Integer.parseInt(skills[1]);
51
52 this.setText(Commons.getModel().getHelper().getNameForSkill(val, true));
53 this.setIcon(icon);
54 } catch (Exception e1) {
55 }
56
57 return this;
58 }
59 }