View Javadoc

1   // %1126721451416:hoplugins.trainingExperience.ui.model%
2   package hoplugins.trainingExperience.ui.model;
3   
4   import hoplugins.Commons;
5   
6   import hoplugins.commons.utils.PluginProperty;
7   
8   import hoplugins.trainingExperience.vo.TrainWeekEffect;
9   
10  import java.text.NumberFormat;
11  
12  import java.util.List;
13  
14  import javax.swing.table.AbstractTableModel;
15  
16  
17  /***
18   * TableModel representing the effect of training.
19   *
20   * @author NetHyperon
21   *
22   * @see hoplugins.trainingExperience.vo.TrainWeekEffect
23   */
24  public class EffectTableModel extends AbstractTableModel {
25      //~ Static fields/initializers -----------------------------------------------------------------
26  
27      /*** TODO Missing Parameter Documentation */
28      private static final NumberFormat FORMATTER = NumberFormat.getInstance();
29  
30      //~ Instance fields ----------------------------------------------------------------------------
31  
32      private List values;
33      private String[] colNames = new String[8];
34  
35      //~ Constructors -------------------------------------------------------------------------------
36  
37      /***
38       * Creates a new EffectTableModel object.
39       *
40       * @param values List of values to show in table.
41       */
42      public EffectTableModel(List values) {
43          super();
44  
45          FORMATTER.setMaximumFractionDigits(2);
46          FORMATTER.setMinimumFractionDigits(2);
47  
48          this.colNames[0] = PluginProperty.getString("Week"); //$NON-NLS-1$
49          this.colNames[1] = Commons.getModel().getResource().getProperty("Season"); //$NON-NLS-1$
50          this.colNames[2] = PluginProperty.getString("TSI"); //$NON-NLS-1$
51          this.colNames[3] = PluginProperty.getString("AVGTSI"); //$NON-NLS-1$
52          this.colNames[4] = PluginProperty.getString("TSI") + " +/-"; //$NON-NLS-1$ //$NON-NLS-2$
53          this.colNames[5] = PluginProperty.getString("AVGFORM"); //$NON-NLS-1$
54          this.colNames[6] = Commons.getModel().getResource().getProperty("Form") + " +/-"; //$NON-NLS-1$ //$NON-NLS-2$
55          this.colNames[7] = PluginProperty.getString("Skillups"); //$NON-NLS-1$
56  
57          this.values = values;
58      }
59  
60      //~ Methods ------------------------------------------------------------------------------------
61  
62      /***
63       * @see javax.swing.table.TableModel#getColumnCount()
64       */
65      public int getColumnCount() {
66          return colNames.length;
67      }
68  
69      /***
70       * @see javax.swing.table.TableModel#getColumnName(int)
71       */
72      public String getColumnName(int column) {
73          return colNames[column];
74      }
75  
76      /***
77       * @see javax.swing.table.TableModel#getRowCount()
78       */
79      public int getRowCount() {
80          return values.size();
81      }
82  
83      /***
84       * @see javax.swing.table.TableModel#getValueAt(int, int)
85       */
86      public Object getValueAt(int rowIndex, int columnIndex) {
87          TrainWeekEffect effect = (TrainWeekEffect) values.get(rowIndex);
88  
89          switch (columnIndex) {
90              case 0:
91                  return Integer.toString(effect.getHattrickWeek());
92  
93              case 1:
94                  return Integer.toString(effect.getHattrickSeason());
95  
96              case 2:
97                  return Integer.toString(effect.getTotalTSI());
98  
99              case 3:
100                 return Integer.toString(effect.getAverageTSI());
101 
102             case 4:
103                 return "+" + effect.getTSIIncrease() + " / " //$NON-NLS-1$ //$NON-NLS-2$
104                        + effect.getTSIDecrease();
105 
106             case 5:
107                 return FORMATTER.format(effect.getAverageForm());
108 
109             case 6:
110                 return "+" + effect.getFormIncrease() + " / " //$NON-NLS-1$ //$NON-NLS-2$
111                        + effect.getFormDecrease();
112 
113             case 7:
114                 return Integer.toString(effect.getAmountSkillups());
115 
116             default:
117                 return ""; //$NON-NLS-1$
118         }
119     }
120 }