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;
\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
38 import android.content.Context;
\r
39 import android.content.Intent;
\r
42 * Utility methods for creating chart views or intents.
\r
44 public class ChartFactory {
\r
45 /** The key for the chart data. */
\r
46 public static final String CHART = "chart";
\r
48 /** The key for the chart graphical activity title. */
\r
49 public static final String TITLE = "title";
\r
51 private ChartFactory() {
\r
56 * Creates a line chart view.
\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
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
74 * Creates a cubic line chart view.
\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
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
92 * Creates a scatter chart view.
\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
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
110 * Creates a bubble chart view.
\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
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
128 * Creates a time chart view.
\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
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
149 * Creates a bar chart view.
\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
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
168 * Creates a range bar chart view.
\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
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
187 * Creates a combined XY chart view.
\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
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
205 checkParameters(dataset, renderer);
\r
206 CombinedXYChart chart = new CombinedXYChart(dataset, renderer, types);
\r
207 return new GraphicalView(context, chart);
\r
211 * Creates a pie chart intent that can be used to start the graphical view
\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
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
230 * Creates a dial chart intent that can be used to start the graphical view
\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
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
249 * Creates a doughnut chart intent that can be used to start the graphical
\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
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
269 * Creates a line chart intent that can be used to start the graphical view
\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
280 public static final Intent getLineChartIntent(Context context, XYMultipleSeriesDataset dataset,
\r
281 XYMultipleSeriesRenderer renderer) {
\r
282 return getLineChartIntent(context, dataset, renderer, "");
\r
287 * Creates a cubic line chart intent that can be used to start the graphical
\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
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
304 * Creates a scatter chart intent that can be used to start the graphical view
\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
315 public static final Intent getScatterChartIntent(Context context,
\r
316 XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) {
\r
317 return getScatterChartIntent(context, dataset, renderer, "");
\r
321 * Creates a bubble chart intent that can be used to start the graphical view
\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
332 public static final Intent getBubbleChartIntent(Context context, XYMultipleSeriesDataset dataset,
\r
333 XYMultipleSeriesRenderer renderer) {
\r
334 return getBubbleChartIntent(context, dataset, renderer, "");
\r
338 * Creates a time chart intent that can be used to start the graphical view
\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
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
357 * Creates a bar chart intent that can be used to start the graphical view
\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
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
375 * Creates a line chart intent that can be used to start the graphical view
\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
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
401 * Creates a line chart intent that can be used to start the graphical view
\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
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
428 * Creates a scatter chart intent that can be used to start the graphical view
\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
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
451 * Creates a bubble chart intent that can be used to start the graphical view
\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
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
474 * Creates a time chart intent that can be used to start the graphical view
\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
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
500 * Creates a bar chart intent that can be used to start the graphical view
\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
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
524 * Creates a range bar chart intent that can be used to start the graphical
\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
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
549 * Creates a combined XY chart intent that can be used to start the graphical
\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
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
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
579 * Creates a pie chart intent that can be used to start the graphical view
\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
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
602 * Creates a doughnut chart intent that can be used to start the graphical
\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
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
625 * Creates a dial chart intent that can be used to start the graphical view
\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
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
648 * Checks the validity of the dataset and renderer parameters.
\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
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
666 * Checks the validity of the dataset and renderer parameters.
\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
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
683 * Checks the validity of the dataset and renderer parameters.
\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
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
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