1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.magicproject.chart;
20
21 import java.util.EnumMap;
22 import java.util.Map;
23
24 import net.sf.magicproject.chart.datasets.Dataset;
25 import net.sf.magicproject.clickable.targetable.card.CardModel;
26
27 /***
28 * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
29 * @since 0.93
30 */
31 public class ChartSets {
32
33 private final Map<ChartFilter, Dataset> datasets;
34
35 /***
36 * Create a new instance of this class.
37 */
38 public ChartSets() {
39 datasets = new EnumMap<ChartFilter, Dataset>(ChartFilter.class);
40 }
41
42 /***
43 * Add a dataset to this set.
44 *
45 * @param filter
46 * @param dataSet
47 */
48 public void addDataSet(ChartFilter filter, Dataset dataSet) {
49 datasets.put(filter, dataSet);
50 }
51
52 /***
53 * Add cards to all datasets.
54 *
55 * @param cardModel
56 * the card to add.
57 * @param amount
58 * the amount of card to add.
59 */
60 public void addCard(final CardModel cardModel, final int amount) {
61 for (Dataset dataset : datasets.values())
62 dataset.addCard(cardModel, amount);
63 }
64
65 /***
66 * Remove cards to all datasets.
67 *
68 * @param cardModel
69 * the card to remove.
70 * @param amount
71 * the amount of card to remove.
72 */
73 public void removeCard(final CardModel cardModel, final int amount) {
74 for (Dataset dataset : datasets.values())
75 dataset.removeCard(cardModel, amount);
76 }
77
78 /***
79 * @param filter
80 * @param key
81 * @param amount
82 */
83 public void initKey(ChartFilter filter, IChartKey key, Integer amount) {
84 datasets.get(filter).setValue(key, amount);
85 }
86
87 /***
88 * Remove all data from this dataset.
89 */
90 public void removeAll() {
91 for (Dataset dataset : datasets.values())
92 dataset.removeAll();
93 }
94 }