Merge commit '42b2e5ca519766e37ce6941ba4faecc9691cc403' into upstream
[debian/openrocket] / android-libraries / achartengine / src / org / achartengine / renderer / DefaultRenderer.java
diff --git a/android-libraries/achartengine/src/org/achartengine/renderer/DefaultRenderer.java b/android-libraries/achartengine/src/org/achartengine/renderer/DefaultRenderer.java
new file mode 100644 (file)
index 0000000..4dbb254
--- /dev/null
@@ -0,0 +1,750 @@
+/**\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.io.Serializable;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import android.graphics.Color;\r
+import android.graphics.Typeface;\r
+\r
+/**\r
+ * An abstract renderer to be extended by the multiple series classes.\r
+ */\r
+public class DefaultRenderer implements Serializable {\r
+  /** The chart title. */\r
+  private String mChartTitle = "";\r
+  /** The chart title text size. */\r
+  private float mChartTitleTextSize = 15;\r
+  /** A no color constant. */\r
+  public static final int NO_COLOR = 0;\r
+  /** The default background color. */\r
+  public static final int BACKGROUND_COLOR = Color.BLACK;\r
+  /** The default color for text. */\r
+  public static final int TEXT_COLOR = Color.LTGRAY;\r
+  /** A text font for regular text, like the chart labels. */\r
+  private static final Typeface REGULAR_TEXT_FONT = Typeface\r
+      .create(Typeface.SERIF, Typeface.NORMAL);\r
+  /** The typeface name for the texts. */\r
+  private String mTextTypefaceName = REGULAR_TEXT_FONT.toString();\r
+  /** The typeface style for the texts. */\r
+  private int mTextTypefaceStyle = Typeface.NORMAL;\r
+  /** The chart background color. */\r
+  private int mBackgroundColor;\r
+  /** If the background color is applied. */\r
+  private boolean mApplyBackgroundColor;\r
+  /** If the axes are visible. */\r
+  private boolean mShowAxes = true;\r
+  /** The axes color. */\r
+  private int mAxesColor = TEXT_COLOR;\r
+  /** If the labels are visible. */\r
+  private boolean mShowLabels = true;\r
+  /** The labels color. */\r
+  private int mLabelsColor = TEXT_COLOR;\r
+  /** The labels text size. */\r
+  private float mLabelsTextSize = 10;\r
+  /** If the legend is visible. */\r
+  private boolean mShowLegend = true;\r
+  /** The legend text size. */\r
+  private float mLegendTextSize = 12;\r
+  /** If the legend should size to fit. */\r
+  private boolean mFitLegend = false;\r
+  /** If the X axis grid should be displayed. */\r
+  private boolean mShowGridX = false;\r
+  /** If the Y axis grid should be displayed. */\r
+  private boolean mShowGridY = false;\r
+  /** If the custom text grid should be displayed. */\r
+  private boolean mShowCustomTextGrid = false;\r
+  /** The simple renderers that are included in this multiple series renderer. */\r
+  private List<SimpleSeriesRenderer> mRenderers = new ArrayList<SimpleSeriesRenderer>();\r
+  /** The antialiasing flag. */\r
+  private boolean mAntialiasing = true;\r
+  /** The legend height. */\r
+  private int mLegendHeight = 0;\r
+  /** The margins size. */\r
+  private int[] mMargins = new int[] { 20, 30, 10, 20 };\r
+  /** A value to be used for scaling the chart. */\r
+  private float mScale = 1;\r
+  /** A flag for enabling the pan. */\r
+  private boolean mPanEnabled = true;\r
+  /** A flag for enabling the zoom. */\r
+  private boolean mZoomEnabled = true;\r
+  /** A flag for enabling the visibility of the zoom buttons. */\r
+  private boolean mZoomButtonsVisible = false;\r
+  /** The zoom rate. */\r
+  private float mZoomRate = 1.5f;\r
+  /** A flag for enabling the external zoom. */\r
+  private boolean mExternalZoomEnabled = false;\r
+  /** The original chart scale. */\r
+  private float mOriginalScale = mScale;\r
+  /** A flag for enabling the click on elements. */\r
+  private boolean mClickEnabled = false;\r
+  /** The selectable radius around a clickable point. */\r
+  private int selectableBuffer = 15;\r
+  /** If the chart should display the values (available for pie chart). */\r
+  private boolean mDisplayValues;\r
+\r
+  /**\r
+   * A flag to be set if the chart is inside a scroll and doesn't need to shrink\r
+   * when not enough space.\r
+   */\r
+  private boolean mInScroll;\r
+  /** The start angle for circular charts such as pie, doughnut, etc. */\r
+  private float mStartAngle = 0;\r
+\r
+  /**\r
+   * Returns the chart title.\r
+   * \r
+   * @return the chart title\r
+   */\r
+  public String getChartTitle() {\r
+    return mChartTitle;\r
+  }\r
+\r
+  /**\r
+   * Sets the chart title.\r
+   * \r
+   * @param title the chart title\r
+   */\r
+  public void setChartTitle(String title) {\r
+    mChartTitle = title;\r
+  }\r
+\r
+  /**\r
+   * Returns the chart title text size.\r
+   * \r
+   * @return the chart title text size\r
+   */\r
+  public float getChartTitleTextSize() {\r
+    return mChartTitleTextSize;\r
+  }\r
+\r
+  /**\r
+   * Sets the chart title text size.\r
+   * \r
+   * @param textSize the chart title text size\r
+   */\r
+  public void setChartTitleTextSize(float textSize) {\r
+    mChartTitleTextSize = textSize;\r
+  }\r
+\r
+  /**\r
+   * Adds a simple renderer to the multiple renderer.\r
+   * \r
+   * @param renderer the renderer to be added\r
+   */\r
+  public void addSeriesRenderer(SimpleSeriesRenderer renderer) {\r
+    mRenderers.add(renderer);\r
+  }\r
+\r
+  /**\r
+   * Adds a simple renderer to the multiple renderer.\r
+   * \r
+   * @param index the index in the renderers list\r
+   * @param renderer the renderer to be added\r
+   */\r
+  public void addSeriesRenderer(int index, SimpleSeriesRenderer renderer) {\r
+    mRenderers.add(index, renderer);\r
+  }\r
+\r
+  /**\r
+   * Removes a simple renderer from the multiple renderer.\r
+   * \r
+   * @param renderer the renderer to be removed\r
+   */\r
+  public void removeSeriesRenderer(SimpleSeriesRenderer renderer) {\r
+    mRenderers.remove(renderer);\r
+  }\r
+\r
+  /**\r
+   * Removes all renderers from the multiple renderer.\r
+   */\r
+  public void removeAllRenderers() {\r
+    mRenderers.clear();\r
+  }\r
+\r
+  /**\r
+   * Returns the simple renderer from the multiple renderer list.\r
+   * \r
+   * @param index the index in the simple renderers list\r
+   * @return the simple renderer at the specified index\r
+   */\r
+  public SimpleSeriesRenderer getSeriesRendererAt(int index) {\r
+    return mRenderers.get(index);\r
+  }\r
+\r
+  /**\r
+   * Returns the simple renderers count in the multiple renderer list.\r
+   * \r
+   * @return the simple renderers count\r
+   */\r
+  public int getSeriesRendererCount() {\r
+    return mRenderers.size();\r
+  }\r
+\r
+  /**\r
+   * Returns an array of the simple renderers in the multiple renderer list.\r
+   * \r
+   * @return the simple renderers array\r
+   */\r
+  public SimpleSeriesRenderer[] getSeriesRenderers() {\r
+    return mRenderers.toArray(new SimpleSeriesRenderer[0]);\r
+  }\r
+\r
+  /**\r
+   * Returns the background color.\r
+   * \r
+   * @return the background color\r
+   */\r
+  public int getBackgroundColor() {\r
+    return mBackgroundColor;\r
+  }\r
+\r
+  /**\r
+   * Sets the background color.\r
+   * \r
+   * @param color the background color\r
+   */\r
+  public void setBackgroundColor(int color) {\r
+    mBackgroundColor = color;\r
+  }\r
+\r
+  /**\r
+   * Returns if the background color should be applied.\r
+   * \r
+   * @return the apply flag for the background color.\r
+   */\r
+  public boolean isApplyBackgroundColor() {\r
+    return mApplyBackgroundColor;\r
+  }\r
+\r
+  /**\r
+   * Sets if the background color should be applied.\r
+   * \r
+   * @param apply the apply flag for the background color\r
+   */\r
+  public void setApplyBackgroundColor(boolean apply) {\r
+    mApplyBackgroundColor = apply;\r
+  }\r
+\r
+  /**\r
+   * Returns the axes color.\r
+   * \r
+   * @return the axes color\r
+   */\r
+  public int getAxesColor() {\r
+    return mAxesColor;\r
+  }\r
+\r
+  /**\r
+   * Sets the axes color.\r
+   * \r
+   * @param color the axes color\r
+   */\r
+  public void setAxesColor(int color) {\r
+    mAxesColor = color;\r
+  }\r
+\r
+  /**\r
+   * Returns the labels color.\r
+   * \r
+   * @return the labels color\r
+   */\r
+  public int getLabelsColor() {\r
+    return mLabelsColor;\r
+  }\r
+\r
+  /**\r
+   * Sets the labels color.\r
+   * \r
+   * @param color the labels color\r
+   */\r
+  public void setLabelsColor(int color) {\r
+    mLabelsColor = color;\r
+  }\r
+\r
+  /**\r
+   * Returns the labels text size.\r
+   * \r
+   * @return the labels text size\r
+   */\r
+  public float getLabelsTextSize() {\r
+    return mLabelsTextSize;\r
+  }\r
+\r
+  /**\r
+   * Sets the labels text size.\r
+   * \r
+   * @param textSize the labels text size\r
+   */\r
+  public void setLabelsTextSize(float textSize) {\r
+    mLabelsTextSize = textSize;\r
+  }\r
+\r
+  /**\r
+   * Returns if the axes should be visible.\r
+   * \r
+   * @return the visibility flag for the axes\r
+   */\r
+  public boolean isShowAxes() {\r
+    return mShowAxes;\r
+  }\r
+\r
+  /**\r
+   * Sets if the axes should be visible.\r
+   * \r
+   * @param showAxes the visibility flag for the axes\r
+   */\r
+  public void setShowAxes(boolean showAxes) {\r
+    mShowAxes = showAxes;\r
+  }\r
+\r
+  /**\r
+   * Returns if the labels should be visible.\r
+   * \r
+   * @return the visibility flag for the labels\r
+   */\r
+  public boolean isShowLabels() {\r
+    return mShowLabels;\r
+  }\r
+\r
+  /**\r
+   * Sets if the labels should be visible.\r
+   * \r
+   * @param showLabels the visibility flag for the labels\r
+   */\r
+  public void setShowLabels(boolean showLabels) {\r
+    mShowLabels = showLabels;\r
+  }\r
+\r
+  /**\r
+   * Returns if the X axis grid should be visible.\r
+   * \r
+   * @return the visibility flag for the X axis grid\r
+   */\r
+  public boolean isShowGridX() {\r
+    return mShowGridX;\r
+  }\r
+\r
+  /**\r
+   * Returns if the Y axis grid should be visible.\r
+   * \r
+   * @return the visibility flag for the Y axis grid\r
+   */\r
+  public boolean isShowGridY() {\r
+    return mShowGridY;\r
+  }\r
+\r
+  /**\r
+   * Sets if the X axis grid should be visible.\r
+   * \r
+   * @param showGrid the visibility flag for the X axis grid\r
+   */\r
+  public void setShowGridX(boolean showGrid) {\r
+    mShowGridX = showGrid;\r
+  }\r
+\r
+  /**\r
+   * Sets if the Y axis grid should be visible.\r
+   * \r
+   * @param showGrid the visibility flag for the Y axis grid\r
+   */\r
+  public void setShowGridY(boolean showGrid) {\r
+    mShowGridY = showGrid;\r
+  }\r
+\r
+  /**\r
+   * Sets if the grid should be visible.\r
+   * \r
+   * @param showGrid the visibility flag for the grid\r
+   */\r
+  public void setShowGrid(boolean showGrid) {\r
+    setShowGridX(showGrid);\r
+    setShowGridY(showGrid);\r
+  }\r
+\r
+  /**\r
+   * Returns if the grid should be visible for custom X or Y labels.\r
+   * \r
+   * @return the visibility flag for the custom text grid\r
+   */\r
+  public boolean isShowCustomTextGrid() {\r
+    return mShowCustomTextGrid;\r
+  }\r
+\r
+  /**\r
+   * Sets if the grid for custom X or Y labels should be visible.\r
+   * \r
+   * @param showGrid the visibility flag for the custom text grid\r
+   */\r
+  public void setShowCustomTextGrid(boolean showGrid) {\r
+    mShowCustomTextGrid = showGrid;\r
+  }\r
+\r
+  /**\r
+   * Returns if the legend should be visible.\r
+   * \r
+   * @return the visibility flag for the legend\r
+   */\r
+  public boolean isShowLegend() {\r
+    return mShowLegend;\r
+  }\r
+\r
+  /**\r
+   * Sets if the legend should be visible.\r
+   * \r
+   * @param showLegend the visibility flag for the legend\r
+   */\r
+  public void setShowLegend(boolean showLegend) {\r
+    mShowLegend = showLegend;\r
+  }\r
+\r
+  /**\r
+   * Returns if the legend should size to fit.\r
+   * \r
+   * @return the fit behavior\r
+   */\r
+  public boolean isFitLegend() {\r
+    return mFitLegend;\r
+  }\r
+\r
+  /**\r
+   * Sets if the legend should size to fit.\r
+   * \r
+   * @param fit the fit behavior\r
+   */\r
+  public void setFitLegend(boolean fit) {\r
+    mFitLegend = fit;\r
+  }\r
+\r
+  /**\r
+   * Returns the text typeface name.\r
+   * \r
+   * @return the text typeface name\r
+   */\r
+  public String getTextTypefaceName() {\r
+    return mTextTypefaceName;\r
+  }\r
+\r
+  /**\r
+   * Returns the text typeface style.\r
+   * \r
+   * @return the text typeface style\r
+   */\r
+  public int getTextTypefaceStyle() {\r
+    return mTextTypefaceStyle;\r
+  }\r
+\r
+  /**\r
+   * Returns the legend text size.\r
+   * \r
+   * @return the legend text size\r
+   */\r
+  public float getLegendTextSize() {\r
+    return mLegendTextSize;\r
+  }\r
+\r
+  /**\r
+   * Sets the legend text size.\r
+   * \r
+   * @param textSize the legend text size\r
+   */\r
+  public void setLegendTextSize(float textSize) {\r
+    mLegendTextSize = textSize;\r
+  }\r
+\r
+  /**\r
+   * Sets the text typeface name and style.\r
+   * \r
+   * @param typefaceName the text typeface name\r
+   * @param style the text typeface style\r
+   */\r
+  public void setTextTypeface(String typefaceName, int style) {\r
+    mTextTypefaceName = typefaceName;\r
+    mTextTypefaceStyle = style;\r
+  }\r
+\r
+  /**\r
+   * Returns the antialiasing flag value.\r
+   * \r
+   * @return the antialiasing value\r
+   */\r
+  public boolean isAntialiasing() {\r
+    return mAntialiasing;\r
+  }\r
+\r
+  /**\r
+   * Sets the antialiasing value.\r
+   * \r
+   * @param antialiasing the antialiasing\r
+   */\r
+  public void setAntialiasing(boolean antialiasing) {\r
+    mAntialiasing = antialiasing;\r
+  }\r
+\r
+  /**\r
+   * Returns the value to be used for scaling the chart.\r
+   * \r
+   * @return the scale value\r
+   */\r
+  public float getScale() {\r
+    return mScale;\r
+  }\r
+\r
+  /**\r
+   * Returns the original value to be used for scaling the chart.\r
+   * \r
+   * @return the original scale value\r
+   */\r
+  public float getOriginalScale() {\r
+    return mOriginalScale;\r
+  }\r
+\r
+  /**\r
+   * Sets the value to be used for scaling the chart. It works on some charts\r
+   * like pie, doughnut, dial.\r
+   * \r
+   * @param scale the scale value\r
+   */\r
+  public void setScale(float scale) {\r
+    mScale = scale;\r
+  }\r
+\r
+  /**\r
+   * Returns the enabled state of the zoom.\r
+   * \r
+   * @return if zoom is enabled\r
+   */\r
+  public boolean isZoomEnabled() {\r
+    return mZoomEnabled;\r
+  }\r
+\r
+  /**\r
+   * Sets the enabled state of the zoom.\r
+   * \r
+   * @param enabled zoom enabled\r
+   */\r
+  public void setZoomEnabled(boolean enabled) {\r
+    mZoomEnabled = enabled;\r
+  }\r
+\r
+  /**\r
+   * Returns the visible state of the zoom buttons.\r
+   * \r
+   * @return if zoom buttons are visible\r
+   */\r
+  public boolean isZoomButtonsVisible() {\r
+    return mZoomButtonsVisible;\r
+  }\r
+\r
+  /**\r
+   * Sets the visible state of the zoom buttons.\r
+   * \r
+   * @param visible if the zoom buttons are visible\r
+   */\r
+  public void setZoomButtonsVisible(boolean visible) {\r
+    mZoomButtonsVisible = visible;\r
+  }\r
+\r
+  /**\r
+   * Returns the enabled state of the external (application implemented) zoom.\r
+   * \r
+   * @return if external zoom is enabled\r
+   */\r
+  public boolean isExternalZoomEnabled() {\r
+    return mExternalZoomEnabled;\r
+  }\r
+\r
+  /**\r
+   * Sets the enabled state of the external (application implemented) zoom.\r
+   * \r
+   * @param enabled external zoom enabled\r
+   */\r
+  public void setExternalZoomEnabled(boolean enabled) {\r
+    mExternalZoomEnabled = enabled;\r
+  }\r
+\r
+  /**\r
+   * Returns the zoom rate.\r
+   * \r
+   * @return the zoom rate\r
+   */\r
+  public float getZoomRate() {\r
+    return mZoomRate;\r
+  }\r
+\r
+  /**\r
+   * Returns the enabled state of the pan.\r
+   * \r
+   * @return if pan is enabled\r
+   */\r
+  public boolean isPanEnabled() {\r
+    return mPanEnabled;\r
+  }\r
+\r
+  /**\r
+   * Sets the enabled state of the pan.\r
+   * \r
+   * @param enabled pan enabled\r
+   */\r
+  public void setPanEnabled(boolean enabled) {\r
+    mPanEnabled = enabled;\r
+  }\r
+\r
+  /**\r
+   * Sets the zoom rate.\r
+   * \r
+   * @param rate the zoom rate\r
+   */\r
+  public void setZoomRate(float rate) {\r
+    mZoomRate = rate;\r
+  }\r
+\r
+  /**\r
+   * Returns the enabled state of the click.\r
+   * \r
+   * @return if click is enabled\r
+   */\r
+  public boolean isClickEnabled() {\r
+    return mClickEnabled;\r
+  }\r
+\r
+  /**\r
+   * Sets the enabled state of the click.\r
+   * \r
+   * @param enabled click enabled\r
+   */\r
+  public void setClickEnabled(boolean enabled) {\r
+    mClickEnabled = enabled;\r
+  }\r
+\r
+  /**\r
+   * Returns the selectable radius value around clickable points.\r
+   * \r
+   * @return the selectable radius\r
+   */\r
+  public int getSelectableBuffer() {\r
+    return selectableBuffer;\r
+  }\r
+\r
+  /**\r
+   * Sets the selectable radius value around clickable points.\r
+   * \r
+   * @param buffer the selectable radius\r
+   */\r
+  public void setSelectableBuffer(int buffer) {\r
+    selectableBuffer = buffer;\r
+  }\r
+\r
+  /**\r
+   * Returns the legend height.\r
+   * \r
+   * @return the legend height\r
+   */\r
+  public int getLegendHeight() {\r
+    return mLegendHeight;\r
+  }\r
+\r
+  /**\r
+   * Sets the legend height, in pixels.\r
+   * \r
+   * @param height the legend height\r
+   */\r
+  public void setLegendHeight(int height) {\r
+    mLegendHeight = height;\r
+  }\r
+\r
+  /**\r
+   * Returns the margin sizes. An array containing the margins in this order:\r
+   * top, left, bottom, right\r
+   * \r
+   * @return the margin sizes\r
+   */\r
+  public int[] getMargins() {\r
+    return mMargins;\r
+  }\r
+\r
+  /**\r
+   * Sets the margins, in pixels.\r
+   * \r
+   * @param margins an array containing the margin size values, in this order:\r
+   *          top, left, bottom, right\r
+   */\r
+  public void setMargins(int[] margins) {\r
+    mMargins = margins;\r
+  }\r
+\r
+  /**\r
+   * Returns if the chart is inside a scroll view and doesn't need to shrink.\r
+   * \r
+   * @return if it is inside a scroll view\r
+   */\r
+  public boolean isInScroll() {\r
+    return mInScroll;\r
+  }\r
+\r
+  /**\r
+   * To be set if the chart is inside a scroll view and doesn't need to shrink\r
+   * when not enough space.\r
+   * \r
+   * @param inScroll if it is inside a scroll view\r
+   */\r
+  public void setInScroll(boolean inScroll) {\r
+    mInScroll = inScroll;\r
+  }\r
+\r
+  /**\r
+   * Returns the start angle for circular charts such as pie, doughnut. An angle\r
+   * of 0 degrees correspond to the geometric angle of 0 degrees (3 o'clock on a\r
+   * watch.)\r
+   * \r
+   * @return the start angle in degrees\r
+   */\r
+  public float getStartAngle() {\r
+    return mStartAngle;\r
+  }\r
+\r
+  /**\r
+   * Sets the start angle for circular charts such as pie, doughnut, etc. An\r
+   * angle of 0 degrees correspond to the geometric angle of 0 degrees (3\r
+   * o'clock on a watch.)\r
+   * \r
+   * @param startAngle the start angle in degrees\r
+   */\r
+  public void setStartAngle(float startAngle) {\r
+    mStartAngle = startAngle;\r
+  }\r
+\r
+  /**\r
+   * Returns if the values should be displayed as text.\r
+   * \r
+   * @return if the values should be displayed as text\r
+   */\r
+  public boolean isDisplayValues() {\r
+    return mDisplayValues;\r
+  }\r
+\r
+  /**\r
+   * Sets if the values should be displayed as text (supported by pie chart).\r
+   * \r
+   * @param display if the values should be displayed as text\r
+   */\r
+  public void setDisplayValues(boolean display) {\r
+    mDisplayValues = display;\r
+  }\r
+\r
+}\r