create changelog entry
[debian/openrocket] / android-libraries / achartengine / src / org / achartengine / renderer / DialRenderer.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.ArrayList;\r
19 import java.util.Arrays;\r
20 import java.util.List;\r
21 \r
22 import org.achartengine.util.MathHelper;\r
23 \r
24 /**\r
25  * Dial chart renderer.\r
26  */\r
27 public class DialRenderer extends DefaultRenderer {\r
28   /** The start angle in the dial range. */\r
29   private double mAngleMin = 330;\r
30   /** The end angle in the dial range. */\r
31   private double mAngleMax = 30;\r
32   /** The start value in dial range. */\r
33   private double mMinValue = MathHelper.NULL_VALUE;\r
34   /** The end value in dial range. */\r
35   private double mMaxValue = -MathHelper.NULL_VALUE;\r
36   /** The spacing for the minor ticks. */\r
37   private double mMinorTickSpacing = MathHelper.NULL_VALUE;\r
38   /** The spacing for the major ticks. */\r
39   private double mMajorTickSpacing = MathHelper.NULL_VALUE;\r
40   /** An array of the renderers types (default is NEEDLE). */\r
41   private List<Type> mVisualTypes = new ArrayList<Type>();\r
42 \r
43   public enum Type {\r
44     NEEDLE, ARROW;\r
45   }\r
46 \r
47   /**\r
48    * Returns the start angle value of the dial.\r
49    * \r
50    * @return the angle start value\r
51    */\r
52   public double getAngleMin() {\r
53     return mAngleMin;\r
54   }\r
55 \r
56   /**\r
57    * Sets the start angle value of the dial.\r
58    * \r
59    * @param min the dial angle start value\r
60    */\r
61   public void setAngleMin(double min) {\r
62     mAngleMin = min;\r
63   }\r
64 \r
65   /**\r
66    * Returns the end angle value of the dial.\r
67    * \r
68    * @return the angle end value\r
69    */\r
70   public double getAngleMax() {\r
71     return mAngleMax;\r
72   }\r
73 \r
74   /**\r
75    * Sets the end angle value of the dial.\r
76    * \r
77    * @param max the dial angle end value\r
78    */\r
79   public void setAngleMax(double max) {\r
80     mAngleMax = max;\r
81   }\r
82 \r
83   /**\r
84    * Returns the start value to be rendered on the dial.\r
85    * \r
86    * @return the start value on dial\r
87    */\r
88   public double getMinValue() {\r
89     return mMinValue;\r
90   }\r
91 \r
92   /**\r
93    * Sets the start value to be rendered on the dial.\r
94    * \r
95    * @param min the start value on the dial\r
96    */\r
97   public void setMinValue(double min) {\r
98     mMinValue = min;\r
99   }\r
100 \r
101   /**\r
102    * Returns if the minimum dial value was set.\r
103    * \r
104    * @return the minimum dial value was set or not\r
105    */\r
106   public boolean isMinValueSet() {\r
107     return mMinValue != MathHelper.NULL_VALUE;\r
108   }\r
109 \r
110   /**\r
111    * Returns the end value to be rendered on the dial.\r
112    * \r
113    * @return the end value on the dial\r
114    */\r
115   public double getMaxValue() {\r
116     return mMaxValue;\r
117   }\r
118 \r
119   /**\r
120    * Sets the end value to be rendered on the dial.\r
121    * \r
122    * @param max the end value on the dial\r
123    */\r
124   public void setMaxValue(double max) {\r
125     mMaxValue = max;\r
126   }\r
127 \r
128   /**\r
129    * Returns if the maximum dial value was set.\r
130    * \r
131    * @return the maximum dial was set or not\r
132    */\r
133   public boolean isMaxValueSet() {\r
134     return mMaxValue != -MathHelper.NULL_VALUE;\r
135   }\r
136 \r
137   /**\r
138    * Returns the minor ticks spacing.\r
139    * \r
140    * @return the minor ticks spacing\r
141    */\r
142   public double getMinorTicksSpacing() {\r
143     return mMinorTickSpacing;\r
144   }\r
145 \r
146   /**\r
147    * Sets the minor ticks spacing.\r
148    * \r
149    * @param spacing the minor ticks spacing\r
150    */\r
151   public void setMinorTicksSpacing(double spacing) {\r
152     mMinorTickSpacing = spacing;\r
153   }\r
154 \r
155   /**\r
156    * Returns the major ticks spacing.\r
157    * \r
158    * @return the major ticks spacing\r
159    */\r
160   public double getMajorTicksSpacing() {\r
161     return mMajorTickSpacing;\r
162   }\r
163 \r
164   /**\r
165    * Sets the major ticks spacing.\r
166    * \r
167    * @param spacing the major ticks spacing\r
168    */\r
169   public void setMajorTicksSpacing(double spacing) {\r
170     mMajorTickSpacing = spacing;\r
171   }\r
172 \r
173   /**\r
174    * Returns the visual type at the specified index.\r
175    * \r
176    * @param index the index\r
177    * @return the visual type\r
178    */\r
179   public Type getVisualTypeForIndex(int index) {\r
180     if (index < mVisualTypes.size()) {\r
181       return mVisualTypes.get(index);\r
182     }\r
183     return Type.NEEDLE;\r
184   }\r
185 \r
186   /**\r
187    * Sets the visual types.\r
188    * \r
189    * @param types the visual types\r
190    */\r
191   public void setVisualTypes(Type[] types) {\r
192     mVisualTypes.clear();\r
193     mVisualTypes.addAll(Arrays.asList(types));\r
194   }\r
195 \r
196 }\r