Merge commit '42b2e5ca519766e37ce6941ba4faecc9691cc403' into upstream
[debian/openrocket] / android-libraries / achartengine / src / org / achartengine / chart / RoundChart.java
diff --git a/android-libraries/achartengine/src/org/achartengine/chart/RoundChart.java b/android-libraries/achartengine/src/org/achartengine/chart/RoundChart.java
new file mode 100644 (file)
index 0000000..1a2121d
--- /dev/null
@@ -0,0 +1,143 @@
+/**\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.chart;\r
+\r
+import org.achartengine.model.CategorySeries;\r
+import org.achartengine.renderer.DefaultRenderer;\r
+import org.achartengine.renderer.SimpleSeriesRenderer;\r
+\r
+import android.graphics.Canvas;\r
+import android.graphics.Paint;\r
+import android.graphics.Paint.Align;\r
+\r
+/**\r
+ * An abstract class to be extended by round like chart rendering classes.\r
+ */\r
+public abstract class RoundChart extends AbstractChart {\r
+  /** The legend shape width. */\r
+  protected static final int SHAPE_WIDTH = 10;\r
+  /** The series dataset. */\r
+  protected CategorySeries mDataset;\r
+  /** The series renderer. */\r
+  protected DefaultRenderer mRenderer;\r
+  /** A no value constant. */\r
+  protected static final int NO_VALUE = Integer.MAX_VALUE;\r
+  /** The chart center X axis. */\r
+  protected int mCenterX = NO_VALUE;\r
+  /** The chart center y axis. */\r
+  protected int mCenterY = NO_VALUE;\r
+\r
+  /**\r
+   * Round chart.\r
+   * \r
+   * @param dataset the series dataset\r
+   * @param renderer the series renderer\r
+   */\r
+  public RoundChart(CategorySeries dataset, DefaultRenderer renderer) {\r
+    mDataset = dataset;\r
+    mRenderer = renderer;\r
+  }\r
+\r
+  /**\r
+   * The graphical representation of the round chart title.\r
+   * \r
+   * @param canvas the canvas to paint to\r
+   * @param x the top left x value of the view to draw to\r
+   * @param y the top left y value of the view to draw to\r
+   * @param width the width of the view to draw to\r
+   * @param paint the paint\r
+   */\r
+  public void drawTitle(Canvas canvas, int x, int y, int width, Paint paint) {\r
+    if (mRenderer.isShowLabels()) {\r
+      paint.setColor(mRenderer.getLabelsColor());\r
+      paint.setTextAlign(Align.CENTER);\r
+      paint.setTextSize(mRenderer.getChartTitleTextSize());\r
+      drawString(canvas, mRenderer.getChartTitle(), x + width / 2,\r
+          y + mRenderer.getChartTitleTextSize(), paint);\r
+    }\r
+  }\r
+\r
+  /**\r
+   * Returns the legend shape width.\r
+   * \r
+   * @param seriesIndex the series index\r
+   * @return the legend shape width\r
+   */\r
+  public int getLegendShapeWidth(int seriesIndex) {\r
+    return SHAPE_WIDTH;\r
+  }\r
+\r
+  /**\r
+   * The graphical representation of the legend shape.\r
+   * \r
+   * @param canvas the canvas to paint to\r
+   * @param renderer the series renderer\r
+   * @param x the x value of the point the shape should be drawn at\r
+   * @param y the y value of the point the shape should be drawn at\r
+   * @param seriesIndex the series index\r
+   * @param paint the paint to be used for drawing\r
+   */\r
+  public void drawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float x, float y,\r
+      int seriesIndex, Paint paint) {\r
+    canvas.drawRect(x, y - SHAPE_WIDTH / 2, x + SHAPE_WIDTH, y + SHAPE_WIDTH / 2, paint);\r
+  }\r
+\r
+  /**\r
+   * Returns the renderer.\r
+   * \r
+   * @return the renderer\r
+   */\r
+  public DefaultRenderer getRenderer() {\r
+    return mRenderer;\r
+  }\r
+\r
+  /**\r
+   * Returns the center on X axis.\r
+   * \r
+   * @return the center on X axis\r
+   */\r
+  public int getCenterX() {\r
+    return mCenterX;\r
+  }\r
+\r
+  /**\r
+   * Returns the center on Y axis.\r
+   * \r
+   * @return the center on Y axis\r
+   */\r
+  public int getCenterY() {\r
+    return mCenterY;\r
+  }\r
+\r
+  /**\r
+   * Sets a new center on X axis.\r
+   * \r
+   * @param centerX center on X axis\r
+   */\r
+  public void setCenterX(int centerX) {\r
+    mCenterX = centerX;\r
+  }\r
+\r
+  /**\r
+   * Sets a new center on Y axis.\r
+   * \r
+   * @param centerY center on Y axis\r
+   */\r
+  public void setCenterY(int centerY) {\r
+    mCenterY = centerY;\r
+  }\r
+\r
+}\r