View Javadoc

1   // %4118680904:hoplugins.teamAnalyzer.ui.lineup%
2   package hoplugins.teamAnalyzer.ui.lineup;
3   
4   import java.awt.Color;
5   import java.awt.Font;
6   import java.awt.GridBagConstraints;
7   import java.awt.GridBagLayout;
8   
9   import javax.swing.JLabel;
10  import javax.swing.JPanel;
11  
12  
13  /***
14   * An abstract Lineup jpanel
15   *
16   * @author <a href=mailto:draghetto@users.sourceforge.net>Massimiliano Amato</a>
17   */
18  public abstract class LineupStylePanel extends JPanel {
19      //~ Instance fields ----------------------------------------------------------------------------
20  
21      /*** The main formation panel */
22      protected FormationPanel mainPanel;
23  
24      /*** GridBag Constraints */
25      protected GridBagConstraints constraints = new GridBagConstraints();
26  
27      /*** GridBag layout */
28      protected GridBagLayout layout = new GridBagLayout();
29  
30      /*** The main panel */
31      protected JPanel centerPanel = new javax.swing.JPanel();
32  
33      //~ Constructors -------------------------------------------------------------------------------
34  
35      /***
36       * Constructor
37       *
38       * @param _mainPanel the main formation panel
39       */
40      public LineupStylePanel(FormationPanel _mainPanel) {
41          super();
42          mainPanel = _mainPanel;
43      }
44  
45      //~ Methods ------------------------------------------------------------------------------------
46  
47      /***
48       * Sets the layout for 2 teams  displayed
49       */
50      public abstract void initCompare();
51  
52      /***
53       * Sets the layout for only 1 team displayed
54       */
55      public abstract void initSingle();
56  
57      /***
58       * Sets the rating bar in the proper line on the grid bag grid
59       *
60       * @param line
61       */
62      protected void setMidfieldRatingBar(int line) {
63          constraints.gridx = 0;
64          constraints.gridy = line;
65          constraints.gridwidth = 4;
66          layout.setConstraints(mainPanel.midfield, constraints);
67          centerPanel.add(mainPanel.midfield);
68      }
69  
70      /***
71       * Sets a lineup line in the proper line on the grid bag grid
72       *
73       * @param line
74       */
75      protected void setMyAttack(int line) {
76          JPanel m_clLinkerSturm;
77          JPanel m_clRechterSturm;
78  
79          constraints.gridx = 2;
80          constraints.gridy = line;
81          constraints.gridwidth = 1;
82          m_clLinkerSturm = mainPanel.getMyTeam().getLeftForwardPanel();
83          m_clLinkerSturm.setOpaque(false);
84          layout.setConstraints(m_clLinkerSturm, constraints);
85          centerPanel.add(m_clLinkerSturm);
86  
87          constraints.gridx = 1;
88          constraints.gridy = line;
89          constraints.gridwidth = 1;
90          m_clRechterSturm = mainPanel.getMyTeam().getRightForwardPanel();
91          m_clRechterSturm.setOpaque(false);
92          layout.setConstraints(m_clRechterSturm, constraints);
93          centerPanel.add(m_clRechterSturm);
94      }
95  
96      /***
97       * Sets a lineup line in the proper line on the grid bag grid
98       *
99       * @param line
100      */
101     protected void setMyDefence(int line) {
102         constraints.gridx = 3;
103         constraints.gridy = line;
104         constraints.gridwidth = 1;
105 
106         JPanel m_clRechteAussenVerteidiger = mainPanel.getMyTeam().getRightWingbackPanel();
107 
108         m_clRechteAussenVerteidiger.setOpaque(false);
109         layout.setConstraints(m_clRechteAussenVerteidiger, constraints);
110         centerPanel.add(m_clRechteAussenVerteidiger);
111 
112         constraints.gridx = 2;
113         constraints.gridy = line;
114         constraints.gridwidth = 1;
115 
116         JPanel m_clRechteInnenVerteidiger = mainPanel.getMyTeam().getRightCentralDefenderPanel();
117 
118         m_clRechteInnenVerteidiger.setOpaque(false);
119         layout.setConstraints(m_clRechteInnenVerteidiger, constraints);
120         centerPanel.add(m_clRechteInnenVerteidiger);
121 
122         constraints.gridx = 1;
123         constraints.gridy = line;
124         constraints.gridwidth = 1;
125 
126         JPanel m_clLinkeInnenVerteidiger = mainPanel.getMyTeam().getLeftCentralDefenderPanel();
127 
128         m_clLinkeInnenVerteidiger.setOpaque(false);
129         layout.setConstraints(m_clLinkeInnenVerteidiger, constraints);
130         centerPanel.add(m_clLinkeInnenVerteidiger);
131 
132         constraints.gridx = 0;
133         constraints.gridy = line;
134         constraints.gridwidth = 1;
135 
136         JPanel m_clLinkeAussenVerteidiger = mainPanel.getMyTeam().getLeftWingbackPanel();
137 
138         m_clLinkeAussenVerteidiger.setOpaque(false);
139         layout.setConstraints(m_clLinkeAussenVerteidiger, constraints);
140         centerPanel.add(m_clLinkeAussenVerteidiger);
141     }
142 
143     /***
144      * Sets a lineup line in the proper line on the grid bag grid
145      *
146      * @param line
147      */
148     protected void setMyKeeper(int line) {
149         JPanel m_clTorwart;
150 
151         constraints.gridx = 0;
152         constraints.gridy = line;
153         constraints.gridwidth = 4;
154         m_clTorwart = mainPanel.getMyTeam().getKeeperPanel();
155         m_clTorwart.setOpaque(false);
156         layout.setConstraints(m_clTorwart, constraints);
157         centerPanel.add(m_clTorwart);
158     }
159 
160     /***
161      * Sets a lineup line in the proper line on the grid bag grid
162      *
163      * @param line
164      */
165     protected void setMyMidfield(int line) {
166         JPanel m_clRechteFluegel;
167         JPanel m_clRechteMittelfeld;
168         JPanel m_clLinkeMittelfeld;
169         JPanel m_clLinkeFluegel;
170 
171         constraints.gridx = 3;
172         constraints.gridy = line;
173         constraints.gridwidth = 1;
174         m_clRechteFluegel = mainPanel.getMyTeam().getRightWingPanel();
175         m_clRechteFluegel.setOpaque(false);
176         layout.setConstraints(m_clRechteFluegel, constraints);
177         centerPanel.add(m_clRechteFluegel);
178 
179         constraints.gridx = 2;
180         constraints.gridy = line;
181         constraints.gridwidth = 1;
182         m_clRechteMittelfeld = mainPanel.getMyTeam().getRightMidfieldPanel();
183         m_clRechteMittelfeld.setOpaque(false);
184         layout.setConstraints(m_clRechteMittelfeld, constraints);
185         centerPanel.add(m_clRechteMittelfeld);
186 
187         constraints.gridx = 1;
188         constraints.gridy = line;
189         constraints.gridwidth = 1;
190         m_clLinkeMittelfeld = mainPanel.getMyTeam().getLeftMidfieldPanel();
191         m_clLinkeMittelfeld.setOpaque(false);
192         layout.setConstraints(m_clLinkeMittelfeld, constraints);
193         centerPanel.add(m_clLinkeMittelfeld);
194 
195         constraints.gridx = 0;
196         constraints.gridy = line;
197         constraints.gridwidth = 1;
198         m_clLinkeFluegel = mainPanel.getMyTeam().getLeftWingPanel();
199         m_clLinkeFluegel.setOpaque(false);
200         layout.setConstraints(m_clLinkeFluegel, constraints);
201         centerPanel.add(m_clLinkeFluegel);
202     }
203 
204     /***
205      * Sets the user team title panel on the grid
206      *
207      * @param line
208      */
209     protected void setMyPanel(int line) {
210         JLabel m_jlTeamName;
211 
212         constraints.gridx = 0;
213         constraints.gridy = line;
214         constraints.gridwidth = 4;
215         m_jlTeamName = mainPanel.getMyTeam().getTeamPanel();
216         m_jlTeamName.setOpaque(false);
217         m_jlTeamName.setForeground(Color.white);
218         m_jlTeamName.setFont(m_jlTeamName.getFont().deriveFont(Font.BOLD,
219                                                                gui.UserParameter.instance().schriftGroesse
220                                                                + 3));
221         layout.setConstraints(m_jlTeamName, constraints);
222         centerPanel.add(m_jlTeamName);
223     }
224 
225     /***
226      * Sets a lineup line in the proper line on the grid bag grid
227      *
228      * @param line
229      */
230     protected void setOpponentAttack(int line) {
231         constraints.gridx = 1;
232         constraints.gridy = line;
233         constraints.gridwidth = 1;
234 
235         JPanel m_clLinkerSturm = mainPanel.getOpponentTeam().getLeftForwardPanel();
236 
237         m_clLinkerSturm.setOpaque(false);
238         layout.setConstraints(m_clLinkerSturm, constraints);
239         centerPanel.add(m_clLinkerSturm);
240 
241         constraints.gridx = 2;
242         constraints.gridy = line;
243         constraints.gridwidth = 1;
244 
245         JPanel m_clRechterSturm = mainPanel.getOpponentTeam().getRightForwardPanel();
246 
247         m_clRechterSturm.setOpaque(false);
248         layout.setConstraints(m_clRechterSturm, constraints);
249         centerPanel.add(m_clRechterSturm);
250     }
251 
252     /***
253      * Sets a lineup line in the proper line on the grid bag grid
254      *
255      * @param line
256      */
257     protected void setOpponentDefence(int line) {
258         constraints.gridx = 0;
259         constraints.gridy = line;
260         constraints.gridwidth = 1;
261 
262         JPanel m_clRechteAussenVerteidiger = mainPanel.getOpponentTeam().getRightWingbackPanel();
263 
264         m_clRechteAussenVerteidiger.setOpaque(false);
265         layout.setConstraints(m_clRechteAussenVerteidiger, constraints);
266         centerPanel.add(m_clRechteAussenVerteidiger);
267 
268         constraints.gridx = 1;
269         constraints.gridy = line;
270         constraints.gridwidth = 1;
271 
272         JPanel m_clRechteInnenVerteidiger = mainPanel.getOpponentTeam()
273                                                      .getRightCentralDefenderPanel();
274 
275         m_clRechteInnenVerteidiger.setOpaque(false);
276         layout.setConstraints(m_clRechteInnenVerteidiger, constraints);
277         centerPanel.add(m_clRechteInnenVerteidiger);
278 
279         constraints.gridx = 2;
280         constraints.gridy = line;
281         constraints.gridwidth = 1;
282 
283         JPanel m_clLinkeInnenVerteidiger = mainPanel.getOpponentTeam().getLeftCentralDefenderPanel();
284 
285         m_clLinkeInnenVerteidiger.setOpaque(false);
286         layout.setConstraints(m_clLinkeInnenVerteidiger, constraints);
287         centerPanel.add(m_clLinkeInnenVerteidiger);
288 
289         constraints.gridx = 3;
290         constraints.gridy = line;
291         constraints.gridwidth = 1;
292 
293         JPanel m_clLinkeAussenVerteidiger = mainPanel.getOpponentTeam().getLeftWingbackPanel();
294 
295         m_clLinkeAussenVerteidiger.setOpaque(false);
296         layout.setConstraints(m_clLinkeAussenVerteidiger, constraints);
297         centerPanel.add(m_clLinkeAussenVerteidiger);
298     }
299 
300     /***
301      * Sets a lineup line in the proper line on the grid bag grid
302      *
303      * @param line
304      */
305     protected void setOpponentKeeper(int line) {
306         constraints.gridx = 0;
307         constraints.gridy = line;
308         constraints.gridwidth = 4;
309 
310         JPanel m_clTorwart = mainPanel.getOpponentTeam().getKeeperPanel();
311 
312         m_clTorwart.setOpaque(false);
313         layout.setConstraints(m_clTorwart, constraints);
314         centerPanel.add(m_clTorwart);
315     }
316 
317     /***
318      * Sets a lineup line in the proper line on the grid bag grid
319      *
320      * @param line
321      */
322     protected void setOpponentMidfield(int line) {
323         constraints.gridx = 0;
324         constraints.gridy = line;
325         constraints.gridwidth = 1;
326 
327         JPanel m_clRechteFluegel = mainPanel.getOpponentTeam().getRightWingPanel();
328 
329         m_clRechteFluegel.setOpaque(false);
330         layout.setConstraints(m_clRechteFluegel, constraints);
331         centerPanel.add(m_clRechteFluegel);
332 
333         constraints.gridx = 1;
334         constraints.gridy = line;
335         constraints.gridwidth = 1;
336 
337         JPanel m_clRechteMittelfeld = mainPanel.getOpponentTeam().getRightMidfieldPanel();
338 
339         m_clRechteMittelfeld.setOpaque(false);
340         layout.setConstraints(m_clRechteMittelfeld, constraints);
341         centerPanel.add(m_clRechteMittelfeld);
342 
343         constraints.gridx = 2;
344         constraints.gridy = line;
345         constraints.gridwidth = 1;
346 
347         JPanel m_clLinkeMittelfeld = mainPanel.getOpponentTeam().getLeftMidfieldPanel();
348 
349         m_clLinkeMittelfeld.setOpaque(false);
350         layout.setConstraints(m_clLinkeMittelfeld, constraints);
351         centerPanel.add(m_clLinkeMittelfeld);
352 
353         constraints.gridx = 3;
354         constraints.gridy = line;
355         constraints.gridwidth = 1;
356 
357         JPanel m_clLinkeFluegel = mainPanel.getOpponentTeam().getLeftWingPanel();
358 
359         m_clLinkeFluegel.setOpaque(false);
360         layout.setConstraints(m_clLinkeFluegel, constraints);
361         centerPanel.add(m_clLinkeFluegel);
362     }
363 
364     /***
365      * Sets the opponent team title panel on the grid
366      *
367      * @param line
368      */
369     protected void setOpponentPanel(int line) {
370         constraints.gridx = 0;
371         constraints.gridy = line;
372         constraints.gridwidth = 4;
373 
374         JLabel m_jlTeamName = mainPanel.getOpponentTeam().getTeamPanel();
375 
376         m_jlTeamName.setOpaque(false);
377         m_jlTeamName.setForeground(Color.white);
378         m_jlTeamName.setFont(m_jlTeamName.getFont().deriveFont(Font.BOLD,
379                                                                gui.UserParameter.instance().schriftGroesse
380                                                                + 3));
381         layout.setConstraints(m_jlTeamName, constraints);
382         centerPanel.add(m_jlTeamName);
383     }
384 
385     /***
386      * Sets the rating bar in the proper line on the grid bag grid
387      *
388      * @param line
389      */
390     protected void setRatingBar1(int line) {
391         constraints.gridy = line;
392         constraints.gridwidth = 1;
393 
394         constraints.gridx = 3;
395         layout.setConstraints(mainPanel.leftDef, constraints);
396         centerPanel.add(mainPanel.leftDef);
397 
398         constraints.gridx = 0;
399         layout.setConstraints(mainPanel.rightDef, constraints);
400         centerPanel.add(mainPanel.rightDef);
401 
402         constraints.gridx = 1;
403         constraints.gridwidth = 2;
404         layout.setConstraints(mainPanel.midDef, constraints);
405         centerPanel.add(mainPanel.midDef);
406     }
407 
408     /***
409      * Sets the rating bar in the proper line on the grid bag grid
410      *
411      * @param line
412      */
413     protected void setRatingBar2(int line) {
414         constraints.gridy = line;
415         constraints.gridwidth = 1;
416 
417         constraints.gridx = 3;
418         layout.setConstraints(mainPanel.leftAtt, constraints);
419         centerPanel.add(mainPanel.leftAtt);
420 
421         constraints.gridx = 0;
422         layout.setConstraints(mainPanel.rightAtt, constraints);
423         centerPanel.add(mainPanel.rightAtt);
424 
425         constraints.gridx = 1;
426         constraints.gridwidth = 2;
427         layout.setConstraints(mainPanel.midAtt, constraints);
428         centerPanel.add(mainPanel.midAtt);
429     }
430 }