1
2 package hoplugins.teamAnalyzer.report;
3
4 import hoplugins.teamAnalyzer.vo.PlayerPerformance;
5
6 import java.util.Collection;
7 import java.util.HashMap;
8 import java.util.Map;
9
10
11 /***
12 * Report of all players played in a certain position on a spot on the field
13 *
14 * @author <a href=mailto:draghetto@users.sourceforge.net>Massimiliano Amato</a>
15 */
16 public class PositionReport extends Report {
17
18
19 /*** List of tactics used offensive, defensive etc */
20 private Map tacticReports = new HashMap();
21
22
23
24 /***
25 * Creates a new PositionReport object.
26 *
27 * @param pp PlayerPerformance
28 */
29 public PositionReport(PlayerPerformance pp) {
30 super(pp);
31 }
32
33
34
35 /***
36 * Document me!
37 *
38 * @return
39 */
40 public Collection getTacticReports() {
41 return tacticReports.values();
42 }
43
44 /***
45 * Add a performance to the report, and updated the tactic list
46 *
47 * @param pp
48 */
49 public void addPerformance(PlayerPerformance pp) {
50 super.addPerformance(pp);
51 updateTacticDetails(pp);
52 }
53
54 /***
55 * toString methode: creates a String representation of the object
56 *
57 * @return the String representation
58 */
59 public String toString() {
60 StringBuffer buffer = new StringBuffer();
61
62 buffer.append("PositionReport[");
63 buffer.append(super.toString());
64 buffer.append("]");
65
66 return buffer.toString();
67 }
68
69 /***
70 * Update the tactic detail list with the new performance Gets the tactic report for the tactic
71 * position (offensive mid, def midfielder etc), and add the new performance
72 *
73 * @param pp
74 */
75 private void updateTacticDetails(PlayerPerformance pp) {
76 TacticReport report = (TacticReport) tacticReports.get("" + pp.getPosition());
77
78 if (report == null) {
79 report = new TacticReport(pp);
80 tacticReports.put("" + pp.getPosition(), report);
81 }
82
83 report.addPerformance(pp);
84 }
85 }