1
2 package hoplugins.teamAnalyzer.ui;
3
4 import hoplugins.Commons;
5
6 import hoplugins.commons.utils.PluginProperty;
7
8 import hoplugins.teamAnalyzer.SystemManager;
9 import hoplugins.teamAnalyzer.ui.lineup.FormationPanel;
10 import hoplugins.teamAnalyzer.vo.TeamLineup;
11 import hoplugins.teamAnalyzer.vo.UserTeamSpotLineup;
12
13 import plugins.ILineUp;
14 import plugins.ISpieler;
15
16 import java.awt.BorderLayout;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import javax.swing.JPanel;
22 import javax.swing.JScrollPane;
23
24
25 /***
26 * TODO Missing Class Documentation
27 *
28 * @author TODO Author Name
29 */
30 public class TeamPanel extends JPanel {
31
32
33 private FormationPanel lineupPanel = new FormationPanel();
34 private PlayerPanel keeper = new PlayerPanel();
35 private PlayerPanel leftAttacker = new PlayerPanel();
36 private PlayerPanel leftBack = new PlayerPanel();
37 private PlayerPanel leftCentral = new PlayerPanel();
38 private PlayerPanel leftMidfielder = new PlayerPanel();
39 private PlayerPanel leftWinger = new PlayerPanel();
40 private PlayerPanel rightAttacker = new PlayerPanel();
41 private PlayerPanel rightBack = new PlayerPanel();
42 private PlayerPanel rightCentral = new PlayerPanel();
43 private PlayerPanel rightMidfielder = new PlayerPanel();
44 private PlayerPanel rightWinger = new PlayerPanel();
45
46
47
48 /***
49 * Creates a new TeamPanel object.
50 */
51 public TeamPanel() {
52 jbInit();
53 }
54
55
56
57 /***
58 * TODO Missing Method Documentation
59 *
60 * @return TODO Missing Return Method Documentation
61 */
62 public TeamLineupData getMyTeamLineupPanel() {
63 return lineupPanel.getMyTeam();
64 }
65
66 /***
67 * TODO Missing Method Documentation
68 *
69 * @return TODO Missing Return Method Documentation
70 */
71 public TeamLineupData getOpponentTeamLineupPanel() {
72 return lineupPanel.getOpponentTeam();
73 }
74
75 /***
76 * TODO Missing Method Documentation
77 */
78 public void jbInit() {
79 JPanel grassPanel = Commons.getModel().getGUI().createGrassPanel();
80
81 grassPanel.setLayout(new BorderLayout());
82 grassPanel.add(lineupPanel, BorderLayout.CENTER);
83 setMyTeam();
84 setLayout(new BorderLayout());
85 fillPanel(lineupPanel.getOpponentTeam().getKeeperPanel(), keeper);
86 fillPanel(lineupPanel.getOpponentTeam().getLeftWingbackPanel(), leftBack);
87 fillPanel(lineupPanel.getOpponentTeam().getLeftCentralDefenderPanel(), leftCentral);
88 fillPanel(lineupPanel.getOpponentTeam().getRightCentralDefenderPanel(), rightCentral);
89 fillPanel(lineupPanel.getOpponentTeam().getRightWingbackPanel(), rightBack);
90 fillPanel(lineupPanel.getOpponentTeam().getLeftWingPanel(), leftWinger);
91 fillPanel(lineupPanel.getOpponentTeam().getLeftMidfieldPanel(), leftMidfielder);
92 fillPanel(lineupPanel.getOpponentTeam().getRightMidfieldPanel(), rightMidfielder);
93 fillPanel(lineupPanel.getOpponentTeam().getRightWingPanel(), rightWinger);
94 fillPanel(lineupPanel.getOpponentTeam().getLeftForwardPanel(), leftAttacker);
95 fillPanel(lineupPanel.getOpponentTeam().getRightForwardPanel(), rightAttacker);
96
97 JScrollPane scrollPane = new JScrollPane(grassPanel);
98
99 scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
100 scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
101 add(scrollPane, BorderLayout.CENTER);
102 }
103
104 /***
105 * DOCUMENT ME!
106 *
107 * @param lineup
108 * @param week TODO Missing Constructuor Parameter Documentation
109 * @param season TODO Missing Constructuor Parameter Documentation
110 */
111 public void reload(TeamLineup lineup, int week, int season) {
112 if (lineup != null) {
113 lineupPanel.getOpponentTeam().setTeamName(SystemManager.getActiveTeamName() + " ("
114 + SystemManager.getActiveTeamId() + ")");
115 keeper.reload(lineup.getSpotLineup(1), week, season);
116 leftBack.reload(lineup.getSpotLineup(5), week, season);
117 leftCentral.reload(lineup.getSpotLineup(4), week, season);
118 rightCentral.reload(lineup.getSpotLineup(3), week, season);
119 rightBack.reload(lineup.getSpotLineup(2), week, season);
120 leftWinger.reload(lineup.getSpotLineup(9), week, season);
121 leftMidfielder.reload(lineup.getSpotLineup(8), week, season);
122 rightMidfielder.reload(lineup.getSpotLineup(7), week, season);
123 rightWinger.reload(lineup.getSpotLineup(6), week, season);
124 leftAttacker.reload(lineup.getSpotLineup(10), week, season);
125 rightAttacker.reload(lineup.getSpotLineup(11), week, season);
126 lineupPanel.getOpponentTeam().setLeftAttack(lineup.getRating().getLeftAttack());
127 lineupPanel.getOpponentTeam().setLeftDefence(lineup.getRating().getLeftDefense());
128 lineupPanel.getOpponentTeam().setRightAttack(lineup.getRating().getRightAttack());
129 lineupPanel.getOpponentTeam().setRightDefence(lineup.getRating().getRightDefense());
130 lineupPanel.getOpponentTeam().setMiddleAttack(lineup.getRating().getCentralAttack());
131 lineupPanel.getOpponentTeam().setMiddleDefence(lineup.getRating().getCentralDefense());
132 lineupPanel.getOpponentTeam().setMidfield(lineup.getRating().getMidfield());
133
134 setMyTeam();
135 } else {
136 lineupPanel.getOpponentTeam().setTeamName(PluginProperty.getString("TeamPanel.TeamMessage"));
137 keeper.reload(null, 0, 0);
138 leftBack.reload(null, 0, 0);
139 leftCentral.reload(null, 0, 0);
140 rightCentral.reload(null, 0, 0);
141 rightBack.reload(null, 0, 0);
142 leftWinger.reload(null, 0, 0);
143 leftMidfielder.reload(null, 0, 0);
144 rightMidfielder.reload(null, 0, 0);
145 rightWinger.reload(null, 0, 0);
146 leftAttacker.reload(null, 0, 0);
147 rightAttacker.reload(null, 0, 0);
148 lineupPanel.getOpponentTeam().setLeftAttack(0);
149 lineupPanel.getOpponentTeam().setLeftDefence(0);
150 lineupPanel.getOpponentTeam().setRightAttack(0);
151 lineupPanel.getOpponentTeam().setRightDefence(0);
152 lineupPanel.getOpponentTeam().setMiddleAttack(0);
153 lineupPanel.getOpponentTeam().setMiddleDefence(0);
154 lineupPanel.getOpponentTeam().setMidfield(0);
155 }
156
157 lineupPanel.reload(SystemManager.getConfig().isLineup(),
158 SystemManager.getConfig().isMixedLineup());
159 }
160
161 /***
162 * TODO Missing Method Documentation
163 */
164 private void setMyTeam() {
165 List list = new ArrayList();
166 ILineUp lineup = Commons.getModel().getLineUP();
167
168 for (int spot = 1; spot < 12; spot++) {
169 ISpieler spieler = lineup.getPlayerByPositionID(spot);
170 UserTeamPlayerPanel pp = new UserTeamPlayerPanel();
171
172 if (spieler != null) {
173 UserTeamSpotLineup spotLineup = new UserTeamSpotLineup();
174
175 spotLineup.setAppearance(0);
176 spotLineup.setName(spieler.getName());
177 spotLineup.setPlayerId(spieler.getSpielerID());
178 spotLineup.setSpecialEvent(spieler.getSpezialitaet());
179 spotLineup.setTacticCode(lineup.getTactic4PositionID(spot));
180 spotLineup.setPosition(lineup.getEffectivePos4PositionID(spot));
181 spotLineup.setRating(spieler.calcPosValue(lineup.getEffectivePos4PositionID(spot),
182 true));
183 spotLineup.setSpot(spot);
184 spotLineup.setTactics(new ArrayList());
185 pp.reload(spotLineup);
186 } else {
187 pp.reload(null);
188 }
189
190 list.add(pp);
191 }
192
193 lineupPanel.getMyTeam().setTeamName(Commons.getModel().getBasics().getTeamName() + " ("
194 + Commons.getModel().getBasics().getTeamId() + ")");
195 fillPanel(lineupPanel.getMyTeam().getKeeperPanel(), (PlayerPanel) list.get(0));
196 fillPanel(lineupPanel.getMyTeam().getLeftWingbackPanel(), (PlayerPanel) list.get(4));
197 fillPanel(lineupPanel.getMyTeam().getLeftCentralDefenderPanel(), (PlayerPanel) list.get(3));
198 fillPanel(lineupPanel.getMyTeam().getRightCentralDefenderPanel(), (PlayerPanel) list.get(2));
199 fillPanel(lineupPanel.getMyTeam().getRightWingbackPanel(), (PlayerPanel) list.get(1));
200 fillPanel(lineupPanel.getMyTeam().getLeftWingPanel(), (PlayerPanel) list.get(8));
201 fillPanel(lineupPanel.getMyTeam().getLeftMidfieldPanel(), (PlayerPanel) list.get(7));
202 fillPanel(lineupPanel.getMyTeam().getRightMidfieldPanel(), (PlayerPanel) list.get(6));
203 fillPanel(lineupPanel.getMyTeam().getRightWingPanel(), (PlayerPanel) list.get(5));
204 fillPanel(lineupPanel.getMyTeam().getLeftForwardPanel(), (PlayerPanel) list.get(9));
205 fillPanel(lineupPanel.getMyTeam().getRightForwardPanel(), (PlayerPanel) list.get(10));
206 lineupPanel.getMyTeam().setLeftAttack(convertRating(lineup.getLeftAttackRating()));
207 lineupPanel.getMyTeam().setLeftDefence(convertRating(lineup.getLeftDefenseRating()));
208 lineupPanel.getMyTeam().setRightAttack(convertRating(lineup.getRightAttackRating()));
209 lineupPanel.getMyTeam().setRightDefence(convertRating(lineup.getRightDefenseRating()));
210 lineupPanel.getMyTeam().setMiddleAttack(convertRating(lineup.getCentralAttackRating()));
211 lineupPanel.getMyTeam().setMiddleDefence(convertRating(lineup.getCentralDefenseRating()));
212 lineupPanel.getMyTeam().setMidfield(convertRating(lineup.getMidfieldRating()));
213 }
214
215 /***
216 * TODO Missing Method Documentation
217 *
218 * @param rating TODO Missing Method Parameter Documentation
219 *
220 * @return TODO Missing Return Method Documentation
221 */
222 private int convertRating(double rating) {
223 return Commons.getModel().getLineUP().getIntValue4Rating(rating);
224 }
225
226 /***
227 * TODO Missing Method Documentation
228 *
229 * @param panel TODO Missing Method Parameter Documentation
230 * @param playerPanel TODO Missing Method Parameter Documentation
231 */
232 private void fillPanel(JPanel panel, JPanel playerPanel) {
233 panel.removeAll();
234 panel.add(playerPanel);
235 }
236 }