org.achartengine.chart
Class AbstractChart

java.lang.Object
  extended by org.achartengine.chart.AbstractChart
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
RoundChart, XYChart

public abstract class AbstractChart
extends java.lang.Object
implements java.io.Serializable

An abstract class to be implemented by the chart rendering classes.

See Also:
Serialized Form

Constructor Summary
AbstractChart()
           
 
Method Summary
abstract  void draw(android.graphics.Canvas canvas, int x, int y, int width, int height, android.graphics.Paint paint)
          The graphical representation of the chart.
protected  void drawBackground(DefaultRenderer renderer, android.graphics.Canvas canvas, int x, int y, int width, int height, android.graphics.Paint paint, boolean newColor, int color)
          Draws the chart background.
protected  void drawLabel(android.graphics.Canvas canvas, java.lang.String labelText, DefaultRenderer renderer, java.util.List<android.graphics.RectF> prevLabelsBounds, int centerX, int centerY, float shortRadius, float longRadius, float currentAngle, float angle, int left, int right, int color, android.graphics.Paint paint, boolean line, boolean display)
          Draws a text label.
protected  int drawLegend(android.graphics.Canvas canvas, DefaultRenderer renderer, java.lang.String[] titles, int left, int right, int y, int width, int height, int legendSize, android.graphics.Paint paint, boolean calculate)
          Draws the chart legend.
abstract  void drawLegendShape(android.graphics.Canvas canvas, SimpleSeriesRenderer renderer, float x, float y, int seriesIndex, android.graphics.Paint paint)
          The graphical representation of the legend shape.
protected  void drawPath(android.graphics.Canvas canvas, float[] points, android.graphics.Paint paint, boolean circular)
          The graphical representation of a path.
protected  void drawPath(android.graphics.Canvas canvas, java.util.List<java.lang.Float> points, android.graphics.Paint paint, boolean circular)
          The graphical representation of a path.
protected  void drawString(android.graphics.Canvas canvas, java.lang.String text, float x, float y, android.graphics.Paint paint)
          Draw a multiple lines string.
protected  boolean getExceed(float currentWidth, DefaultRenderer renderer, int right, int width)
          Calculates if the current width exceeds the total width.
protected  java.lang.String getLabel(java.text.NumberFormat format, double label)
          Makes sure the fraction digit is not displayed, if not needed.
abstract  int getLegendShapeWidth(int seriesIndex)
          Returns the legend shape width.
protected  int getLegendSize(DefaultRenderer renderer, int defaultHeight, float extraHeight)
          Calculates the current legend size.
 SeriesSelection getSeriesAndPointForScreenCoordinate(Point screenPoint)
          Given screen coordinates, returns the series and point indexes of a chart element.
 boolean isNullValue(double value)
           
 boolean isVertical(DefaultRenderer renderer)
          Checks if the current chart is rendered as vertical.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractChart

public AbstractChart()
Method Detail

draw

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

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

drawBackground

protected void drawBackground(DefaultRenderer renderer,
                              android.graphics.Canvas canvas,
                              int x,
                              int y,
                              int width,
                              int height,
                              android.graphics.Paint paint,
                              boolean newColor,
                              int color)
Draws the chart background.

Parameters:
renderer - the chart renderer
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 used for drawing
newColor - if a new color is to be used
color - the color to be used

drawLegend

protected int drawLegend(android.graphics.Canvas canvas,
                         DefaultRenderer renderer,
                         java.lang.String[] titles,
                         int left,
                         int right,
                         int y,
                         int width,
                         int height,
                         int legendSize,
                         android.graphics.Paint paint,
                         boolean calculate)
Draws the chart legend.

Parameters:
canvas - the canvas to paint to
renderer - the series renderer
titles - the titles to go to the legend
left - the left X value of the area to draw to
right - the right X value of the area to draw to
y - the y value of the area to draw to
width - the width of the area to draw to
height - the height of the area to draw to
legendSize - the legend size
paint - the paint to be used for drawing
calculate - if only calculating the legend size
Returns:
the legend height

