create changelog entry
[debian/openrocket] / android-libraries / achartengine / src / org / achartengine / model / MultipleCategorySeries.java
1 /**\r
2  * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL\r
3  *  \r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *  \r
8  *      http://www.apache.org/licenses/LICENSE-2.0\r
9  *  \r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 package org.achartengine.model;\r
17 \r
18 import java.io.Serializable;\r
19 import java.util.ArrayList;\r
20 import java.util.List;\r
21 \r
22 /**\r
23  * A series for the multiple category charts like the doughnut.\r
24  */\r
25 public class MultipleCategorySeries implements Serializable {\r
26   /** The series title. */\r
27   private String mTitle;\r
28   /** The series local keys. */\r
29   private List<String> mCategories = new ArrayList<String>();\r
30   /** The series name. */\r
31   private List<String[]> mTitles = new ArrayList<String[]>();\r
32   /** The series values. */\r
33   private List<double[]> mValues = new ArrayList<double[]>();\r
34 \r
35   /**\r
36    * Builds a new category series.\r
37    * \r
38    * @param title the series title\r
39    */\r
40   public MultipleCategorySeries(String title) {\r
41     mTitle = title;\r
42   }\r
43 \r
44   /**\r
45    * Adds a new value to the series\r
46    * \r
47    * @param titles the titles to be used as labels\r
48    * @param values the new value\r
49    */\r
50   public void add(String[] titles, double[] values) {\r
51     add(mCategories.size() + "", titles, values);\r
52   }\r
53 \r
54   /**\r
55    * Adds a new value to the series.\r
56    * \r
57    * @param category the category name\r
58    * @param titles the titles to be used as labels\r
59    * @param values the new value\r
60    */\r
61   public void add(String category, String[] titles, double[] values) {\r
62     mCategories.add(category);\r
63     mTitles.add(titles);\r
64     mValues.add(values);\r
65   }\r
66 \r
67   /**\r
68    * Removes an existing value from the series.\r
69    * \r
70    * @param index the index in the series of the value to remove\r
71    */\r
72   public void remove(int index) {\r
73     mCategories.remove(index);\r
74     mTitles.remove(index);\r
75     mValues.remove(index);\r
76   }\r
77 \r
78   /**\r
79    * Removes all the existing values from the series.\r
80    */\r
81   public void clear() {\r
82     mCategories.clear();\r
83     mTitles.clear();\r
84     mValues.clear();\r
85   }\r
86 \r
87   /**\r
88    * Returns the values at the specified index.\r
89    * \r
90    * @param index the index\r
91    * @return the value at the index\r
92    */\r
93   public double[] getValues(int index) {\r
94     return mValues.get(index);\r
95   }\r
96 \r
97   /**\r
98    * Returns the category name at the specified index.\r
99    * \r
100    * @param index the index\r
101    * @return the category name at the index\r
102    */\r
103   public String getCategory(int index) {\r
104     return mCategories.get(index);\r
105   }\r
106 \r
107   /**\r
108    * Returns the categories count.\r
109    * \r
110    * @return the categories count\r
111    */\r
112   public int getCategoriesCount() {\r
113     return mCategories.size();\r
114   }\r
115 \r
116   /**\r
117    * Returns the series item count.\r
118    * \r
119    * @param index the index\r
120    * @return the series item count\r
121    */\r
122   public int getItemCount(int index) {\r
123     return mValues.get(index).length;\r
124   }\r
125 \r
126   /**\r
127    * Returns the series titles.\r
128    * \r
129    * @param index the index\r
130    * @return the series titles\r
131    */\r
132   public String[] getTitles(int index) {\r
133     return mTitles.get(index);\r
134   }\r
135 \r
136   /**\r
137    * Transforms the category series to an XY series.\r
138    * \r
139    * @return the XY series\r
140    */\r
141   public XYSeries toXYSeries() {\r
142     XYSeries xySeries = new XYSeries(mTitle);\r
143     return xySeries;\r
144   }\r
145 }\r