1
2 package hoplugins.teamAnalyzer.ui;
3
4 import hoplugins.Commons;
5
6 import hoplugins.commons.utils.PluginProperty;
7 import hoplugins.commons.utils.RatingUtil;
8
9 import hoplugins.teamAnalyzer.SystemManager;
10 import hoplugins.teamAnalyzer.ui.model.UiRatingTableModel;
11 import hoplugins.teamAnalyzer.vo.TeamLineup;
12
13 import java.awt.BorderLayout;
14
15 import java.util.Arrays;
16 import java.util.Vector;
17
18 import javax.swing.JPanel;
19 import javax.swing.JScrollPane;
20 import javax.swing.JTable;
21
22
23 /***
24 * TODO Missing Class Documentation
25 *
26 * @author TODO Author Name
27 */
28 public class RatingPanel extends JPanel {
29
30
31 private JTable table;
32 private UiRatingTableModel tableModel;
33 private String[] columns = {
34 PluginProperty.getString("RatingPanel.Area"),
35 Commons.getModel().getResource().getProperty("Bewertung"),
36 Commons.getModel().getResource().getProperty("Differenz_kurz"),
37 };
38
39
40
41 /***
42 * Creates a new RatingPanel object.
43 */
44 public RatingPanel() {
45 jbInit();
46 }
47
48
49
50 /***
51 * TODO Missing Method Documentation
52 *
53 * @param lineup TODO Missing Method Parameter Documentation
54 */
55 public void reload(TeamLineup lineup) {
56 tableModel = new UiRatingTableModel(new Vector(), new Vector(Arrays.asList(columns)));
57 table.setModel(tableModel);
58
59 if ((lineup == null) || (!SystemManager.getConfig().isLineup())) {
60 return;
61 }
62
63 TeamLineupData myTeam = SystemManager.getPlugin().getMainPanel().getMyTeamLineupPanel();
64 TeamLineupData opponentTeam = SystemManager.getPlugin().getMainPanel()
65 .getOpponentTeamLineupPanel();
66
67 tableModel.addRow(getRow(Commons.getModel().getResource().getProperty("MatchMittelfeld"),
68 myTeam.getMidfield(), opponentTeam.getMidfield()));
69 tableModel.addRow(getRow(Commons.getModel().getResource().getProperty("rechteAbwehrseite"),
70 myTeam.getRightDefence(), opponentTeam.getLeftAttack()));
71 tableModel.addRow(getRow(Commons.getModel().getResource().getProperty("Abwehrzentrum"),
72 myTeam.getMiddleDefence(), opponentTeam.getMiddleAttack()));
73 tableModel.addRow(getRow(Commons.getModel().getResource().getProperty("linkeAbwehrseite"),
74 myTeam.getLeftDefence(), opponentTeam.getRightAttack()));
75 tableModel.addRow(getRow(Commons.getModel().getResource().getProperty("rechteAngriffsseite"),
76 myTeam.getRightAttack(), opponentTeam.getLeftDefence()));
77 tableModel.addRow(getRow(Commons.getModel().getResource().getProperty("Angriffszentrum"),
78 myTeam.getMiddleAttack(), opponentTeam.getMiddleDefence()));
79 tableModel.addRow(getRow(Commons.getModel().getResource().getProperty("linkeAngriffsseite"),
80 myTeam.getLeftAttack(), opponentTeam.getRightDefence()));
81
82 table.getTableHeader().getColumnModel().getColumn(0).setWidth(130);
83 table.getTableHeader().getColumnModel().getColumn(0).setPreferredWidth(130);
84 table.getTableHeader().getColumnModel().getColumn(1).setWidth(100);
85 table.getTableHeader().getColumnModel().getColumn(1).setPreferredWidth(100);
86 }
87
88 /***
89 * TODO Missing Method Documentation
90 *
91 * @param rating TODO Missing Method Parameter Documentation
92 *
93 * @return TODO Missing Return Method Documentation
94 */
95 private String getRating(int rating) {
96 return RatingUtil.getRating(rating, SystemManager.getConfig().isNumericRating(),
97 SystemManager.getConfig().isDescriptionRating(),
98 Commons.getModel());
99 }
100
101 /***
102 * TODO Missing Method Documentation
103 *
104 * @param label TODO Missing Method Parameter Documentation
105 * @param myRating TODO Missing Method Parameter Documentation
106 * @param opponentRating TODO Missing Method Parameter Documentation
107 *
108 * @return TODO Missing Return Method Documentation
109 */
110 private Vector getRow(String label, double myRating, double opponentRating) {
111 Vector rowData = new Vector();
112
113 rowData.add(label);
114 rowData.add("" + getRating((int) myRating));
115
116 int diff = (int) myRating - (int) opponentRating;
117
118 rowData.add(Commons.getModel().getHelper().getImageIcon4Veraenderung(diff));
119
120 return rowData;
121 }
122
123 /***
124 * TODO Missing Method Documentation
125 */
126 private void jbInit() {
127 Vector data = new Vector();
128
129
130 tableModel = new UiRatingTableModel(data, new Vector(Arrays.asList(columns)));
131 table = new JTable(tableModel);
132 setLayout(new BorderLayout());
133
134 JScrollPane scrollPane = new JScrollPane(table);
135
136 scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
137 scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
138
139
140 add(scrollPane);
141 }
142 }