drawString

protected void drawString(android.graphics.Canvas canvas,
                          java.lang.String text,
                          float x,
                          float y,
                          android.graphics.Paint paint)
Draw a multiple lines string.

Parameters:
canvas - the canvas to paint to
text - the text to be painted
x - the x value of the area to draw to
y - the y value of the area to draw to
paint - the paint to be used for drawing

getExceed

protected boolean getExceed(float currentWidth,
                            DefaultRenderer renderer,
                            int right,
                            int width)
Calculates if the current width exceeds the total width.

Parameters:
currentWidth - the current width
renderer - the renderer
right - the right side pixel value
width - the total width
Returns:
if the current width exceeds the total width

isVertical

public boolean isVertical(DefaultRenderer renderer)
Checks if the current chart is rendered as vertical.

Parameters:
renderer - the renderer
Returns:
if the chart is rendered as a vertical one

getLabel

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

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

drawPath

protected void drawPath(android.graphics.Canvas canvas,
                        java.util.List<java.lang.Float> points,
                        android.graphics.Paint paint,
                        boolean circular)
The graphical representation of a path.

Parameters:
canvas - the canvas to paint to
points - the points that are contained in the path to paint
paint - the paint to be used for painting
circular - if the path ends with the start point

drawPath

protected void drawPath(android.graphics.Canvas canvas,
                        float[] points,
                        android.graphics.Paint paint,
                        boolean circular)
The graphical representation of a path.

Parameters:
canvas - the canvas to paint to
points - the points that are contained in the path to paint
paint - the paint to be used for painting
circular - if the path ends with the start point

getLegendShapeWidth

public abstract int getLegendShapeWidth(int seriesIndex)
Returns the legend shape width.

Parameters:
seriesIndex - the series index
Returns:
the legend shape width

drawLegendShape

public abstract void drawLegendShape(android.graphics.Canvas canvas,
                                     SimpleSeriesRenderer renderer,
                                     float x,
                                     float y,
                                     int seriesIndex,
                                     android.graphics.Paint paint)
The graphical representation of the legend shape.

Parameters:
canvas - the canvas to paint to
renderer - the series renderer
x - the x value of the point the shape should be drawn at
y - the y value of the point the shape should be drawn at
seriesIndex - the series index
paint - the paint to be used for drawing

getLegendSize

protected int getLegendSize(DefaultRenderer renderer,
                            int defaultHeight,
                            float extraHeight)
Calculates the current legend size.

Parameters:
renderer - the renderer
defaultHeight - the default height
extraHeight - the added extra height
Returns:
the legend size

drawLabel

protected void drawLabel(android.graphics.Canvas canvas,
                         java.lang.String labelText,
                         DefaultRenderer renderer,
                         java.util.List<android.graphics.RectF> prevLabelsBounds,
                         int centerX,
                         int centerY,
                         float shortRadius,
                         float longRadius,
                         float currentAngle,
                         float angle,
                         int left,
                         int right,
                         int color,
                         android.graphics.Paint paint,
                         boolean line,
                         boolean display)
Draws a text label.

Parameters:
canvas - the canvas
labelText - the label text
renderer - the renderer
prevLabelsBounds - the previous rendered label bounds
centerX - the round chart center on X axis
centerY - the round chart center on Y axis
shortRadius - the short radius for the round chart
longRadius - the long radius for the round chart
currentAngle - the current angle
angle - the label extra angle
left - the left side
right - the right side
color - the label color
paint - the paint
line - if a line to the label should be drawn
display - display the label anyway

isNullValue

public boolean isNullValue(double value)

getSeriesAndPointForScreenCoordinate

public SeriesSelection getSeriesAndPointForScreenCoordinate(Point screenPoint)
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.

Parameters:
screenPoint -
Returns:
the series and point indexes


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