org.achartengine.chart
Class XYChart

java.lang.Object
  extended by org.achartengine.chart.AbstractChart
      extended by org.achartengine.chart.XYChart
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BarChart, BubbleChart, CombinedXYChart, LineChart, ScatterChart

public abstract class XYChart
extends AbstractChart

The XY chart rendering class.

See Also:
Serialized Form

Field Summary
protected  XYMultipleSeriesDataset mDataset
          The multiple series dataset.
protected  XYMultipleSeriesRenderer mRenderer
          The multiple series renderer.
 
Constructor Summary
protected XYChart()
           
  XYChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer)
          Builds a new XY chart instance.
 
Method Summary
protected abstract  android.graphics.RectF[] clickableAreasForPoints(float[] points, float yAxisValue, int seriesIndex)
          Returns the clickable areas for all passed points
 void draw(android.graphics.Canvas canvas, int x, int y, int width, int height, android.graphics.Paint paint)
          The graphical representation of the XY chart.
protected  void drawChartValuesText(android.graphics.Canvas canvas, XYSeries series, SimpleSeriesRenderer renderer, android.graphics.Paint paint, float[] points, int seriesIndex)
          The graphical representation of the series values as text.
abstract  void drawSeries(android.graphics.Canvas canvas, android.graphics.Paint paint, float[] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex)
          The graphical representation of a series.
protected  void drawSeries(XYSeries series, android.graphics.Canvas canvas, android.graphics.Paint paint, java.util.List<java.lang.Float> pointsList, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, XYMultipleSeriesRenderer.Orientation or)
           
protected  void drawText(android.graphics.Canvas canvas, java.lang.String text, float x, float y, android.graphics.Paint paint, float extraAngle)
          The graphical representation of a text, to handle both HORIZONTAL and VERTICAL orientations and extra rotation angles.
protected  void drawXLabels(java.util.List<java.lang.Double> xLabels, java.lang.Double[] xTextLabelLocations, android.graphics.Canvas canvas, android.graphics.Paint paint, int left, int top, int bottom, double xPixelsPerUnit, double minX, double maxX)
          The graphical representation of the labels on the X axis.
protected  void drawXTextLabels(java.lang.Double[] xTextLabelLocations, android.graphics.Canvas canvas, android.graphics.Paint paint, boolean showLabels, int left, int top, int bottom, double xPixelsPerUnit, double minX, double maxX)
          The graphical representation of the text labels on the X axis.
 double[] getCalcRange(int scale)
           
abstract  java.lang.String getChartType()
          Returns the chart type identifier.
 XYMultipleSeriesDataset getDataset()
           
 double getDefaultMinimum()
          Returns the default axis minimum.
protected  java.lang.String getLabel(double label)
          Makes sure the fraction digit is not displayed, if not needed.
 ScatterChart getPointsChart()
          Returns the scatter chart to be used for drawing the data points.
 XYMultipleSeriesRenderer getRenderer()
           
protected  android.graphics.Rect getScreenR()
           
 SeriesSelection getSeriesAndPointForScreenCoordinate(Point screenPoint)
          Given screen coordinates, returns the series and point indexes of a chart element.
protected  boolean isRenderNullValues()
          Returns if the chart should display the null values.
 boolean isRenderPoints(SimpleSeriesRenderer renderer)
          Returns if the chart should display the points as a certain shape.
 void setCalcRange(double[] range, int scale)
           
protected  void setDatasetRenderer(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer)
           
protected  void setScreenR(android.graphics.Rect screenR)
           
 double[] toRealPoint(float screenX, float screenY)
           
 double[] toRealPoint(float screenX, float screenY, int scale)
          Transforms a screen point to a real coordinates point.
 double[] toScreenPoint(double[] realPoint)
           
 double[] toScreenPoint(double[] realPoint, int scale)
           
 
Methods inherited from class org.achartengine.chart.AbstractChart
drawBackground, drawLabel, drawLegend, drawLegendShape, drawPath, getExceed, getLegendShapeWidth, getLegendSize, isVertical
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mDataset

protected XYMultipleSeriesDataset mDataset
The multiple series dataset.


mRenderer

protected XYMultipleSeriesRenderer mRenderer
The multiple series renderer.

Constructor Detail

XYChart

protected XYChart()

XYChart

public XYChart(XYMultipleSeriesDataset dataset,
               XYMultipleSeriesRenderer renderer)
Builds a new XY chart instance.

Parameters:
dataset - the multiple series dataset
renderer - the multiple series renderer
Method Detail

setDatasetRenderer

protected void setDatasetRenderer(XYMultipleSeriesDataset dataset,
                                  XYMultipleSeriesRenderer renderer)

draw

public void draw(android.graphics.Canvas canvas,
                 int x,
                 int y,
                 int width,
                 int height,
                 android.graphics.Paint paint)
The graphical representation of the XY chart.

Specified by:
draw in class AbstractChart
Parameters:
canvas - the canvas to paint to
x - the top left x value of the view to draw to
y - the top left y value of the view to draw to
width - the width of the view to draw to
height - the height of the view to draw to
paint - the paint

getScreenR

protected android.graphics.Rect getScreenR()

setScreenR

protected void setScreenR(android.graphics.Rect screenR)

drawSeries

protected void drawSeries(XYSeries series,
                          android.graphics.Canvas canvas,
                          android.graphics.Paint paint,
                          java.util.List<java.lang.Float> pointsList,
                          SimpleSeriesRenderer seriesRenderer,
                          float yAxisValue,
                          int seriesIndex,
                          XYMultipleSeriesRenderer.Orientation or)

