1
2 package hoplugins.teamAnalyzer.ui.renderer;
3
4 import hoplugins.Commons;
5
6 import plugins.IHelper;
7
8 import java.awt.Component;
9
10 import java.util.HashMap;
11 import java.util.Map;
12
13 import javax.swing.ImageIcon;
14 import javax.swing.JTable;
15 import javax.swing.table.DefaultTableCellRenderer;
16
17
18 /***
19 * DOCUMENT ME!
20 *
21 * @author Tommi Rautava <kenmooda
22 *
23 * @users.sourceforge.net>
24 */
25 public class PlayerPositionTableCellRenderer extends DefaultTableCellRenderer {
26
27
28 /*** TODO Missing Parameter Documentation */
29 private static final long serialVersionUID = 3258412837305923127L;
30 private static Map map;
31 private static IHelper helper;
32
33
34
35 /***
36 *
37 */
38 public PlayerPositionTableCellRenderer() {
39 super();
40
41 if (map == null) {
42 map = new HashMap();
43 }
44
45 if (helper == null) {
46 helper = Commons.getModel().getHelper();
47 }
48 }
49
50
51
52
53
54
55
56
57
58 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
59 boolean hasFocus, int row, int col) {
60 if (value instanceof Integer) {
61 super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, col);
62
63 int pos = ((Integer) value).intValue();
64
65 ImageIcon icon;
66
67
68 if (map.containsKey(value)) {
69 icon = (ImageIcon) map.get(value);
70 } else {
71
72 icon = Commons.getModel().getHelper().getImage4Position(helper.getPosition(pos),
73 (byte) 0);
74 map.put(value, icon);
75 }
76
77 this.setIcon(icon);
78 this.setText(helper.getNameForPosition((byte) pos));
79 } else {
80 this.setIcon(null);
81 this.setText(null);
82 super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
83 }
84
85 return this;
86 }
87 }