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.renderer;
\r
18 import java.util.ArrayList;
\r
19 import java.util.Arrays;
\r
20 import java.util.List;
\r
22 import org.achartengine.util.MathHelper;
\r
25 * Dial chart renderer.
\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
48 * Returns the start angle value of the dial.
\r
50 * @return the angle start value
\r
52 public double getAngleMin() {
\r
57 * Sets the start angle value of the dial.
\r
59 * @param min the dial angle start value
\r
61 public void setAngleMin(double min) {
\r
66 * Returns the end angle value of the dial.
\r
68 * @return the angle end value
\r
70 public double getAngleMax() {
\r
75 * Sets the end angle value of the dial.
\r
77 * @param max the dial angle end value
\r
79 public void setAngleMax(double max) {
\r
84 * Returns the start value to be rendered on the dial.
\r
86 * @return the start value on dial
\r
88 public double getMinValue() {
\r
93 * Sets the start value to be rendered on the dial.
\r
95 * @param min the start value on the dial
\r
97 public void setMinValue(double min) {
\r
102 * Returns if the minimum dial value was set.
\r
104 * @return the minimum dial value was set or not
\r
106 public boolean isMinValueSet() {
\r
107 return mMinValue != MathHelper.NULL_VALUE;
\r
111 * Returns the end value to be rendered on the dial.
\r
113 * @return the end value on the dial
\r
115 public double getMaxValue() {
\r
120 * Sets the end value to be rendered on the dial.
\r
122 * @param max the end value on the dial
\r
124 public void setMaxValue(double max) {
\r
129 * Returns if the maximum dial value was set.
\r
131 * @return the maximum dial was set or not
\r
133 public boolean isMaxValueSet() {
\r
134 return mMaxValue != -MathHelper.NULL_VALUE;
\r
138 * Returns the minor ticks spacing.
\r
140 * @return the minor ticks spacing
\r
142 public double getMinorTicksSpacing() {
\r
143 return mMinorTickSpacing;
\r
147 * Sets the minor ticks spacing.
\r
149 * @param spacing the minor ticks spacing
\r
151 public void setMinorTicksSpacing(double spacing) {
\r
152 mMinorTickSpacing = spacing;
\r
156 * Returns the major ticks spacing.
\r
158 * @return the major ticks spacing
\r
160 public double getMajorTicksSpacing() {
\r
161 return mMajorTickSpacing;
\r
165 * Sets the major ticks spacing.
\r
167 * @param spacing the major ticks spacing
\r
169 public void setMajorTicksSpacing(double spacing) {
\r
170 mMajorTickSpacing = spacing;
\r
174 * Returns the visual type at the specified index.
\r
176 * @param index the index
\r
177 * @return the visual type
\r
179 public Type getVisualTypeForIndex(int index) {
\r
180 if (index < mVisualTypes.size()) {
\r
181 return mVisualTypes.get(index);
\r
183 return Type.NEEDLE;
\r
187 * Sets the visual types.
\r
189 * @param types the visual types
\r
191 public void setVisualTypes(Type[] types) {
\r
192 mVisualTypes.clear();
\r
193 mVisualTypes.addAll(Arrays.asList(types));
\r