1
2 package hoplugins.teamAnalyzer.ui.lineup;
3
4 import hoplugins.teamAnalyzer.SystemManager;
5 import hoplugins.teamAnalyzer.ui.RatingBox;
6 import hoplugins.teamAnalyzer.ui.TeamLineupData;
7
8 import javax.swing.JPanel;
9
10
11 /***
12 * Main formation Panel class that delegator to subclasses the issue of building the gui
13 *
14 * @author <a href=mailto:draghetto@users.sourceforge.net>Massimiliano Amato</a>
15 */
16 public class FormationPanel extends JPanel {
17
18
19 /*** Left Attack RatingBox */
20 protected RatingBox leftAtt = new RatingBox();
21
22 /*** Left Defence RatingBox */
23 protected RatingBox leftDef = new RatingBox();
24
25 /*** Central Attack RatingBox */
26 protected RatingBox midAtt = new RatingBox();
27
28 /*** Central Defence RatingBox */
29 protected RatingBox midDef = new RatingBox();
30
31 /*** Midfield RatingBox */
32 protected RatingBox midfield = new RatingBox();
33
34 /*** Right Attack RatingBox */
35 protected RatingBox rightAtt = new RatingBox();
36
37 /*** Right Defence RatingBox */
38 protected RatingBox rightDef = new RatingBox();
39
40 /*** User Team Lineup Data */
41 protected TeamLineupData myTeam = new TeamLineupData();
42
43 /*** Opponent Team Lineup Data */
44 protected TeamLineupData opponentTeam = new TeamLineupData();
45
46
47
48 /***
49 * Creates a new FormationPanel object.
50 */
51 public FormationPanel() {
52 setLayout(SystemManager.getConfig().isLineup(), SystemManager.getConfig().isMixedLineup());
53 }
54
55
56
57 /***
58 * Returns user team lineup data
59 *
60 * @return Own lineup data
61 */
62 public TeamLineupData getMyTeam() {
63 return myTeam;
64 }
65
66 /***
67 * Returns opponent team lineup data
68 *
69 * @return Opponents lineup data
70 */
71 public TeamLineupData getOpponentTeam() {
72 return opponentTeam;
73 }
74
75 /***
76 * Refresh the panel
77 *
78 * @param compare if both teams must be shown
79 * @param type standard (false) or mixed layout (true)
80 */
81 public void reload(boolean compare, boolean type) {
82 setLayout(compare, type);
83 midfield.reload((int) myTeam.getMidfield(), (int) opponentTeam.getMidfield());
84 rightDef.reload((int) myTeam.getLeftAttack(), (int) opponentTeam.getRightDefence());
85 leftDef.reload((int) myTeam.getRightAttack(), (int) opponentTeam.getLeftDefence());
86 midDef.reload((int) myTeam.getMiddleAttack(), (int) opponentTeam.getMiddleDefence());
87 rightAtt.reload((int) myTeam.getLeftDefence(), (int) opponentTeam.getRightAttack());
88 leftAtt.reload((int) myTeam.getRightDefence(), (int) opponentTeam.getLeftAttack());
89 midAtt.reload((int) myTeam.getMiddleDefence(), (int) opponentTeam.getMiddleAttack());
90 }
91
92 /***
93 * Sets the Layout of the panel, by delegating to the proper class
94 *
95 * @param compare true if both teams must be shown
96 * @param mixedLIneup true if mixedlineup has to be used, false if not
97 */
98 private void setLayout(boolean compare, boolean mixedLIneup) {
99 LineupStylePanel panel;
100
101 if (mixedLIneup) {
102 panel = new MixedLineupPanel(this);
103 } else {
104 panel = new StandardLineupPanel(this);
105 }
106
107 if (compare) {
108 panel.initCompare();
109 } else {
110 panel.initSingle();
111 }
112
113 removeAll();
114 setOpaque(false);
115 add(panel);
116 }
117 }