Merge commit '42b2e5ca519766e37ce6941ba4faecc9691cc403' into upstream
[debian/openrocket] / android-libraries / achartengine / src / org / achartengine / renderer / DialRenderer.java
diff --git a/android-libraries/achartengine/src/org/achartengine/renderer/DialRenderer.java b/android-libraries/achartengine/src/org/achartengine/renderer/DialRenderer.java
new file mode 100644 (file)
index 0000000..1ed8461
--- /dev/null
@@ -0,0 +1,196 @@
+/**\r
+ * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL\r
+ *  \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *  \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *  \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.achartengine.renderer;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+import java.util.List;\r
+\r
+import org.achartengine.util.MathHelper;\r
+\r
+/**\r
+ * Dial chart renderer.\r
+ */\r
+public class DialRenderer extends DefaultRenderer {\r
+  /** The start angle in the dial range. */\r
+  private double mAngleMin = 330;\r
+  /** The end angle in the dial range. */\r
+  private double mAngleMax = 30;\r
+  /** The start value in dial range. */\r
+  private double mMinValue = MathHelper.NULL_VALUE;\r
+  /** The end value in dial range. */\r
+  private double mMaxValue = -MathHelper.NULL_VALUE;\r
+  /** The spacing for the minor ticks. */\r
+  private double mMinorTickSpacing = MathHelper.NULL_VALUE;\r
+  /** The spacing for the major ticks. */\r
+  private double mMajorTickSpacing = MathHelper.NULL_VALUE;\r
+  /** An array of the renderers types (default is NEEDLE). */\r
+  private List<Type> mVisualTypes = new ArrayList<Type>();\r
+\r
+  public enum Type {\r
+    NEEDLE, ARROW;\r
+  }\r
+\r
+  /**\r
+   * Returns the start angle value of the dial.\r
+   * \r
+   * @return the angle start value\r
+   */\r
+  public double getAngleMin() {\r
+    return mAngleMin;\r
+  }\r
+\r
+  /**\r
+   * Sets the start angle value of the dial.\r
+   * \r
+   * @param min the dial angle start value\r
+   */\r
+  public void setAngleMin(double min) {\r
+    mAngleMin = min;\r
+  }\r
+\r
+  /**\r
+   * Returns the end angle value of the dial.\r
+   * \r
+   * @return the angle end value\r
+   */\r
+  public double getAngleMax() {\r
+    return mAngleMax;\r
+  }\r
+\r
+  /**\r
+   * Sets the end angle value of the dial.\r
+   * \r
+   * @param max the dial angle end value\r
+   */\r
+  public void setAngleMax(double max) {\r
+    mAngleMax = max;\r
+  }\r
+\r
+  /**\r
+   * Returns the start value to be rendered on the dial.\r
+   * \r
+   * @return the start value on dial\r
+   */\r
+  public double getMinValue() {\r
+    return mMinValue;\r
+  }\r
+\r
+  /**\r
+   * Sets the start value to be rendered on the dial.\r
+   * \r
+   * @param min the start value on the dial\r
+   */\r
+  public void setMinValue(double min) {\r
+    mMinValue = min;\r
+  }\r
+\r
+  /**\r
+   * Returns if the minimum dial value was set.\r
+   * \r
+   * @return the minimum dial value was set or not\r
+   */\r
+  public boolean isMinValueSet() {\r
+    return mMinValue != MathHelper.NULL_VALUE;\r
+  }\r
+\r
+  /**\r
+   * Returns the end value to be rendered on the dial.\r
+   * \r
+   * @return the end value on the dial\r
+   */\r
+  public double getMaxValue() {\r
+    return mMaxValue;\r
+  }\r
+\r
+  /**\r
+   * Sets the end value to be rendered on the dial.\r
+   * \r
+   * @param max the end value on the dial\r
+   */\r
+  public void setMaxValue(double max) {\r
+    mMaxValue = max;\r
+  }\r
+\r
+  /**\r
+   * Returns if the maximum dial value was set.\r
+   * \r
+   * @return the maximum dial was set or not\r
+   */\r
+  public boolean isMaxValueSet() {\r
+    return mMaxValue != -MathHelper.NULL_VALUE;\r
+  }\r
+\r
+  /**\r
+   * Returns the minor ticks spacing.\r
+   * \r
+   * @return the minor ticks spacing\r
+   */\r
+  public double getMinorTicksSpacing() {\r
+    return mMinorTickSpacing;\r
+  }\r
+\r
+  /**\r
+   * Sets the minor ticks spacing.\r
+   * \r
+   * @param spacing the minor ticks spacing\r
+   */\r
+  public void setMinorTicksSpacing(double spacing) {\r
+    mMinorTickSpacing = spacing;\r
+  }\r
+\r
+  /**\r
+   * Returns the major ticks spacing.\r
+   * \r
+   * @return the major ticks spacing\r
+   */\r
+  public double getMajorTicksSpacing() {\r
+    return mMajorTickSpacing;\r
+  }\r
+\r
+  /**\r
+   * Sets the major ticks spacing.\r
+   * \r
+   * @param spacing the major ticks spacing\r
+   */\r
+  public void setMajorTicksSpacing(double spacing) {\r
+    mMajorTickSpacing = spacing;\r
+  }\r
+\r
+  /**\r
+   * Returns the visual type at the specified index.\r
+   * \r
+   * @param index the index\r
+   * @return the visual type\r
+   */\r
+  public Type getVisualTypeForIndex(int index) {\r
+    if (index < mVisualTypes.size()) {\r
+      return mVisualTypes.get(index);\r
+    }\r
+    return Type.NEEDLE;\r
+  }\r
+\r
+  /**\r
+   * Sets the visual types.\r
+   * \r
+   * @param types the visual types\r
+   */\r
+  public void setVisualTypes(Type[] types) {\r
+    mVisualTypes.clear();\r
+    mVisualTypes.addAll(Arrays.asList(types));\r
+  }\r
+\r
+}\r