View Javadoc

1   /*
2    *   Magic-Project is a turn based strategy simulator
3    *   Copyright (C) 2003-2007 Fabrice Daugan
4    *
5    *   This program is free software; you can redistribute it and/or modify it 
6    * under the terms of the GNU General Public License as published by the Free 
7    * Software Foundation; either version 2 of the License, or (at your option) any
8    * later version.
9    *
10   *   This program is distributed in the hope that it will be useful, but WITHOUT 
11   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
13   * details.
14   *
15   *   You should have received a copy of the GNU General Public License along  
16   * with this program; if not, write to the Free Software Foundation, Inc., 
17   * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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  }