create changelog entry
[debian/openrocket] / android-libraries / achartengine / src / org / achartengine / renderer / XYMultipleSeriesRenderer.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.renderer;\r
17 \r
18 import java.util.HashMap;\r
19 import java.util.LinkedHashMap;\r
20 import java.util.Map;\r
21 \r
22 import org.achartengine.util.MathHelper;\r
23 \r
24 import android.graphics.Color;\r
25 import android.graphics.Paint.Align;\r
26 \r
27 /**\r
28  * Multiple XY series renderer.\r
29  */\r
30 public class XYMultipleSeriesRenderer extends DefaultRenderer {\r
31   /** The X axis title. */\r
32   private String mXTitle = "";\r
33   /** The Y axis title. */\r
34   private String[] mYTitle;\r
35   /** The axis title text size. */\r
36   private float mAxisTitleTextSize = 12;\r
37   /** The start value in the X axis range. */\r
38   private double[] mMinX;\r
39   /** The end value in the X axis range. */\r
40   private double[] mMaxX;\r
41   /** The start value in the Y axis range. */\r
42   private double[] mMinY;\r
43   /** The end value in the Y axis range. */\r
44   private double[] mMaxY;\r
45   /** The approximative number of labels on the x axis. */\r
46   private int mXLabels = 5;\r
47   /** The approximative number of labels on the y axis. */\r
48   private int mYLabels = 5;\r
49   /** The current orientation of the chart. */\r
50   private Orientation mOrientation = Orientation.HORIZONTAL;\r
51   /** The X axis text labels. */\r
52   private Map<Double, String> mXTextLabels = new HashMap<Double, String>();\r
53   /** The Y axis text labels. */\r
54   private Map<Integer, Map<Double, String>> mYTextLabels = new LinkedHashMap<Integer, Map<Double, String>>();\r
55   /** A flag for enabling or not the pan on the X axis. */\r
56   private boolean mPanXEnabled = true;\r
57   /** A flag for enabling or not the pan on the Y axis. */\r
58   private boolean mPanYEnabled = true;\r
59   /** A flag for enabling or not the zoom on the X axis. */\r
60   private boolean mZoomXEnabled = true;\r
61   /** A flag for enabling or not the zoom on the Y axis . */\r
62   private boolean mZoomYEnabled = true;\r
63   /** The spacing between bars, in bar charts. */\r
64   private double mBarSpacing = 0;\r
65   /** The margins colors. */\r
66   private int mMarginsColor = NO_COLOR;\r
67   /** The pan limits. */\r
68   private double[] mPanLimits;\r
69   /** The zoom limits. */\r
70   private double[] mZoomLimits;\r
71   /** The X axis labels rotation angle. */\r
72   private float mXLabelsAngle;\r
73   /** The Y axis labels rotation angle. */\r
74   private float mYLabelsAngle;\r
75   /** The initial axis range. */\r
76   private Map<Integer, double[]> initialRange = new LinkedHashMap<Integer, double[]>();\r
77   /** The point size for charts displaying points. */\r
78   private float mPointSize = 3;\r
79   /** The grid color. */\r
80   private int mGridColor = Color.argb(75, 200, 200, 200);\r
81   /** The number of scales. */\r
82   private int scalesCount;\r
83   /** The X axis labels alignment. */\r
84   private Align xLabelsAlign = Align.CENTER;\r
85   /** The Y axis labels alignment. */\r
86   private Align[] yLabelsAlign;\r
87   /** The Y axis alignment. */\r
88   private Align[] yAxisAlign;\r
89   /** The X axis labels color. */\r
90   private int mXLabelsColor = TEXT_COLOR;\r
91   /** The Y axis labels color. */\r
92   private int[] mYLabelsColor = new int[] { TEXT_COLOR };\r
93   /**\r
94    * If X axis value selection algorithm to be used. Only used by the time\r
95    * charts.\r
96    */\r
97   private boolean mXRoundedLabels = true;\r
98 \r
99   /**\r
100    * An enum for the XY chart orientation of the X axis.\r
101    */\r
102   public enum Orientation {\r
103     HORIZONTAL(0), VERTICAL(90);\r
104     /** The rotate angle. */\r
105     private int mAngle = 0;\r
106 \r
107     private Orientation(int angle) {\r
108       mAngle = angle;\r
109     }\r
110 \r
111     /**\r
112      * Return the orientation rotate angle.\r
113      * \r
114      * @return the orientaion rotate angle\r
115      */\r
116     public int getAngle() {\r
117       return mAngle;\r
118     }\r
119   }\r
120 \r
121   public XYMultipleSeriesRenderer() {\r
122     this(1);\r
123   }\r
124 \r
125   public XYMultipleSeriesRenderer(int scaleNumber) {\r
126     scalesCount = scaleNumber;\r
127     initAxesRange(scaleNumber);\r
128   }\r
129 \r
130   public void initAxesRange(int scales) {\r
131     mYTitle = new String[scales];\r
132     yLabelsAlign = new Align[scales];\r
133     yAxisAlign = new Align[scales];\r
134     mYLabelsColor = new int[scales];\r
135     mMinX = new double[scales];\r
136     mMaxX = new double[scales];\r
137     mMinY = new double[scales];\r
138     mMaxY = new double[scales];\r
139     for (int i = 0; i < scales; i++) {\r
140       mYLabelsColor[i] = TEXT_COLOR;\r
141       initAxesRangeForScale(i);\r
142     }\r
143   }\r
144 \r
145   public void initAxesRangeForScale(int i) {\r
146     mMinX[i] = MathHelper.NULL_VALUE;\r
147     mMaxX[i] = -MathHelper.NULL_VALUE;\r
148     mMinY[i] = MathHelper.NULL_VALUE;\r
149     mMaxY[i] = -MathHelper.NULL_VALUE;\r
150     double[] range = new double[] { mMinX[i], mMaxX[i], mMinY[i], mMaxY[i] };\r
151     initialRange.put(i, range);\r
152     mYTitle[i] = "";\r
153     mYTextLabels.put(i, new HashMap<Double, String>());\r
154     yLabelsAlign[i] = Align.CENTER;\r
155     yAxisAlign[i] = Align.LEFT;\r
156   }\r
157 \r
158   /**\r
159    * Returns the current orientation of the chart X axis.\r
160    * \r
161    * @return the chart orientation\r
162    */\r
163   public Orientation getOrientation() {\r
164     return mOrientation;\r
165   }\r
166 \r
167   /**\r
168    * Sets the current orientation of the chart X axis.\r
169    * \r
170    * @param orientation the chart orientation\r
171    */\r
172   public void setOrientation(Orientation orientation) {\r
173     mOrientation = orientation;\r
174   }\r
175 \r
176   /**\r
177    * Returns the title for the X axis.\r
178    * \r
179    * @return the X axis title\r
180    */\r
181   public String getXTitle() {\r
182     return mXTitle;\r
183   }\r
184 \r
185   /**\r
186    * Sets the title for the X axis.\r
187    * \r
188    * @param title the X axis title\r
189    */\r
190   public void setXTitle(String title) {\r
191     mXTitle = title;\r
192   }\r
193 \r
194   /**\r
195    * Returns the title for the Y axis.\r
196    * \r
197    * @return the Y axis title\r
198    */\r
199   public String getYTitle() {\r
200     return getYTitle(0);\r
201   }\r
202 \r
203   /**\r
204    * Returns the title for the Y axis.\r
205    * \r
206    * @param scale the renderer scale\r
207    * @return the Y axis title\r
208    */\r
209   public String getYTitle(int scale) {\r
210     return mYTitle[scale];\r
211   }\r
212 \r
213   /**\r
214    * Sets the title for the Y axis.\r
215    * \r
216    * @param title the Y axis title\r
217    */\r
218   public void setYTitle(String title) {\r
219     setYTitle(title, 0);\r
220   }\r
221 \r
222   /**\r
223    * Sets the title for the Y axis.\r
224    * \r
225    * @param title the Y axis title\r
226    * @param scale the renderer scale\r
227    */\r
228   public void setYTitle(String title, int scale) {\r
229     mYTitle[scale] = title;\r
230   }\r
231 \r
232   /**\r
233    * Returns the axis title text size.\r
234    * \r
235    * @return the axis title text size\r
236    */\r
237   public float getAxisTitleTextSize() {\r
238     return mAxisTitleTextSize;\r
239   }\r
240 \r
241   /**\r
242    * Sets the axis title text size.\r
243    * \r
244    * @param textSize the chart axis text size\r
245    */\r
246   public void setAxisTitleTextSize(float textSize) {\r
247     mAxisTitleTextSize = textSize;\r
248   }\r
249 \r
250   /**\r
251    * Returns the start value of the X axis range.\r
252    * \r
253    * @return the X axis range start value\r
254    */\r
255   public double getXAxisMin() {\r
256     return getXAxisMin(0);\r
257   }\r
258 \r
259   /**\r
260    * Sets the start value of the X axis range.\r
261    * \r
262    * @param min the X axis range start value\r
263    */\r
264   public void setXAxisMin(double min) {\r
265     setXAxisMin(min, 0);\r
266   }\r
267 \r
268   /**\r
269    * Returns if the minimum X value was set.\r
270    * \r
271    * @return the minX was set or not\r
272    */\r
273   public boolean isMinXSet() {\r
274     return isMinXSet(0);\r
275   }\r
276 \r
277   /**\r
278    * Returns the end value of the X axis range.\r
279    * \r
280    * @return the X axis range end value\r
281    */\r
282   public double getXAxisMax() {\r
283     return getXAxisMax(0);\r
284   }\r
285 \r
286   /**\r
287    * Sets the end value of the X axis range.\r
288    * \r
289    * @param max the X axis range end value\r
290    */\r
291   public void setXAxisMax(double max) {\r
292     setXAxisMax(max, 0);\r
293   }\r
294 \r
295   /**\r
296    * Returns if the maximum X value was set.\r
297    * \r
298    * @return the maxX was set or not\r
299    */\r
300   public boolean isMaxXSet() {\r
301     return isMaxXSet(0);\r
302   }\r
303 \r
304   /**\r
305    * Returns the start value of the Y axis range.\r
306    * \r
307    * @return the Y axis range end value\r
308    */\r
309   public double getYAxisMin() {\r
310     return getYAxisMin(0);\r
311   }\r
312 \r
313   /**\r
314    * Sets the start value of the Y axis range.\r
315    * \r
316    * @param min the Y axis range start value\r
317    */\r
318   public void setYAxisMin(double min) {\r
319     setYAxisMin(min, 0);\r
320   }\r
321 \r
322   /**\r
323    * Returns if the minimum Y value was set.\r
324    * \r
325    * @return the minY was set or not\r
326    */\r
327   public boolean isMinYSet() {\r
328     return isMinYSet(0);\r
329   }\r
330 \r
331   /**\r
332    * Returns the end value of the Y axis range.\r
333    * \r
334    * @return the Y axis range end value\r
335    */\r
336   public double getYAxisMax() {\r
337     return getYAxisMax(0);\r
338   }\r
339 \r
340   /**\r
341    * Sets the end value of the Y axis range.\r
342    * \r
343    * @param max the Y axis range end value\r
344    */\r
345   public void setYAxisMax(double max) {\r
346     setYAxisMax(max, 0);\r
347   }\r
348 \r
349   /**\r
350    * Returns if the maximum Y value was set.\r
351    * \r
352    * @return the maxY was set or not\r
353    */\r
354   public boolean isMaxYSet() {\r
355     return isMaxYSet(0);\r
356   }\r
357 \r
358   /**\r
359    * Returns the start value of the X axis range.\r
360    * \r
361    * @param scale the renderer scale\r
362    * @return the X axis range start value\r
363    */\r
364   public double getXAxisMin(int scale) {\r
365     return mMinX[scale];\r
366   }\r
367 \r
368   /**\r
369    * Sets the start value of the X axis range.\r
370    * \r
371    * @param min the X axis range start value\r
372    * @param scale the renderer scale\r
373    */\r
374   public void setXAxisMin(double min, int scale) {\r
375     if (!isMinXSet(scale)) {\r
376       initialRange.get(scale)[0] = min;\r
377     }\r
378     mMinX[scale] = min;\r
379   }\r
380 \r
381   /**\r
382    * Returns if the minimum X value was set.\r
383    * \r
384    * @param scale the renderer scale\r
385    * @return the minX was set or not\r
386    */\r
387   public boolean isMinXSet(int scale) {\r
388     return mMinX[scale] != MathHelper.NULL_VALUE;\r
389   }\r
390 \r
391   /**\r
392    * Returns the end value of the X axis range.\r
393    * \r
394    * @param scale the renderer scale\r
395    * @return the X axis range end value\r
396    */\r
397   public double getXAxisMax(int scale) {\r
398     return mMaxX[scale];\r
399   }\r
400 \r
401   /**\r
402    * Sets the end value of the X axis range.\r
403    * \r
404    * @param max the X axis range end value\r
405    * @param scale the renderer scale\r
406    */\r
407   public void setXAxisMax(double max, int scale) {\r
408     if (!isMaxXSet(scale)) {\r
409       initialRange.get(scale)[1] = max;\r
410     }\r
411     mMaxX[scale] = max;\r
412   }\r
413 \r
414   /**\r
415    * Returns if the maximum X value was set.\r
416    * \r
417    * @param scale the renderer scale\r
418    * @return the maxX was set or not\r
419    */\r
420   public boolean isMaxXSet(int scale) {\r
421     return mMaxX[scale] != -MathHelper.NULL_VALUE;\r
422   }\r
423 \r
424   /**\r
425    * Returns the start value of the Y axis range.\r
426    * \r
427    * @param scale the renderer scale\r
428    * @return the Y axis range end value\r
429    */\r
430   public double getYAxisMin(int scale) {\r
431     return mMinY[scale];\r
432   }\r
433 \r
434   /**\r
435    * Sets the start value of the Y axis range.\r
436    * \r
437    * @param min the Y axis range start value\r
438    * @param scale the renderer scale\r
439    */\r
440   public void setYAxisMin(double min, int scale) {\r
441     if (!isMinYSet(scale)) {\r
442       initialRange.get(scale)[2] = min;\r
443     }\r
444     mMinY[scale] = min;\r
445   }\r
446 \r
447   /**\r
448    * Returns if the minimum Y value was set.\r
449    * \r
450    * @param scale the renderer scale\r
451    * @return the minY was set or not\r
452    */\r
453   public boolean isMinYSet(int scale) {\r
454     return mMinY[scale] != MathHelper.NULL_VALUE;\r
455   }\r
456 \r
457   /**\r
458    * Returns the end value of the Y axis range.\r
459    * \r
460    * @param scale the renderer scale\r
461    * @return the Y axis range end value\r
462    */\r
463   public double getYAxisMax(int scale) {\r
464     return mMaxY[scale];\r
465   }\r
466 \r
467   /**\r
468    * Sets the end value of the Y axis range.\r
469    * \r
470    * @param max the Y axis range end value\r
471    * @param scale the renderer scale\r
472    */\r
473   public void setYAxisMax(double max, int scale) {\r
474     if (!isMaxYSet(scale)) {\r
475       initialRange.get(scale)[3] = max;\r
476     }\r
477     mMaxY[scale] = max;\r
478   }\r
479 \r
480   /**\r
481    * Returns if the maximum Y value was set.\r
482    * \r
483    * @param scale the renderer scale\r
484    * @return the maxY was set or not\r
485    */\r
486   public boolean isMaxYSet(int scale) {\r
487     return mMaxY[scale] != -MathHelper.NULL_VALUE;\r
488   }\r
489 \r
490   /**\r
491    * Returns the approximate number of labels for the X axis.\r
492    * \r
493    * @return the approximate number of labels for the X axis\r
494    */\r
495   public int getXLabels() {\r
496     return mXLabels;\r
497   }\r
498 \r
499   /**\r
500    * Sets the approximate number of labels for the X axis.\r
501    * \r
502    * @param xLabels the approximate number of labels for the X axis\r
503    */\r
504   public void setXLabels(int xLabels) {\r
505     mXLabels = xLabels;\r
506   }\r
507 \r
508   /**\r
509    * Adds a new text label for the specified X axis value.\r
510    * \r
511    * @param x the X axis value\r
512    * @param text the text label\r
513    * @deprecated use addXTextLabel instead\r
514    */\r
515   public void addTextLabel(double x, String text) {\r
516     addXTextLabel(x, text);\r
517   }\r
518 \r
519   /**\r
520    * Adds a new text label for the specified X axis value.\r
521    * \r
522    * @param x the X axis value\r
523    * @param text the text label\r
524    */\r
525   public void addXTextLabel(double x, String text) {\r
526     mXTextLabels.put(x, text);\r
527   }\r
528 \r
529   /**\r
530    * Returns the X axis text label at the specified X axis value.\r
531    * \r
532    * @param x the X axis value\r
533    * @return the X axis text label\r
534    */\r
535   public String getXTextLabel(Double x) {\r
536     return mXTextLabels.get(x);\r
537   }\r
538 \r
539   /**\r
540    * Returns the X text label locations.\r
541    * \r
542    * @return the X text label locations\r
543    */\r
544   public Double[] getXTextLabelLocations() {\r
545     return mXTextLabels.keySet().toArray(new Double[0]);\r
546   }\r
547 \r
548   /**\r
549    * Clears the existing text labels.\r
550    * \r
551    * @deprecated use clearXTextLabels instead\r
552    */\r
553   public void clearTextLabels() {\r
554     clearXTextLabels();\r
555   }\r
556 \r
557   /**\r
558    * Clears the existing text labels on the X axis.\r
559    */\r
560   public void clearXTextLabels() {\r
561     mXTextLabels.clear();\r
562   }\r
563 \r
564   /**\r
565    * If X axis labels should be rounded.\r
566    * \r
567    * @return if rounded time values to be used\r
568    */\r
569   public boolean isXRoundedLabels() {\r
570     return mXRoundedLabels;\r
571   }\r
572 \r
573   /**\r
574    * Sets if X axis rounded time values to be used.\r
575    * \r
576    * @param rounded rounded values to be used\r
577    */\r
578   public void setXRoundedLabels(boolean rounded) {\r
579     mXRoundedLabels = rounded;\r
580   }\r
581 \r
582   /**\r
583    * Adds a new text label for the specified Y axis value.\r
584    * \r
585    * @param y the Y axis value\r
586    * @param text the text label\r
587    */\r
588   public void addYTextLabel(double y, String text) {\r
589     addYTextLabel(y, text, 0);\r
590   }\r
591 \r
592   /**\r
593    * Adds a new text label for the specified Y axis value.\r
594    * \r
595    * @param y the Y axis value\r
596    * @param text the text label\r
597    * @param scale the renderer scale\r
598    */\r
599   public void addYTextLabel(double y, String text, int scale) {\r
600     mYTextLabels.get(scale).put(y, text);\r
601   }\r
602 \r
603   /**\r
604    * Returns the Y axis text label at the specified Y axis value.\r
605    * \r
606    * @param y the Y axis value\r
607    * @return the Y axis text label\r
608    */\r
609   public String getYTextLabel(Double y) {\r
610     return getYTextLabel(y, 0);\r
611   }\r
612 \r
613   /**\r
614    * Returns the Y axis text label at the specified Y axis value.\r
615    * \r
616    * @param y the Y axis value\r
617    * @param scale the renderer scale\r
618    * @return the Y axis text label\r
619    */\r
620   public String getYTextLabel(Double y, int scale) {\r
621     return mYTextLabels.get(scale).get(y);\r
622   }\r
623 \r
624   /**\r
625    * Returns the Y text label locations.\r
626    * \r
627    * @return the Y text label locations\r
628    */\r
629   public Double[] getYTextLabelLocations() {\r
630     return getYTextLabelLocations(0);\r
631   }\r
632 \r
633   /**\r
634    * Returns the Y text label locations.\r
635    * \r
636    * @param scale the renderer scale\r
637    * @return the Y text label locations\r
638    */\r
639   public Double[] getYTextLabelLocations(int scale) {\r
640     return mYTextLabels.get(scale).keySet().toArray(new Double[0]);\r
641   }\r
642 \r
643   /**\r
644    * Clears the existing text labels on the Y axis.\r
645    */\r
646   public void clearYTextLabels() {\r
647     clearYTextLabels(0);\r
648   }\r
649 \r
650   /**\r
651    * Clears the existing text labels on the Y axis.\r
652    * \r
653    * @param scale the renderer scale\r
654    */\r
655   public void clearYTextLabels(int scale) {\r
656     mYTextLabels.get(scale).clear();\r
657   }\r
658 \r
659   /**\r
660    * Returns the approximate number of labels for the Y axis.\r
661    * \r
662    * @return the approximate number of labels for the Y axis\r
663    */\r
664   public int getYLabels() {\r
665     return mYLabels;\r
666   }\r
667 \r
668   /**\r
669    * Sets the approximate number of labels for the Y axis.\r
670    * \r
671    * @param yLabels the approximate number of labels for the Y axis\r
672    */\r
673   public void setYLabels(int yLabels) {\r
674     mYLabels = yLabels;\r
675   }\r
676 \r
677   /**\r
678    * Sets if the chart point values should be displayed as text.\r
679    * \r
680    * @param display if the chart point values should be displayed as text\r
681    * @deprecated use SimpleSeriesRenderer.setDisplayChartValues() instead\r
682    */\r
683   public void setDisplayChartValues(boolean display) {\r
684     SimpleSeriesRenderer[] renderers = getSeriesRenderers();\r
685     for (SimpleSeriesRenderer renderer : renderers) {\r
686       renderer.setDisplayChartValues(display);\r
687     }\r
688   }\r
689 \r
690   /**\r
691    * Sets the chart values text size.\r
692    * \r
693    * @param textSize the chart values text size\r
694    * @deprecated use SimpleSeriesRenderer.setChartValuesTextSize() instead\r
695    */\r
696   public void setChartValuesTextSize(float textSize) {\r
697     SimpleSeriesRenderer[] renderers = getSeriesRenderers();\r
698     for (SimpleSeriesRenderer renderer : renderers) {\r
699       renderer.setChartValuesTextSize(textSize);\r
700     }\r
701   }\r
702 \r
703   /**\r
704    * Returns the enabled state of the pan on at least one axis.\r
705    * \r
706    * @return if pan is enabled\r
707    */\r
708   public boolean isPanEnabled() {\r
709     return isPanXEnabled() || isPanYEnabled();\r
710   }\r
711 \r
712   /**\r
713    * Returns the enabled state of the pan on X axis.\r
714    * \r
715    * @return if pan is enabled on X axis\r
716    */\r
717   public boolean isPanXEnabled() {\r
718     return mPanXEnabled;\r
719   }\r
720 \r
721   /**\r
722    * Returns the enabled state of the pan on Y axis.\r
723    * \r
724    * @return if pan is enabled on Y axis\r
725    */\r
726   public boolean isPanYEnabled() {\r
727     return mPanYEnabled;\r
728   }\r
729 \r
730   /**\r
731    * Sets the enabled state of the pan.\r
732    * \r
733    * @param enabledX pan enabled on X axis\r
734    * @param enabledY pan enabled on Y axis\r
735    */\r
736   public void setPanEnabled(boolean enabledX, boolean enabledY) {\r
737     mPanXEnabled = enabledX;\r
738     mPanYEnabled = enabledY;\r
739   }\r
740 \r
741   /**\r
742    * Returns the enabled state of the zoom on at least one axis.\r
743    * \r
744    * @return if zoom is enabled\r
745    */\r
746   public boolean isZoomEnabled() {\r
747     return isZoomXEnabled() || isZoomYEnabled();\r
748   }\r
749 \r
750   /**\r
751    * Returns the enabled state of the zoom on X axis.\r
752    * \r
753    * @return if zoom is enabled on X axis\r
754    */\r
755   public boolean isZoomXEnabled() {\r
756     return mZoomXEnabled;\r
757   }\r
758 \r
759   /**\r
760    * Returns the enabled state of the zoom on Y axis.\r
761    * \r
762    * @return if zoom is enabled on Y axis\r
763    */\r
764   public boolean isZoomYEnabled() {\r
765     return mZoomYEnabled;\r
766   }\r
767 \r
768   /**\r
769    * Sets the enabled state of the zoom.\r
770    * \r
771    * @param enabledX zoom enabled on X axis\r
772    * @param enabledY zoom enabled on Y axis\r
773    */\r
774   public void setZoomEnabled(boolean enabledX, boolean enabledY) {\r
775     mZoomXEnabled = enabledX;\r
776     mZoomYEnabled = enabledY;\r
777   }\r
778 \r
779   /**\r
780    * Returns the spacing between bars, in bar charts.\r
781    * \r
782    * @return the spacing between bars\r
783    * @deprecated use getBarSpacing instead\r
784    */\r
785   public double getBarsSpacing() {\r
786     return getBarSpacing();\r
787   }\r
788 \r
789   /**\r
790    * Returns the spacing between bars, in bar charts.\r
791    * \r
792    * @return the spacing between bars\r
793    */\r
794   public double getBarSpacing() {\r
795     return mBarSpacing;\r
796   }\r
797 \r
798   /**\r
799    * Sets the spacing between bars, in bar charts. Only available for bar\r
800    * charts. This is a coefficient of the bar width. For instance, if you want\r
801    * the spacing to be a half of the bar width, set this value to 0.5.\r
802    * \r
803    * @param spacing the spacing between bars coefficient\r
804    */\r
805   public void setBarSpacing(double spacing) {\r
806     mBarSpacing = spacing;\r
807   }\r
808 \r
809   /**\r
810    * Returns the margins color.\r
811    * \r
812    * @return the margins color\r
813    */\r
814   public int getMarginsColor() {\r
815     return mMarginsColor;\r
816   }\r
817 \r
818   /**\r
819    * Sets the color of the margins.\r
820    * \r
821    * @param color the margins color\r
822    */\r
823   public void setMarginsColor(int color) {\r
824     mMarginsColor = color;\r
825   }\r
826 \r
827   /**\r
828    * Returns the grid color.\r
829    * \r
830    * @return the grid color\r
831    */\r
832   public int getGridColor() {\r
833     return mGridColor;\r
834   }\r
835 \r
836   /**\r
837    * Sets the color of the grid.\r
838    * \r
839    * @param color the grid color\r
840    */\r
841   public void setGridColor(int color) {\r
842     mGridColor = color;\r
843   }\r
844 \r
845   /**\r
846    * Returns the pan limits.\r
847    * \r
848    * @return the pan limits\r
849    */\r
850   public double[] getPanLimits() {\r
851     return mPanLimits;\r
852   }\r
853 \r
854   /**\r
855    * Sets the pan limits as an array of 4 values. Setting it to null or a\r
856    * different size array will disable the panning limitation. Values:\r
857    * [panMinimumX, panMaximumX, panMinimumY, panMaximumY]\r
858    * \r
859    * @param panLimits the pan limits\r
860    */\r
861   public void setPanLimits(double[] panLimits) {\r
862     mPanLimits = panLimits;\r
863   }\r
864 \r
865   /**\r
866    * Returns the zoom limits.\r
867    * \r
868    * @return the zoom limits\r
869    */\r
870   public double[] getZoomLimits() {\r
871     return mZoomLimits;\r
872   }\r
873 \r
874   /**\r
875    * Sets the zoom limits as an array of 4 values. Setting it to null or a\r
876    * different size array will disable the zooming limitation. Values:\r
877    * [zoomMinimumX, zoomMaximumX, zoomMinimumY, zoomMaximumY]\r
878    * \r
879    * @param zoomLimits the zoom limits\r
880    */\r
881   public void setZoomLimits(double[] zoomLimits) {\r
882     mZoomLimits = zoomLimits;\r
883   }\r
884 \r
885   /**\r
886    * Returns the rotation angle of labels for the X axis.\r
887    * \r
888    * @return the rotation angle of labels for the X axis\r
889    */\r
890   public float getXLabelsAngle() {\r
891     return mXLabelsAngle;\r
892   }\r
893 \r
894   /**\r
895    * Sets the rotation angle (in degrees) of labels for the X axis.\r
896    * \r
897    * @param angle the rotation angle of labels for the X axis\r
898    */\r
899   public void setXLabelsAngle(float angle) {\r
900     mXLabelsAngle = angle;\r
901   }\r
902 \r
903   /**\r
904    * Returns the rotation angle of labels for the Y axis.\r
905    * \r
906    * @return the approximate number of labels for the Y axis\r
907    */\r
908   public float getYLabelsAngle() {\r
909     return mYLabelsAngle;\r
910   }\r
911 \r
912   /**\r
913    * Sets the rotation angle (in degrees) of labels for the Y axis.\r
914    * \r
915    * @param angle the rotation angle of labels for the Y axis\r
916    */\r
917   public void setYLabelsAngle(float angle) {\r
918     mYLabelsAngle = angle;\r
919   }\r
920 \r
921   /**\r
922    * Returns the size of the points, for charts displaying points.\r
923    * \r
924    * @return the point size\r
925    */\r
926   public float getPointSize() {\r
927     return mPointSize;\r
928   }\r
929 \r
930   /**\r
931    * Sets the size of the points, for charts displaying points.\r
932    * \r
933    * @param size the point size\r
934    */\r
935   public void setPointSize(float size) {\r
936     mPointSize = size;\r
937   }\r
938 \r
939   public void setRange(double[] range) {\r
940     setRange(range, 0);\r
941   }\r
942 \r
943   /**\r
944    * Sets the axes range values.\r
945    * \r
946    * @param range an array having the values in this order: minX, maxX, minY,\r
947    *          maxY\r
948    * @param scale the renderer scale\r
949    */\r
950   public void setRange(double[] range, int scale) {\r
951     setXAxisMin(range[0], scale);\r
952     setXAxisMax(range[1], scale);\r
953     setYAxisMin(range[2], scale);\r
954     setYAxisMax(range[3], scale);\r
955   }\r
956 \r
957   public boolean isInitialRangeSet() {\r
958     return isInitialRangeSet(0);\r
959   }\r
960 \r
961   /**\r
962    * Returns if the initial range is set.\r
963    * \r
964    * @param scale the renderer scale\r
965    * @return the initial range was set or not\r
966    */\r
967   public boolean isInitialRangeSet(int scale) {\r
968     return initialRange.get(scale) != null;\r
969   }\r
970 \r
971   /**\r
972    * Returns the initial range.\r
973    * \r
974    * @return the initial range\r
975    */\r
976   public double[] getInitialRange() {\r
977     return getInitialRange(0);\r
978   }\r
979 \r
980   /**\r
981    * Returns the initial range.\r
982    * \r
983    * @param scale the renderer scale\r
984    * @return the initial range\r
985    */\r
986   public double[] getInitialRange(int scale) {\r
987     return initialRange.get(scale);\r
988   }\r
989 \r
990   /**\r
991    * Sets the axes initial range values. This will be used in the zoom fit tool.\r
992    * \r
993    * @param range an array having the values in this order: minX, maxX, minY,\r
994    *          maxY\r
995    */\r
996   public void setInitialRange(double[] range) {\r
997     setInitialRange(range, 0);\r
998   }\r
999 \r
1000   /**\r
1001    * Sets the axes initial range values. This will be used in the zoom fit tool.\r
1002    * \r
1003    * @param range an array having the values in this order: minX, maxX, minY,\r
1004    *          maxY\r
1005    * @param scale the renderer scale\r
1006    */\r
1007   public void setInitialRange(double[] range, int scale) {\r
1008     initialRange.put(scale, range);\r
1009   }\r
1010 \r
1011   /**\r
1012    * Returns the X axis labels color.\r
1013    * \r
1014    * @return the X axis labels color\r
1015    */\r
1016   public int getXLabelsColor() {\r
1017     return mXLabelsColor;\r
1018   }\r
1019 \r
1020   /**\r
1021    * Returns the Y axis labels color.\r
1022    * \r
1023    * @return the Y axis labels color\r
1024    */\r
1025   public int getYLabelsColor(int scale) {\r
1026     return mYLabelsColor[scale];\r
1027   }\r
1028 \r
1029   /**\r
1030    * Sets the X axis labels color.\r
1031    * \r
1032    * @param color the X axis labels color\r
1033    */\r
1034   public void setXLabelsColor(int color) {\r
1035     mXLabelsColor = color;\r
1036   }\r
1037 \r
1038   /**\r
1039    * Sets the Y axis labels color.\r
1040    * \r
1041    * @param scale the renderer scale\r
1042    * @param color the Y axis labels color\r
1043    */\r
1044   public void setYLabelsColor(int scale, int color) {\r
1045     mYLabelsColor[scale] = color;\r
1046   }\r
1047 \r
1048   /**\r
1049    * Returns the X axis labels alignment.\r
1050    * \r
1051    * @return X labels alignment\r
1052    */\r
1053   public Align getXLabelsAlign() {\r
1054     return xLabelsAlign;\r
1055   }\r
1056 \r
1057   /**\r
1058    * Sets the X axis labels alignment.\r
1059    * \r
1060    * @param align the X labels alignment\r
1061    */\r
1062   public void setXLabelsAlign(Align align) {\r
1063     xLabelsAlign = align;\r
1064   }\r
1065 \r
1066   /**\r
1067    * Returns the Y axis labels alignment.\r
1068    * \r
1069    * @param scale the renderer scale\r
1070    * @return Y labels alignment\r
1071    */\r
1072   public Align getYLabelsAlign(int scale) {\r
1073     return yLabelsAlign[scale];\r
1074   }\r
1075 \r
1076   public void setYLabelsAlign(Align align) {\r
1077     setYLabelsAlign(align, 0);\r
1078   }\r
1079 \r
1080   public Align getYAxisAlign(int scale) {\r
1081     return yAxisAlign[scale];\r
1082   }\r
1083 \r
1084   public void setYAxisAlign(Align align, int scale) {\r
1085     yAxisAlign[scale] = align;\r
1086   }\r
1087 \r
1088   /**\r
1089    * Sets the Y axis labels alignment.\r
1090    * \r
1091    * @param align the Y labels alignment\r
1092    */\r
1093   public void setYLabelsAlign(Align align, int scale) {\r
1094     yLabelsAlign[scale] = align;\r
1095   }\r
1096 \r
1097   public int getScalesCount() {\r
1098     return scalesCount;\r
1099   }\r
1100 \r
1101 }\r