drawChartValuesText

protected void drawChartValuesText(android.graphics.Canvas canvas,
                                   XYSeries series,
                                   SimpleSeriesRenderer renderer,
                                   android.graphics.Paint paint,
                                   float[] points,
                                   int seriesIndex)
The graphical representation of the series values as text.

Parameters:
canvas - the canvas to paint to
series - the series to be painted
renderer - the series renderer
paint - the paint to be used for drawing
points - the array of points to be used for drawing the series
seriesIndex - the index of the series currently being drawn

drawText

protected void drawText(android.graphics.Canvas canvas,
                        java.lang.String text,
                        float x,
                        float y,
                        android.graphics.Paint paint,
                        float extraAngle)
The graphical representation of a text, to handle both HORIZONTAL and VERTICAL orientations and extra rotation angles.

Parameters:
canvas - the canvas to paint to
text - the text to be rendered
x - the X axis location of the text
y - the Y axis location of the text
paint - the paint to be used for drawing
extraAngle - the text angle

getLabel

protected java.lang.String getLabel(double label)
Makes sure the fraction digit is not displayed, if not needed.

Parameters:
label - the input label value
Returns:
the label without the useless fraction digit

drawXLabels

protected void drawXLabels(java.util.List<java.lang.Double> xLabels,
                           java.lang.Double[] xTextLabelLocations,
                           android.graphics.Canvas canvas,
                           android.graphics.Paint paint,
                           int left,
                           int top,
                           int bottom,
                           double xPixelsPerUnit,
                           double minX,
                           double maxX)
The graphical representation of the labels on the X axis.

Parameters:
xLabels - the X labels values
xTextLabelLocations - the X text label locations
canvas - the canvas to paint to
paint - the paint to be used for drawing
left - the left value of the labels area
top - the top value of the labels area
bottom - the bottom value of the labels area
xPixelsPerUnit - the amount of pixels per one unit in the chart labels
minX - the minimum value on the X axis in the chart
maxX - the maximum value on the X axis in the chart

drawXTextLabels

protected void drawXTextLabels(java.lang.Double[] xTextLabelLocations,
                               android.graphics.Canvas canvas,
                               android.graphics.Paint paint,
                               boolean showLabels,
                               int left,
                               int top,
                               int bottom,
                               double xPixelsPerUnit,
                               double minX,
                               double maxX)
The graphical representation of the text labels on the X axis.

Parameters:
xTextLabelLocations - the X text label locations
canvas - the canvas to paint to
paint - the paint to be used for drawing
left - the left value of the labels area
top - the top value of the labels area
bottom - the bottom value of the labels area
xPixelsPerUnit - the amount of pixels per one unit in the chart labels
minX - the minimum value on the X axis in the chart
maxX - the maximum value on the X axis in the chart

getRenderer

public XYMultipleSeriesRenderer getRenderer()

getDataset

public XYMultipleSeriesDataset getDataset()

getCalcRange

public double[] getCalcRange(int scale)

setCalcRange

public void setCalcRange(double[] range,
                         int scale)

toRealPoint

public double[] toRealPoint(float screenX,
                            float screenY)

toScreenPoint

public double[] toScreenPoint(double[] realPoint)

toRealPoint

public double[] toRealPoint(float screenX,
                            float screenY,
                            int scale)
Transforms a screen point to a real coordinates point.

Parameters:
screenX - the screen x axis value
screenY - the screen y axis value
Returns:
the real coordinates point

toScreenPoint

public double[] toScreenPoint(double[] realPoint,
                              int scale)

getSeriesAndPointForScreenCoordinate

public SeriesSelection getSeriesAndPointForScreenCoordinate(Point screenPoint)
Description copied from class: AbstractChart
Given screen coordinates, returns the series and point indexes of a chart element. If there is no chart element (line, point, bar, etc) at those coordinates, null is returned.

Overrides:
getSeriesAndPointForScreenCoordinate in class AbstractChart
Returns:

drawSeries

public abstract void drawSeries(android.graphics.Canvas canvas,
                                android.graphics.Paint paint,
                                float[] points,
                                SimpleSeriesRenderer seriesRenderer,
                                float yAxisValue,
                                int seriesIndex)
The graphical representation of a series.

Parameters:
canvas - the canvas to paint to
paint - the paint to be used for drawing
points - the array of points to be used for drawing the series
seriesRenderer - the series renderer
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series currently being drawn

clickableAreasForPoints

protected abstract android.graphics.RectF[] clickableAreasForPoints(float[] points,
                                                                    float yAxisValue,
                                                                    int seriesIndex)
Returns the clickable areas for all passed points

Parameters:
points - the array of points
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series to which the points belong
Returns:
an array of rectangles with the clickable area

isRenderNullValues

protected boolean isRenderNullValues()
Returns if the chart should display the null values.

Returns:
if null values should be rendered

isRenderPoints

public boolean isRenderPoints(SimpleSeriesRenderer renderer)
Returns if the chart should display the points as a certain shape.

Parameters:
renderer - the series renderer

getDefaultMinimum

public double getDefaultMinimum()
Returns the default axis minimum.

Returns:
the default axis minimum

getPointsChart

public ScatterChart getPointsChart()
Returns the scatter chart to be used for drawing the data points.

Returns:
the data points scatter chart

getChartType

public abstract java.lang.String getChartType()
Returns the chart type identifier.

Returns:
the chart type


Copyright © 2009 - 2011 4ViewSoft. All Rights Reserved.