View Javadoc

1   // %1126721451729:hoplugins.trainingExperience.ui%
2   package hoplugins.trainingExperience.ui;
3   
4   import hoplugins.commons.ui.DefaultTableSorter;
5   import hoplugins.trainingExperience.ui.bar.VerticalIndicator;
6   import hoplugins.trainingExperience.ui.model.OutputTableModel;
7   
8   import javax.swing.table.TableModel;
9   
10  import java.util.Comparator;
11  
12  /***
13   * Output Table custom sorter
14   *
15   * @author <a href=mailto:draghetto@users.sourceforge.net>Massimiliano Amato</a>
16   */
17  public class OutputTableSorter extends DefaultTableSorter
18  {
19      /***
20  * Creates a new OutputTableSorter object.
21  *
22  * @param tableModel
23  */
24      public OutputTableSorter(TableModel tableModel)
25      {
26          super(tableModel);
27      }
28  
29      /***
30  * Custom Comparator
31  *
32  * @param column column to compare
33  *
34  * @return comparator
35  */
36      public Comparator getCustomComparator(int column)
37      {
38          if ((column > 2) && (column < 11))
39          {
40              return new Comparator()
41                  {
42                      public boolean equals(Object arg0)
43                      {
44                          return false;
45                      }
46  
47                      public int compare(Object arg0, Object arg1)
48                      {
49                          VerticalIndicator v1 = (VerticalIndicator) arg0;
50                          VerticalIndicator v2 = (VerticalIndicator) arg1;
51  
52                          if (v1.getPercentage() > v2.getPercentage())
53                          {
54                              return 1;
55                          }
56  
57                          if (v1.getPercentage() < v2.getPercentage())
58                          {
59                              return -1;
60                          }
61  
62                          if (v1.getTotal() > v2.getTotal())
63                          {
64                              return -1;
65                          }
66  
67                          if (v1.getTotal() < v2.getTotal())
68                          {
69                              return 1;
70                          }
71  
72                          return 0;
73                      }
74                  };
75          }
76  
77          return null;
78      }
79  
80      /***
81  * DOCUMENT ME!
82  *
83  * @param rowIndex
84  * @param columnIndex
85  *
86  * @return tooltip
87  */
88      public Object getToolTipAt(int rowIndex, int columnIndex)
89      {
90          OutputTableModel ttm = (OutputTableModel) tableModel;
91  
92          return ttm.getToolTipAt(rowIndex, columnIndex);
93      }
94  
95      /***
96  * Fill Table with Data
97  */
98      public void fillWithData()
99      {
100         OutputTableModel ttm = (OutputTableModel) tableModel;
101 
102         ttm.fillWithData();
103     }
104 }