public abstract class AbstractChart
- Object
- AbstractChart
Known subtypesRoundChart, XYChart
An abstract class to be implemented by the chart rendering classes.
Constructors
public AbstractChart() |
Methods
Inherited methods
Constructor details
AbstractChart
public AbstractChart()Method details
calculateDrawPoints
protected static float[] calculateDrawPoints(float p1x, float p1y, float p2x, float p2y, int screenHeight, int screenWidth)draw
public abstract void draw(Canvas canvas, int x, int y, int width, int height, Paint paint)The graphical representation of the chart.
Parameters
canvasCanvas- the canvas to paint to
xint- the top left x value of the view to draw to
yint- the top left y value of the view to draw to
widthint- the width of the view to draw to
heightint- the height of the view to draw to
paintPaint- the paint
drawBackground
protected void drawBackground(DefaultRenderer renderer, Canvas canvas, int x, int y, int width, int height, Paint paint, boolean newColor, int color)Draws the chart background.
Parameters
rendererDefaultRenderer- the chart renderer
canvasCanvas- the canvas to paint to
xint- the top left x value of the view to draw to
yint- the top left y value of the view to draw to
widthint- the width of the view to draw to
heightint- the height of the view to draw to
paintPaint- the paint used for drawing
newColorboolean- if a new color is to be used
colorint- the color to be used
drawLegend
protected int drawLegend(Canvas canvas, DefaultRenderer renderer, String[] titles, int left, int right, int y, int width, int height, int legendSize, Paint paint, boolean calculate)Draws the chart legend.
Parameters
canvasCanvas- the canvas to paint to
rendererDefaultRenderer- the series renderer
titlesString[]- the titles to go to the legend
leftint- the left X value of the area to draw to
rightint- the right X value of the area to draw to
yint- the y value of the area to draw to
widthint- the width of the area to draw to
heightint- the height of the area to draw to
legendSizeint- the legend size
paintPaint- the paint to be used for drawing
calculateboolean- if only calculating the legend size
Returns
the legend height
drawString
protected void drawString(Canvas canvas, String text, float x, float y, Paint paint)Draw a multiple lines string.
Parameters
canvasCanvas- the canvas to paint to
textString- the text to be painted
xfloat- the x value of the area to draw to
yfloat- the y value of the area to draw to
paintPaint- 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
currentWidthfloat- the current width
rendererDefaultRenderer- the renderer
rightint- the right side pixel value
widthint- 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
rendererDefaultRenderer- the renderer
Returns
if the chart is rendered as a vertical one
getLabel
protected String getLabel(NumberFormat format, double label)Makes sure the fraction digit is not displayed, if not needed.
Parameters
formatNumberFormat- the number format for the label
labeldouble- the input label value
Returns
the label without the useless fraction digit
drawPath
protected void drawPath(Canvas canvas, List<Float> points, Paint paint, boolean circular)The graphical representation of a path.
Parameters
canvasCanvas- the canvas to paint to
pointsList<Float>- the points that are contained in the path to paint
paintPaint- the paint to be used for painting
circularboolean- if the path ends with the start point
drawPath
protected void drawPath(Canvas canvas, float[] points, Paint paint, boolean circular)The graphical representation of a path.
Parameters
canvasCanvas- the canvas to paint to
pointsfloat[]- the points that are contained in the path to paint
paintPaint- the paint to be used for painting
circularboolean- if the path ends with the start point
getLegendShapeWidth
public abstract int getLegendShapeWidth(int seriesIndex)Returns the legend shape width.
Parameters
seriesIndexint- the series index
Returns
the legend shape width
drawLegendShape
public abstract void drawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float x, float y, int seriesIndex, Paint paint)The graphical representation of the legend shape.
Parameters
canvasCanvas- the canvas to paint to
rendererSimpleSeriesRenderer- the series renderer
xfloat- the x value of the point the shape should be drawn at
yfloat- the y value of the point the shape should be drawn at
seriesIndexint- the series index
paintPaint- the paint to be used for drawing
getLegendSize
protected int getLegendSize(DefaultRenderer renderer, int defaultHeight, float extraHeight)Calculates the current legend size.
Parameters
rendererDefaultRenderer- the renderer
defaultHeightint- the default height
extraHeightfloat- the added extra height
Returns
the legend size
drawLabel
protected void drawLabel(Canvas canvas, String labelText, DefaultRenderer renderer, List<Rectangle2D> prevLabelsBounds, int centerX, int centerY, float shortRadius, float longRadius, float currentAngle, float angle, int left, int right, int color, Paint paint, boolean line, boolean display)Draws a text label.
Parameters
canvasCanvas- the canvas
labelTextString- the label text
rendererDefaultRenderer- the renderer
prevLabelsBoundsList<Rectangle2D>- the previous rendered label bounds
centerXint- the round chart center on X axis
centerYint- the round chart center on Y axis
shortRadiusfloat- the short radius for the round chart
longRadiusfloat- the long radius for the round chart
currentAnglefloat- the current angle
anglefloat- the label extra angle
leftint- the left side
rightint- the right side
colorint- the label color
paintPaint- the paint
lineboolean- if a line to the label should be drawn
displayboolean- 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.
Returns
the series and point indexes