1
2
3
4
5
6
7
8 package hoplugins.seriesstats.ui;
9
10 import hoplugins.Commons;
11 import hoplugins.SeriesStats;
12
13 import hoplugins.seriesstats.Colors;
14 import hoplugins.seriesstats.LegendeCheckBox;
15
16 import java.awt.BorderLayout;
17 import java.awt.Color;
18 import java.awt.GridBagConstraints;
19 import java.awt.GridBagLayout;
20 import java.awt.Insets;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23
24 import java.util.Collections;
25 import java.util.Enumeration;
26 import java.util.HashMap;
27 import java.util.Map;
28 import java.util.Vector;
29
30 import javax.swing.JComboBox;
31 import javax.swing.JPanel;
32
33
34 /***
35 * DOCUMENT ME!
36 *
37 * @author Mirtillo To change the template for this generated type comment go to
38 * Window>Preferences>Java>Code Generation>Code and Comments
39 */
40 public class LegendaPanel extends JPanel implements ActionListener {
41
42
43 private JComboBox JCBDivision;
44 private JComboBox JCBTeam;
45 private JComboBox JCBType;
46 private Map MapDivisions;
47 private Map MapTeams;
48 private RefreshablePanel refreshablePanel;
49 private LegendeCheckBox[] LCBGeneral;
50
51
52
53 /***
54 * Creates a new LegendaPanel object.
55 *
56 * @param tab TODO Missing Constructuor Parameter Documentation
57 * @param isTeam TODO Missing Constructuor Parameter Documentation
58 */
59 public LegendaPanel(RefreshablePanel tab, boolean isTeam) {
60 this.refreshablePanel = tab;
61
62 LCBGeneral = new LegendeCheckBox[10];
63 LCBGeneral[0] = new hoplugins.seriesstats.LegendeCheckBox(Commons.getModel().getResource()
64 .getProperty("Hilflinien"));
65 LCBGeneral[0].aAL(this);
66 LCBGeneral[1] = new hoplugins.seriesstats.LegendeCheckBox(Commons.getModel().getResource()
67 .getProperty("Beschriftung"));
68 LCBGeneral[1].aAL(this);
69 LCBGeneral[2] = new hoplugins.seriesstats.LegendeCheckBox(Commons.getModel().getResource()
70 .getProperty("Bewertung"),
71 Colors.Black);
72 LCBGeneral[2].aAL(this);
73 LCBGeneral[3] = new hoplugins.seriesstats.LegendeCheckBox(Commons.getModel().getResource()
74 .getProperty("MatchMittelfeld"),
75 Colors.Yellow);
76 LCBGeneral[3].aAL(this);
77 LCBGeneral[4] = new hoplugins.seriesstats.LegendeCheckBox(Commons.getModel().getResource()
78 .getProperty("rechteAbwehrseite"),
79 Colors.Green.darker());
80 LCBGeneral[4].aAL(this);
81 LCBGeneral[5] = new hoplugins.seriesstats.LegendeCheckBox(Commons.getModel().getResource()
82 .getProperty("Abwehrzentrum"),
83 Colors.Blue);
84 LCBGeneral[5].aAL(this);
85 LCBGeneral[6] = new hoplugins.seriesstats.LegendeCheckBox(Commons.getModel().getResource()
86 .getProperty("linkeAbwehrseite"),
87 Colors.Green.brighter());
88 LCBGeneral[6].aAL(this);
89 LCBGeneral[7] = new hoplugins.seriesstats.LegendeCheckBox(Commons.getModel().getResource()
90 .getProperty("rechteAngriffsseite"),
91 Colors.Orange.darker());
92 LCBGeneral[7].aAL(this);
93 LCBGeneral[8] = new hoplugins.seriesstats.LegendeCheckBox(Commons.getModel().getResource()
94 .getProperty("Angriffszentrum"),
95 Colors.Red);
96 LCBGeneral[8].aAL(this);
97 LCBGeneral[9] = new hoplugins.seriesstats.LegendeCheckBox(Commons.getModel().getResource()
98 .getProperty("linkeAngriffsseite"),
99 Colors.Orange.brighter());
100 LCBGeneral[9].aAL(this);
101
102 JPanel d1 = Commons.getModel().getGUI().createImagePanel();
103
104
105 GridBagLayout gridbaglayout1 = new GridBagLayout();
106 GridBagConstraints gridbagconstraints1 = new GridBagConstraints();
107 gridbagconstraints1.fill = GridBagConstraints.HORIZONTAL;
108 gridbagconstraints1.weightx = 0.5;
109 gridbagconstraints1.weighty = 0.1;
110 gridbagconstraints1.anchor = GridBagConstraints.PAGE_START;
111 gridbagconstraints1.insets = new Insets(2, 2, 2, 2);
112 gridbagconstraints1.gridx = 0;
113 gridbagconstraints1.gridy = 0;
114 gridbagconstraints1.gridwidth = 2;
115 d1.setLayout(gridbaglayout1);
116
117 gridbagconstraints1.gridx = 0;
118 gridbagconstraints1.gridy = 2;
119 gridbagconstraints1.gridwidth = 2;
120 JCBDivision = new JComboBox();
121 JCBDivision.addActionListener(this);
122 gridbaglayout1.setConstraints(JCBDivision, gridbagconstraints1);
123 d1.add(JCBDivision);
124
125 gridbagconstraints1.gridx = 0;
126 gridbagconstraints1.gridy = 3;
127 gridbagconstraints1.gridwidth = 2;
128 JCBType = new JComboBox();
129 JCBType.addActionListener(this);
130 JCBTeam = new JComboBox();
131 JCBTeam.addActionListener(this);
132
133 if (isTeam) {
134 gridbaglayout1.setConstraints(JCBTeam, gridbagconstraints1);
135 d1.add(JCBTeam);
136 } else {
137 gridbaglayout1.setConstraints(JCBType, gridbagconstraints1);
138 d1.add(JCBType);
139 }
140
141 gridbagconstraints1.gridwidth = 2;
142 gridbagconstraints1.gridx = 0;
143 gridbagconstraints1.gridy = 5;
144 LCBGeneral[0].setOpaque(false);
145 LCBGeneral[0].setBackground(Color.white);
146 gridbaglayout1.setConstraints(LCBGeneral[0], gridbagconstraints1);
147 d1.add(LCBGeneral[0]);
148
149 gridbagconstraints1.gridwidth = 2;
150 gridbagconstraints1.gridx = 0;
151 gridbagconstraints1.gridy = 6;
152 LCBGeneral[1].setOpaque(false);
153 LCBGeneral[1].setBackground(Color.white);
154 gridbaglayout1.setConstraints(LCBGeneral[1], gridbagconstraints1);
155 d1.add(LCBGeneral[1]);
156
157 gridbagconstraints1.gridwidth = 2;
158 gridbagconstraints1.gridx = 0;
159 gridbagconstraints1.gridy = 7;
160 LCBGeneral[2].setOpaque(false);
161 gridbaglayout1.setConstraints(LCBGeneral[2], gridbagconstraints1);
162 d1.add(LCBGeneral[2]);
163
164 gridbagconstraints1.gridwidth = 2;
165 gridbagconstraints1.gridx = 0;
166 gridbagconstraints1.gridy = 8;
167 LCBGeneral[3].setOpaque(false);
168 gridbaglayout1.setConstraints(LCBGeneral[3], gridbagconstraints1);
169 d1.add(LCBGeneral[3]);
170
171 gridbagconstraints1.gridwidth = 2;
172 gridbagconstraints1.gridx = 0;
173 gridbagconstraints1.gridy = 9;
174 LCBGeneral[4].setOpaque(false);
175 gridbaglayout1.setConstraints(LCBGeneral[4], gridbagconstraints1);
176 d1.add(LCBGeneral[4]);
177
178 gridbagconstraints1.gridwidth = 2;
179 gridbagconstraints1.gridx = 0;
180 gridbagconstraints1.gridy = 10;
181 LCBGeneral[5].setOpaque(false);
182 gridbaglayout1.setConstraints(LCBGeneral[5], gridbagconstraints1);
183 d1.add(LCBGeneral[5]);
184
185 gridbagconstraints1.gridwidth = 2;
186 gridbagconstraints1.gridx = 0;
187 gridbagconstraints1.gridy = 11;
188 LCBGeneral[6].setOpaque(false);
189 gridbaglayout1.setConstraints(LCBGeneral[6], gridbagconstraints1);
190 d1.add(LCBGeneral[6]);
191
192 gridbagconstraints1.gridwidth = 2;
193 gridbagconstraints1.gridx = 0;
194 gridbagconstraints1.gridy = 12;
195 LCBGeneral[7].setOpaque(false);
196 gridbaglayout1.setConstraints(LCBGeneral[7], gridbagconstraints1);
197 d1.add(LCBGeneral[7]);
198
199 gridbagconstraints1.gridwidth = 2;
200 gridbagconstraints1.gridx = 0;
201 gridbagconstraints1.gridy = 13;
202 LCBGeneral[8].setOpaque(false);
203 gridbaglayout1.setConstraints(LCBGeneral[8], gridbagconstraints1);
204 d1.add(LCBGeneral[8]);
205
206 gridbagconstraints1.gridwidth = 2;
207 gridbagconstraints1.gridx = 0;
208 gridbagconstraints1.gridy = 14;
209 LCBGeneral[9].setOpaque(false);
210 gridbaglayout1.setConstraints(LCBGeneral[9], gridbagconstraints1);
211 d1.add(LCBGeneral[9]);
212 setLayout(new BorderLayout());
213 add(d1, BorderLayout.CENTER);
214
215 RefreshDivisionBox();
216 RefreshTeamBox();
217 RefreshTypeBox();
218 }
219
220
221
222 /***
223 * TODO Missing Method Documentation
224 *
225 * @param event TODO Missing Method Parameter Documentation
226 */
227 public void actionPerformed(ActionEvent event) {
228 if (event.getSource().equals(JCBDivision)) {
229 RefreshTeamBox();
230 RefreshTypeBox();
231 }
232
233 refreshablePanel.refresh();
234 }
235
236 /***
237 * TODO Missing Method Documentation
238 */
239 private void RefreshDivisionBox() {
240 try {
241 MapDivisions = new HashMap();
242 JCBDivision.removeActionListener(this);
243
244
245 JCBDivision.removeAllItems();
246
247
248 plugins.ISpielplan[] divisions = Commons.getModel().getSpielplaene();
249
250
251 for (int i = 0; i < divisions.length; i++) {
252 Vector LigaSeas = new Vector();
253
254
255 LigaSeas.add(new Integer(divisions[i].getLigaId()));
256
257
258 LigaSeas.add(new Integer(divisions[i].getSaison()));
259
260 String LigaString = prepareLigaString(divisions[i].getSaison(),
261 divisions[i].getLigaName(),
262 divisions[i].getLigaId());
263 this.JCBDivision.addItem(LigaString);
264
265 this.MapDivisions.put(new String(LigaString), LigaSeas);
266 }
267
268 JCBDivision.setSelectedItem(prepareLigaString(Commons.getModel().getBasics().getSeason(),
269 Commons.getModel().getLiga().getLiga(),
270 Commons.getModel().getBasics().getLiga()));
271
272 JCBDivision.addActionListener(this);
273 } catch (Exception e) {
274 if (true) {
275 SeriesStats.getIDB().append("---ooo---");
276 SeriesStats.getIDB().append(e);
277 }
278 }
279 }
280
281 /***
282 * TODO Missing Method Documentation
283 */
284 private void RefreshTeamBox() {
285 try {
286 MapTeams = new HashMap();
287 this.JCBTeam.removeActionListener(this);
288
289
290 this.JCBTeam.removeAllItems();
291
292
293 Vector LigaSeas = (Vector) this.MapDivisions.get((String) this.JCBDivision
294 .getSelectedItem());
295
296
297 plugins.ITabellenVerlaufEintrag[] dummy = Commons.getModel()
298 .getSpielplan(((Integer) LigaSeas.get(0))
299 .intValue(),
300 ((Integer) LigaSeas.get(1))
301 .intValue()).getVerlauf()
302 .getEintraege();
303
304
305 Vector data = new Vector();
306
307 for (int i = 0; i < dummy.length; i++) {
308 this.MapTeams.put(new String(dummy[i].getTeamName()),
309 new Integer(dummy[i].getTeamId()));
310 data.add(new String(dummy[i].getTeamName()));
311 }
312
313 Collections.sort(data);
314
315
316 for (Enumeration e = data.elements(); e.hasMoreElements();) {
317 String TeamName = (String) e.nextElement();
318 this.JCBTeam.addItem(TeamName);
319 }
320
321 this.JCBTeam.addActionListener(this);
322 } catch (Exception e) {
323 if (true) {
324 SeriesStats.getIDB().append("---ooo---");
325 SeriesStats.getIDB().append(e);
326 }
327 }
328 }
329
330 /***
331 * TODO Missing Method Documentation
332 */
333 private void RefreshTypeBox() {
334 try {
335 this.JCBType.removeActionListener(this);
336
337
338 this.JCBType.removeAllItems();
339 this.JCBType.addItem("Average");
340
341 this.JCBType.addActionListener(this);
342 } catch (Exception e) {
343 if (true) {
344 SeriesStats.getIDB().append("---ooo---");
345 SeriesStats.getIDB().append(e);
346 }
347 }
348 }
349
350 /***
351 * TODO Missing Method Documentation
352 *
353 * @param s TODO Missing Method Parameter Documentation
354 * @param l TODO Missing Method Parameter Documentation
355 * @param lid TODO Missing Method Parameter Documentation
356 *
357 * @return TODO Missing Return Method Documentation
358 */
359 private String prepareLigaString(int s, String l, int lid) {
360 return Commons.getModel().getResource().getProperty("Season") + " " + s + " "
361 + Commons.getModel().getResource().getProperty("Liga") + " " + l + " (" + lid + ")";
362 }
363 }