View Javadoc

1   // %3062152101:hoplugins.teamAnalyzer.ui%
2   package hoplugins.teamAnalyzer.ui;
3   
4   import hoplugins.Commons;
5   
6   import hoplugins.teamAnalyzer.SystemManager;
7   import hoplugins.teamAnalyzer.manager.PlayerDataManager;
8   import hoplugins.teamAnalyzer.vo.PlayerInfo;
9   
10  import java.awt.Color;
11  import java.awt.Component;
12  
13  import javax.swing.ImageIcon;
14  import javax.swing.JLabel;
15  import javax.swing.JTable;
16  import javax.swing.table.DefaultTableCellRenderer;
17  
18  
19  /***
20   * TODO Missing Class Documentation
21   *
22   * @author TODO Author Name
23   */
24  public class RosterTableRenderer extends DefaultTableCellRenderer {
25      //~ Methods ------------------------------------------------------------------------------------
26  
27      /*
28       * (non-Javadoc)
29       *
30       * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable,
31       *      java.lang.Object, boolean, boolean, int, int)
32       */
33      public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
34                                                     boolean hasFocus, int row, int column) {
35          super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
36  
37          try {
38              // setBackground(Color.WHITE);
39              setOpaque(true);
40              setToolTipText(null);
41              setIcon(null);
42  
43              if (isSelected) {
44                  // this.setBackground(Color.LIGHT_GRAY);
45              }
46  
47              if (column > 3) {
48                  setHorizontalAlignment(JLabel.CENTER);
49              } else {
50                  setHorizontalAlignment(JLabel.LEFT);
51              }
52  
53              if (column == 9) {
54                  int v = Integer.parseInt((String) value);
55                  ImageIcon icon = Commons.getModel().getHelper().getImageIcon4Spezialitaet(v);
56                  setIcon(icon);
57                  setText("");
58                  return this;
59              }
60  
61              int status = Integer.parseInt("" + table.getModel().getValueAt(row, 13));
62  
63              switch (status) {
64                  case PlayerDataManager.INJURED:
65                      setForeground(Color.RED);
66                      break;
67  
68                  case PlayerDataManager.SUSPENDED:
69                      setForeground(Color.RED);
70                      break;
71  
72                  case PlayerDataManager.SOLD:
73                      setForeground(Color.BLUE);
74                      break;
75  
76                  default:
77                      setForeground(Color.BLACK);
78                      break;
79              }
80  
81              /*
82                 int pos = ((Integer) table.getValueAt(row, 2)).intValue();
83                 int posCode = Commons.getModel().getHelper().getPosition(pos);
84                 switch (posCode) {
85                 case ISpielerPosition.keeper:
86                     setForeground(Color.BLACK);
87                     break;
88                 case ISpielerPosition.insideBack1:
89                     setForeground(Color.BLUE.darker().darker());
90                     break;
91                 case ISpielerPosition.leftBack:
92                     setForeground(Color.GREEN.darker().darker());
93                     break;
94                 case ISpielerPosition.insideMid1:
95                     setForeground(Color.YELLOW.darker().darker());
96                     break;
97                 case ISpielerPosition.leftWinger:
98                     setForeground(Color.ORANGE.darker().darker());
99                     break;
100                case ISpielerPosition.forward1:
101                    setForeground(Color.RED.darker().darker());
102                    break;
103                }
104              */
105             int playerId = Integer.parseInt("" + table.getModel().getValueAt(row, 14));
106             PlayerInfo oldInfo = SystemManager.getPlugin().getMainPanel().getRosterPanel()
107                                               .getPrevious(playerId);
108 
109             if (oldInfo.getPlayerId() == 0) {
110                 return this;
111             }
112 
113             switch (column) {
114                 case 6: {
115                     int v = Integer.parseInt("" + value);
116                     int diff = v - oldInfo.getForm();
117 
118                     if (Commons.getModel().getHelper().isDevVersion()) {
119                         setIcon(Commons.getModel().getHelper().getImageIcon4Veraenderung(diff));
120                     }
121 
122                     break;
123                 }
124 
125                 case 7: {
126                     int v = Integer.parseInt("" + value);
127                     int diff = v - oldInfo.getExperience();
128 
129                     if (Commons.getModel().getHelper().isDevVersion()) {
130                         setIcon(Commons.getModel().getHelper().getImageIcon4Veraenderung(diff));
131                     }
132 
133                     break;
134                 }
135 
136                 case 8: {
137                     int v = Integer.parseInt("" + value);
138                     int diff = v - oldInfo.getTSI();
139                     String desc = "";
140 
141                     if (Commons.getModel().getHelper().isDevVersion()) {
142                         if (diff > 0) {
143                             desc = "+";
144                         }
145 
146                         desc = desc + diff;
147                     }
148 
149                     setText(getText() + " " + desc);
150                     break;
151                 }
152             }
153         } catch (Exception e) {
154             setText("!!!"); //$NON-NLS-1$
155             setToolTipText(e.toString());
156         }
157 
158         return this;
159     }
160 }