create changelog entry
[debian/openrocket] / android-libraries / achartengine / src / org / achartengine / ChartFactory.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;\r
17 \r
18 import org.achartengine.chart.BarChart;\r
19 import org.achartengine.chart.BarChart.Type;\r
20 import org.achartengine.chart.BubbleChart;\r
21 import org.achartengine.chart.CombinedXYChart;\r
22 import org.achartengine.chart.CubicLineChart;\r
23 import org.achartengine.chart.DialChart;\r
24 import org.achartengine.chart.DoughnutChart;\r
25 import org.achartengine.chart.LineChart;\r
26 import org.achartengine.chart.PieChart;\r
27 import org.achartengine.chart.RangeBarChart;\r
28 import org.achartengine.chart.ScatterChart;\r
29 import org.achartengine.chart.TimeChart;\r
30 import org.achartengine.chart.XYChart;\r
31 import org.achartengine.model.CategorySeries;\r
32 import org.achartengine.model.MultipleCategorySeries;\r
33 import org.achartengine.model.XYMultipleSeriesDataset;\r
34 import org.achartengine.renderer.DefaultRenderer;\r
35 import org.achartengine.renderer.DialRenderer;\r
36 import org.achartengine.renderer.XYMultipleSeriesRenderer;\r
37 \r
38 import android.content.Context;\r
39 import android.content.Intent;\r
40 \r
41 /**\r
42  * Utility methods for creating chart views or intents.\r
43  */\r
44 public class ChartFactory {\r
45   /** The key for the chart data. */\r
46   public static final String CHART = "chart";\r
47 \r
48   /** The key for the chart graphical activity title. */\r
49   public static final String TITLE = "title";\r
50 \r
51   private ChartFactory() {\r
52     // empty for now\r
53   }\r
54 \r
55   /**\r
56    * Creates a line chart view.\r
57    * \r
58    * @param context the context\r
59    * @param dataset the multiple series dataset (cannot be null)\r
60    * @param renderer the multiple series renderer (cannot be null)\r
61    * @return a line chart graphical view\r
62    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
63    *           if the dataset and the renderer don't include the same number of\r
64    *           series\r
65    */\r
66   public static final GraphicalView getLineChartView(Context context,\r
67       XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) {\r
68     checkParameters(dataset, renderer);\r
69     XYChart chart = new LineChart(dataset, renderer);\r
70     return new GraphicalView(context, chart);\r
71   }\r
72 \r
73   /**\r
74    * Creates a cubic line chart view.\r
75    * \r
76    * @param context the context\r
77    * @param dataset the multiple series dataset (cannot be null)\r
78    * @param renderer the multiple series renderer (cannot be null)\r
79    * @return a line chart graphical view\r
80    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
81    *           if the dataset and the renderer don't include the same number of\r
82    *           series\r
83    */\r
84   public static final GraphicalView getCubeLineChartView(Context context,\r
85       XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, float smoothness) {\r
86     checkParameters(dataset, renderer);\r
87     XYChart chart = new CubicLineChart(dataset, renderer, smoothness);\r
88     return new GraphicalView(context, chart);\r
89   }\r
90 \r
91   /**\r
92    * Creates a scatter chart view.\r
93    * \r
94    * @param context the context\r
95    * @param dataset the multiple series dataset (cannot be null)\r
96    * @param renderer the multiple series renderer (cannot be null)\r
97    * @return a scatter chart graphical view\r
98    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
99    *           if the dataset and the renderer don't include the same number of\r
100    *           series\r
101    */\r
102   public static final GraphicalView getScatterChartView(Context context,\r
103       XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) {\r
104     checkParameters(dataset, renderer);\r
105     XYChart chart = new ScatterChart(dataset, renderer);\r
106     return new GraphicalView(context, chart);\r
107   }\r
108 \r
109   /**\r
110    * Creates a bubble chart view.\r
111    * \r
112    * @param context the context\r
113    * @param dataset the multiple series dataset (cannot be null)\r
114    * @param renderer the multiple series renderer (cannot be null)\r
115    * @return a scatter chart graphical view\r
116    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
117    *           if the dataset and the renderer don't include the same number of\r
118    *           series\r
119    */\r
120   public static final GraphicalView getBubbleChartView(Context context,\r
121       XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) {\r
122     checkParameters(dataset, renderer);\r
123     XYChart chart = new BubbleChart(dataset, renderer);\r
124     return new GraphicalView(context, chart);\r
125   }\r
126 \r
127   /**\r
128    * Creates a time chart view.\r
129    * \r
130    * @param context the context\r
131    * @param dataset the multiple series dataset (cannot be null)\r
132    * @param renderer the multiple series renderer (cannot be null)\r
133    * @param format the date format pattern to be used for displaying the X axis\r
134    *          date labels. If null, a default appropriate format will be used.\r
135    * @return a time chart graphical view\r
136    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
137    *           if the dataset and the renderer don't include the same number of\r
138    *           series\r
139    */\r
140   public static final GraphicalView getTimeChartView(Context context,\r
141       XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, String format) {\r
142     checkParameters(dataset, renderer);\r
143     TimeChart chart = new TimeChart(dataset, renderer);\r
144     chart.setDateFormat(format);\r
145     return new GraphicalView(context, chart);\r
146   }\r
147 \r
148   /**\r
149    * Creates a bar chart view.\r
150    * \r
151    * @param context the context\r
152    * @param dataset the multiple series dataset (cannot be null)\r
153    * @param renderer the multiple series renderer (cannot be null)\r
154    * @param type the bar chart type\r
155    * @return a bar chart graphical view\r
156    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
157    *           if the dataset and the renderer don't include the same number of\r
158    *           series\r
159    */\r
160   public static final GraphicalView getBarChartView(Context context,\r
161       XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type) {\r
162     checkParameters(dataset, renderer);\r
163     XYChart chart = new BarChart(dataset, renderer, type);\r
164     return new GraphicalView(context, chart);\r
165   }\r
166 \r
167   /**\r
168    * Creates a range bar chart view.\r
169    * \r
170    * @param context the context\r
171    * @param dataset the multiple series dataset (cannot be null)\r
172    * @param renderer the multiple series renderer (cannot be null)\r
173    * @param type the range bar chart type\r
174    * @return a bar chart graphical view\r
175    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
176    *           if the dataset and the renderer don't include the same number of\r
177    *           series\r
178    */\r
179   public static final GraphicalView getRangeBarChartView(Context context,\r
180       XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type) {\r
181     checkParameters(dataset, renderer);\r
182     XYChart chart = new RangeBarChart(dataset, renderer, type);\r
183     return new GraphicalView(context, chart);\r
184   }\r
185 \r
186   /**\r
187    * Creates a combined XY chart view.\r
188    * \r
189    * @param context the context\r
190    * @param dataset the multiple series dataset (cannot be null)\r
191    * @param renderer the multiple series renderer (cannot be null)\r
192    * @param types the chart types (cannot be null)\r
193    * @return a combined XY chart graphical view\r
194    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
195    *           if a dataset number of items is different than the number of\r
196    *           series renderers or number of chart types\r
197    */\r
198   public static final GraphicalView getCombinedXYChartView(Context context,\r
199       XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, String[] types) {\r
200     if (dataset == null || renderer == null || types == null\r
201         || dataset.getSeriesCount() != types.length) {\r
202       throw new IllegalArgumentException(\r
203           "Dataset, renderer and types should be not null and the datasets series count should be equal to the types length");\r
204     }\r
205     checkParameters(dataset, renderer);\r
206     CombinedXYChart chart = new CombinedXYChart(dataset, renderer, types);\r
207     return new GraphicalView(context, chart);\r
208   }\r
209 \r
210   /**\r
211    * Creates a pie chart intent that can be used to start the graphical view\r
212    * activity.\r
213    * \r
214    * @param context the context\r
215    * @param dataset the category series dataset (cannot be null)\r
216    * @param renderer the series renderer (cannot be null)\r
217    * @return a pie chart view\r
218    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
219    *           if the dataset number of items is different than the number of\r
220    *           series renderers\r
221    */\r
222   public static final GraphicalView getPieChartView(Context context, CategorySeries dataset,\r
223       DefaultRenderer renderer) {\r
224     checkParameters(dataset, renderer);\r
225     PieChart chart = new PieChart(dataset, renderer);\r
226     return new GraphicalView(context, chart);\r
227   }\r
228 \r
229   /**\r
230    * Creates a dial chart intent that can be used to start the graphical view\r
231    * activity.\r
232    * \r
233    * @param context the context\r
234    * @param dataset the category series dataset (cannot be null)\r
235    * @param renderer the dial renderer (cannot be null)\r
236    * @return a pie chart view\r
237    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
238    *           if the dataset number of items is different than the number of\r
239    *           series renderers\r
240    */\r
241   public static final GraphicalView getDialChartView(Context context, CategorySeries dataset,\r
242       DialRenderer renderer) {\r
243     checkParameters(dataset, renderer);\r
244     DialChart chart = new DialChart(dataset, renderer);\r
245     return new GraphicalView(context, chart);\r
246   }\r
247 \r
248   /**\r
249    * Creates a doughnut chart intent that can be used to start the graphical\r
250    * view activity.\r
251    * \r
252    * @param context the context\r
253    * @param dataset the multiple category series dataset (cannot be null)\r
254    * @param renderer the series renderer (cannot be null)\r
255    * @return a pie chart view\r
256    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
257    *           if the dataset number of items is different than the number of\r
258    *           series renderers\r
259    */\r
260   public static final GraphicalView getDoughnutChartView(Context context,\r
261       MultipleCategorySeries dataset, DefaultRenderer renderer) {\r
262     checkParameters(dataset, renderer);\r
263     DoughnutChart chart = new DoughnutChart(dataset, renderer);\r
264     return new GraphicalView(context, chart);\r
265   }\r
266 \r
267   /**\r
268    * \r
269    * Creates a line chart intent that can be used to start the graphical view\r
270    * activity.\r
271    * \r
272    * @param context the context\r
273    * @param dataset the multiple series dataset (cannot be null)\r
274    * @param renderer the multiple series renderer (cannot be null)\r
275    * @return a line chart intent\r
276    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
277    *           if the dataset and the renderer don't include the same number of\r
278    *           series\r
279    */\r
280   public static final Intent getLineChartIntent(Context context, XYMultipleSeriesDataset dataset,\r
281       XYMultipleSeriesRenderer renderer) {\r
282     return getLineChartIntent(context, dataset, renderer, "");\r
283   }\r
284 \r
285   /**\r
286    * \r
287    * Creates a cubic line chart intent that can be used to start the graphical\r
288    * view activity.\r
289    * \r
290    * @param context the context\r
291    * @param dataset the multiple series dataset (cannot be null)\r
292    * @param renderer the multiple series renderer (cannot be null)\r
293    * @return a line chart intent\r
294    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
295    *           if the dataset and the renderer don't include the same number of\r
296    *           series\r
297    */\r
298   public static final Intent getCubicLineChartIntent(Context context,\r
299       XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, float smoothness) {\r
300     return getCubicLineChartIntent(context, dataset, renderer, smoothness, "");\r
301   }\r
302 \r
303   /**\r
304    * Creates a scatter chart intent that can be used to start the graphical view\r
305    * activity.\r
306    * \r
307    * @param context the context\r
308    * @param dataset the multiple series dataset (cannot be null)\r
309    * @param renderer the multiple series renderer (cannot be null)\r
310    * @return a scatter chart intent\r
311    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
312    *           if the dataset and the renderer don't include the same number of\r
313    *           series\r
314    */\r
315   public static final Intent getScatterChartIntent(Context context,\r
316       XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) {\r
317     return getScatterChartIntent(context, dataset, renderer, "");\r
318   }\r
319 \r
320   /**\r
321    * Creates a bubble chart intent that can be used to start the graphical view\r
322    * activity.\r
323    * \r
324    * @param context the context\r
325    * @param dataset the multiple series dataset (cannot be null)\r
326    * @param renderer the multiple series renderer (cannot be null)\r
327    * @return a scatter chart intent\r
328    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
329    *           if the dataset and the renderer don't include the same number of\r
330    *           series\r
331    */\r
332   public static final Intent getBubbleChartIntent(Context context, XYMultipleSeriesDataset dataset,\r
333       XYMultipleSeriesRenderer renderer) {\r
334     return getBubbleChartIntent(context, dataset, renderer, "");\r
335   }\r
336 \r
337   /**\r
338    * Creates a time chart intent that can be used to start the graphical view\r
339    * activity.\r
340    * \r
341    * @param context the context\r
342    * @param dataset the multiple series dataset (cannot be null)\r
343    * @param renderer the multiple series renderer (cannot be null)\r
344    * @param format the date format pattern to be used for displaying the X axis\r
345    *          date labels. If null, a default appropriate format will be used.\r
346    * @return a time chart intent\r
347    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
348    *           if the dataset and the renderer don't include the same number of\r
349    *           series\r
350    */\r
351   public static final Intent getTimeChartIntent(Context context, XYMultipleSeriesDataset dataset,\r
352       XYMultipleSeriesRenderer renderer, String format) {\r
353     return getTimeChartIntent(context, dataset, renderer, format, "");\r
354   }\r
355 \r
356   /**\r
357    * Creates a bar chart intent that can be used to start the graphical view\r
358    * activity.\r
359    * \r
360    * @param context the context\r
361    * @param dataset the multiple series dataset (cannot be null)\r
362    * @param renderer the multiple series renderer (cannot be null)\r
363    * @param type the bar chart type\r
364    * @return a bar chart intent\r
365    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
366    *           if the dataset and the renderer don't include the same number of\r
367    *           series\r
368    */\r
369   public static final Intent getBarChartIntent(Context context, XYMultipleSeriesDataset dataset,\r
370       XYMultipleSeriesRenderer renderer, Type type) {\r
371     return getBarChartIntent(context, dataset, renderer, type, "");\r
372   }\r
373 \r
374   /**\r
375    * Creates a line chart intent that can be used to start the graphical view\r
376    * activity.\r
377    * \r
378    * @param context the context\r
379    * @param dataset the multiple series dataset (cannot be null)\r
380    * @param renderer the multiple series renderer (cannot be null)\r
381    * @param activityTitle the graphical chart activity title. If this is null,\r
382    *          then the title bar will be hidden. If a blank title is passed in,\r
383    *          then the title bar will be the default. Pass in any other string\r
384    *          to set a custom title.\r
385    * @return a line chart intent\r
386    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
387    *           if the dataset and the renderer don't include the same number of\r
388    *           series\r
389    */\r
390   public static final Intent getLineChartIntent(Context context, XYMultipleSeriesDataset dataset,\r
391       XYMultipleSeriesRenderer renderer, String activityTitle) {\r
392     checkParameters(dataset, renderer);\r
393     Intent intent = new Intent(context, GraphicalActivity.class);\r
394     XYChart chart = new LineChart(dataset, renderer);\r
395     intent.putExtra(CHART, chart);\r
396     intent.putExtra(TITLE, activityTitle);\r
397     return intent;\r
398   }\r
399 \r
400   /**\r
401    * Creates a line chart intent that can be used to start the graphical view\r
402    * activity.\r
403    * \r
404    * @param context the context\r
405    * @param dataset the multiple series dataset (cannot be null)\r
406    * @param renderer the multiple series renderer (cannot be null)\r
407    * @param activityTitle the graphical chart activity title. If this is null,\r
408    *          then the title bar will be hidden. If a blank title is passed in,\r
409    *          then the title bar will be the default. Pass in any other string\r
410    *          to set a custom title.\r
411    * @return a line chart intent\r
412    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
413    *           if the dataset and the renderer don't include the same number of\r
414    *           series\r
415    */\r
416   public static final Intent getCubicLineChartIntent(Context context,\r
417       XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, float smoothness,\r
418       String activityTitle) {\r
419     checkParameters(dataset, renderer);\r
420     Intent intent = new Intent(context, GraphicalActivity.class);\r
421     XYChart chart = new CubicLineChart(dataset, renderer, smoothness);\r
422     intent.putExtra(CHART, chart);\r
423     intent.putExtra(TITLE, activityTitle);\r
424     return intent;\r
425   }\r
426 \r
427   /**\r
428    * Creates a scatter chart intent that can be used to start the graphical view\r
429    * activity.\r
430    * \r
431    * @param context the context\r
432    * @param dataset the multiple series dataset (cannot be null)\r
433    * @param renderer the multiple series renderer (cannot be null)\r
434    * @param activityTitle the graphical chart activity title\r
435    * @return a scatter chart intent\r
436    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
437    *           if the dataset and the renderer don't include the same number of\r
438    *           series\r
439    */\r
440   public static final Intent getScatterChartIntent(Context context,\r
441       XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, String activityTitle) {\r
442     checkParameters(dataset, renderer);\r
443     Intent intent = new Intent(context, GraphicalActivity.class);\r
444     XYChart chart = new ScatterChart(dataset, renderer);\r
445     intent.putExtra(CHART, chart);\r
446     intent.putExtra(TITLE, activityTitle);\r
447     return intent;\r
448   }\r
449 \r
450   /**\r
451    * Creates a bubble chart intent that can be used to start the graphical view\r
452    * activity.\r
453    * \r
454    * @param context the context\r
455    * @param dataset the multiple series dataset (cannot be null)\r
456    * @param renderer the multiple series renderer (cannot be null)\r
457    * @param activityTitle the graphical chart activity title\r
458    * @return a scatter chart intent\r
459    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
460    *           if the dataset and the renderer don't include the same number of\r
461    *           series\r
462    */\r
463   public static final Intent getBubbleChartIntent(Context context, XYMultipleSeriesDataset dataset,\r
464       XYMultipleSeriesRenderer renderer, String activityTitle) {\r
465     checkParameters(dataset, renderer);\r
466     Intent intent = new Intent(context, GraphicalActivity.class);\r
467     XYChart chart = new BubbleChart(dataset, renderer);\r
468     intent.putExtra(CHART, chart);\r
469     intent.putExtra(TITLE, activityTitle);\r
470     return intent;\r
471   }\r
472 \r
473   /**\r
474    * Creates a time chart intent that can be used to start the graphical view\r
475    * activity.\r
476    * \r
477    * @param context the context\r
478    * @param dataset the multiple series dataset (cannot be null)\r
479    * @param renderer the multiple series renderer (cannot be null)\r
480    * @param format the date format pattern to be used for displaying the X axis\r
481    *          date labels. If null, a default appropriate format will be used\r
482    * @param activityTitle the graphical chart activity title\r
483    * @return a time chart intent\r
484    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
485    *           if the dataset and the renderer don't include the same number of\r
486    *           series\r
487    */\r
488   public static final Intent getTimeChartIntent(Context context, XYMultipleSeriesDataset dataset,\r
489       XYMultipleSeriesRenderer renderer, String format, String activityTitle) {\r
490     checkParameters(dataset, renderer);\r
491     Intent intent = new Intent(context, GraphicalActivity.class);\r
492     TimeChart chart = new TimeChart(dataset, renderer);\r
493     chart.setDateFormat(format);\r
494     intent.putExtra(CHART, chart);\r
495     intent.putExtra(TITLE, activityTitle);\r
496     return intent;\r
497   }\r
498 \r
499   /**\r
500    * Creates a bar chart intent that can be used to start the graphical view\r
501    * activity.\r
502    * \r
503    * @param context the context\r
504    * @param dataset the multiple series dataset (cannot be null)\r
505    * @param renderer the multiple series renderer (cannot be null)\r
506    * @param type the bar chart type\r
507    * @param activityTitle the graphical chart activity title\r
508    * @return a bar chart intent\r
509    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
510    *           if the dataset and the renderer don't include the same number of\r
511    *           series\r
512    */\r
513   public static final Intent getBarChartIntent(Context context, XYMultipleSeriesDataset dataset,\r
514       XYMultipleSeriesRenderer renderer, Type type, String activityTitle) {\r
515     checkParameters(dataset, renderer);\r
516     Intent intent = new Intent(context, GraphicalActivity.class);\r
517     BarChart chart = new BarChart(dataset, renderer, type);\r
518     intent.putExtra(CHART, chart);\r
519     intent.putExtra(TITLE, activityTitle);\r
520     return intent;\r
521   }\r
522 \r
523   /**\r
524    * Creates a range bar chart intent that can be used to start the graphical\r
525    * view activity.\r
526    * \r
527    * @param context the context\r
528    * @param dataset the multiple series dataset (cannot be null)\r
529    * @param renderer the multiple series renderer (cannot be null)\r
530    * @param type the range bar chart type\r
531    * @param activityTitle the graphical chart activity title\r
532    * @return a range bar chart intent\r
533    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
534    *           if the dataset and the renderer don't include the same number of\r
535    *           series\r
536    */\r
537   public static final Intent getRangeBarChartIntent(Context context,\r
538       XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type,\r
539       String activityTitle) {\r
540     checkParameters(dataset, renderer);\r
541     Intent intent = new Intent(context, GraphicalActivity.class);\r
542     RangeBarChart chart = new RangeBarChart(dataset, renderer, type);\r
543     intent.putExtra(CHART, chart);\r
544     intent.putExtra(TITLE, activityTitle);\r
545     return intent;\r
546   }\r
547 \r
548   /**\r
549    * Creates a combined XY chart intent that can be used to start the graphical\r
550    * view activity.\r
551    * \r
552    * @param context the context\r
553    * @param dataset the multiple series dataset (cannot be null)\r
554    * @param renderer the multiple series renderer (cannot be null)\r
555    * @param types the chart types (cannot be null)\r
556    * @param activityTitle the graphical chart activity title\r
557    * @return a combined XY chart intent\r
558    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
559    *           if a dataset number of items is different than the number of\r
560    *           series renderers or number of chart types\r
561    */\r
562   public static final Intent getCombinedXYChartIntent(Context context,\r
563       XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, String[] types,\r
564       String activityTitle) {\r
565     if (dataset == null || renderer == null || types == null\r
566         || dataset.getSeriesCount() != types.length) {\r
567       throw new IllegalArgumentException(\r
568           "Datasets, renderers and types should be not null and the datasets series count should be equal to the types length");\r
569     }\r
570     checkParameters(dataset, renderer);\r
571     Intent intent = new Intent(context, GraphicalActivity.class);\r
572     CombinedXYChart chart = new CombinedXYChart(dataset, renderer, types);\r
573     intent.putExtra(CHART, chart);\r
574     intent.putExtra(TITLE, activityTitle);\r
575     return intent;\r
576   }\r
577 \r
578   /**\r
579    * Creates a pie chart intent that can be used to start the graphical view\r
580    * activity.\r
581    * \r
582    * @param context the context\r
583    * @param dataset the category series dataset (cannot be null)\r
584    * @param renderer the series renderer (cannot be null)\r
585    * @param activityTitle the graphical chart activity title\r
586    * @return a pie chart intent\r
587    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
588    *           if the dataset number of items is different than the number of\r
589    *           series renderers\r
590    */\r
591   public static final Intent getPieChartIntent(Context context, CategorySeries dataset,\r
592       DefaultRenderer renderer, String activityTitle) {\r
593     checkParameters(dataset, renderer);\r
594     Intent intent = new Intent(context, GraphicalActivity.class);\r
595     PieChart chart = new PieChart(dataset, renderer);\r
596     intent.putExtra(CHART, chart);\r
597     intent.putExtra(TITLE, activityTitle);\r
598     return intent;\r
599   }\r
600 \r
601   /**\r
602    * Creates a doughnut chart intent that can be used to start the graphical\r
603    * view activity.\r
604    * \r
605    * @param context the context\r
606    * @param dataset the multiple category series dataset (cannot be null)\r
607    * @param renderer the series renderer (cannot be null)\r
608    * @param activityTitle the graphical chart activity title\r
609    * @return a pie chart intent\r
610    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
611    *           if the dataset number of items is different than the number of\r
612    *           series renderers\r
613    */\r
614   public static final Intent getDoughnutChartIntent(Context context,\r
615       MultipleCategorySeries dataset, DefaultRenderer renderer, String activityTitle) {\r
616     checkParameters(dataset, renderer);\r
617     Intent intent = new Intent(context, GraphicalActivity.class);\r
618     DoughnutChart chart = new DoughnutChart(dataset, renderer);\r
619     intent.putExtra(CHART, chart);\r
620     intent.putExtra(TITLE, activityTitle);\r
621     return intent;\r
622   }\r
623 \r
624   /**\r
625    * Creates a dial chart intent that can be used to start the graphical view\r
626    * activity.\r
627    * \r
628    * @param context the context\r
629    * @param dataset the category series dataset (cannot be null)\r
630    * @param renderer the dial renderer (cannot be null)\r
631    * @param activityTitle the graphical chart activity title\r
632    * @return a dial chart intent\r
633    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
634    *           if the dataset number of items is different than the number of\r
635    *           series renderers\r
636    */\r
637   public static final Intent getDialChartIntent(Context context, CategorySeries dataset,\r
638       DialRenderer renderer, String activityTitle) {\r
639     checkParameters(dataset, renderer);\r
640     Intent intent = new Intent(context, GraphicalActivity.class);\r
641     DialChart chart = new DialChart(dataset, renderer);\r
642     intent.putExtra(CHART, chart);\r
643     intent.putExtra(TITLE, activityTitle);\r
644     return intent;\r
645   }\r
646 \r
647   /**\r
648    * Checks the validity of the dataset and renderer parameters.\r
649    * \r
650    * @param dataset the multiple series dataset (cannot be null)\r
651    * @param renderer the multiple series renderer (cannot be null)\r
652    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
653    *           if the dataset and the renderer don't include the same number of\r
654    *           series\r
655    */\r
656   private static void checkParameters(XYMultipleSeriesDataset dataset,\r
657       XYMultipleSeriesRenderer renderer) {\r
658     if (dataset == null || renderer == null\r
659         || dataset.getSeriesCount() != renderer.getSeriesRendererCount()) {\r
660       throw new IllegalArgumentException(\r
661           "Dataset and renderer should be not null and should have the same number of series");\r
662     }\r
663   }\r
664 \r
665   /**\r
666    * Checks the validity of the dataset and renderer parameters.\r
667    * \r
668    * @param dataset the category series dataset (cannot be null)\r
669    * @param renderer the series renderer (cannot be null)\r
670    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
671    *           if the dataset number of items is different than the number of\r
672    *           series renderers\r
673    */\r
674   private static void checkParameters(CategorySeries dataset, DefaultRenderer renderer) {\r
675     if (dataset == null || renderer == null\r
676         || dataset.getItemCount() != renderer.getSeriesRendererCount()) {\r
677       throw new IllegalArgumentException(\r
678           "Dataset and renderer should be not null and the dataset number of items should be equal to the number of series renderers");\r
679     }\r
680   }\r
681 \r
682   /**\r
683    * Checks the validity of the dataset and renderer parameters.\r
684    * \r
685    * @param dataset the category series dataset (cannot be null)\r
686    * @param renderer the series renderer (cannot be null)\r
687    * @throws IllegalArgumentException if dataset is null or renderer is null or\r
688    *           if the dataset number of items is different than the number of\r
689    *           series renderers\r
690    */\r
691   private static void checkParameters(MultipleCategorySeries dataset, DefaultRenderer renderer) {\r
692     if (dataset == null || renderer == null\r
693         || !checkMultipleSeriesItems(dataset, renderer.getSeriesRendererCount())) {\r
694       throw new IllegalArgumentException(\r
695           "Titles and values should be not null and the dataset number of items should be equal to the number of series renderers");\r
696     }\r
697   }\r
698 \r
699   private static boolean checkMultipleSeriesItems(MultipleCategorySeries dataset, int value) {\r
700     int count = dataset.getCategoriesCount();\r
701     boolean equal = true;\r
702     for (int k = 0; k < count && equal; k++) {\r
703       equal = dataset.getValues(k).length == dataset.getTitles(k).length;\r
704     }\r
705     return equal;\r
706   }\r
707 \r
708 }\r