2 * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
\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
8 * http://www.apache.org/licenses/LICENSE-2.0
\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
16 package org.achartengine.model;
\r
18 import java.io.Serializable;
\r
19 import java.util.ArrayList;
\r
20 import java.util.List;
\r
23 * A series for the multiple category charts like the doughnut.
\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
36 * Builds a new category series.
\r
38 * @param title the series title
\r
40 public MultipleCategorySeries(String title) {
\r
45 * Adds a new value to the series
\r
47 * @param titles the titles to be used as labels
\r
48 * @param values the new value
\r
50 public void add(String[] titles, double[] values) {
\r
51 add(mCategories.size() + "", titles, values);
\r
55 * Adds a new value to the series.
\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
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
68 * Removes an existing value from the series.
\r
70 * @param index the index in the series of the value to remove
\r
72 public void remove(int index) {
\r
73 mCategories.remove(index);
\r
74 mTitles.remove(index);
\r
75 mValues.remove(index);
\r
79 * Removes all the existing values from the series.
\r
81 public void clear() {
\r
82 mCategories.clear();
\r
88 * Returns the values at the specified index.
\r
90 * @param index the index
\r
91 * @return the value at the index
\r
93 public double[] getValues(int index) {
\r
94 return mValues.get(index);
\r
98 * Returns the category name at the specified index.
\r
100 * @param index the index
\r
101 * @return the category name at the index
\r
103 public String getCategory(int index) {
\r
104 return mCategories.get(index);
\r
108 * Returns the categories count.
\r
110 * @return the categories count
\r
112 public int getCategoriesCount() {
\r
113 return mCategories.size();
\r
117 * Returns the series item count.
\r
119 * @param index the index
\r
120 * @return the series item count
\r
122 public int getItemCount(int index) {
\r
123 return mValues.get(index).length;
\r
127 * Returns the series titles.
\r
129 * @param index the index
\r
130 * @return the series titles
\r
132 public String[] getTitles(int index) {
\r
133 return mTitles.get(index);
\r
137 * Transforms the category series to an XY series.
\r
139 * @return the XY series
\r
141 public XYSeries toXYSeries() {
\r
142 XYSeries xySeries = new XYSeries(mTitle);
\r