View Javadoc

1   // %3338167864:hoplugins.teamAnalyzer.ui%
2   package hoplugins.teamAnalyzer.ui;
3   
4   import hoplugins.Commons;
5   
6   import java.awt.Color;
7   import java.awt.Component;
8   import java.awt.Font;
9   
10  import javax.swing.JTable;
11  import javax.swing.table.DefaultTableCellRenderer;
12  
13  
14  /***
15   * TODO Missing Class Documentation
16   *
17   * @author TODO Author Name
18   */
19  public class RecapTableRenderer extends DefaultTableCellRenderer {
20      //~ Methods ------------------------------------------------------------------------------------
21  
22      /*
23       * (non-Javadoc)
24       *
25       * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable,
26       *      java.lang.Object, boolean, boolean, int, int)
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          // Is this 'average' or 'no matches' row?
33          if ((row == 0) && ((table.getRowCount() > 1) || (table.getValueAt(0, 1) == null))) {
34              Font nFont = new Font(this.getFont().getFontName(), Font.BOLD, this.getFont().getSize());
35  
36              this.setFont(nFont);
37              this.setBackground(UIColors.SelectedRowColor);
38              this.setIcon(null);
39          } else {
40              int matchType = 0;
41              boolean isHomeMatch = true;
42  
43              try {
44                  matchType = ((Integer) table.getValueAt(row, 20)).intValue();
45                  isHomeMatch = ((Boolean) table.getValueAt(row, 21)).booleanValue();
46                  this.setBackground(UIColors.getColor4Matchtyp(matchType));
47              } catch (Exception e) {
48                  // Make the exception visible.
49                  this.setBackground(Color.RED);
50                  this.setText("!!!"); //$NON-NLS-1$
51                  this.setToolTipText(e.toString());
52  
53                  return this;
54              }
55  
56              switch (column) {
57                  case 1:
58  
59                      // Set icon for match type.
60                      this.setIcon(Commons.getModel().getHelper().getImageIcon4Spieltyp(matchType));
61                      this.setText(null);
62  
63                      StringBuffer tipText = new StringBuffer(Commons.getModel().getHelper()
64                                                                     .getNameForMatchTyp(matchType));
65  
66                      tipText.append(" - "); //$NON-NLS-1$
67  
68                      if (isHomeMatch) {
69                          tipText.append(Commons.getModel().getResource().getProperty("Heim")); //$NON-NLS-1$
70                      } else {
71                          tipText.append(Commons.getModel().getResource().getProperty("Gast")); //$NON-NLS-1$
72                      }
73  
74                      this.setToolTipText(tipText.toString());
75  
76                      break;
77  
78                  default:
79                      this.setToolTipText(null);
80                      this.setIcon(null);
81              }
82          }
83  
84          if (isSelected) {
85              this.setBackground(UIColors.RecapRowColor);
86          }
87  
88          return this;
89      }
90  }