Class AbstractChart
- Direct Known Subclasses:
RoundChart, XYChart
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static float[]calculateDrawPoints(float p1x, float p1y, float p2x, float p2y, int screenHeight, int screenWidth) abstract voidThe graphical representation of the chart.protected voiddrawBackground(DefaultRenderer renderer, Canvas canvas, int x, int y, int width, int height, Paint paint, boolean newColor, int color) Draws the chart background.protected voiddrawLabel(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.protected intdrawLegend(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.abstract voiddrawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float x, float y, int seriesIndex, Paint paint) The graphical representation of the legend shape.protected voidThe graphical representation of a path.protected voidThe graphical representation of a path.protected voiddrawString(Canvas canvas, String text, float x, float y, Paint paint) Draw a multiple lines string.protected booleangetExceed(float currentWidth, DefaultRenderer renderer, int right, int width) Calculates if the current width exceeds the total width.protected StringgetLabel(NumberFormat format, double label) Makes sure the fraction digit is not displayed, if not needed.abstract intgetLegendShapeWidth(int seriesIndex) Returns the legend shape width.protected intgetLegendSize(DefaultRenderer renderer, int defaultHeight, float extraHeight) Calculates the current legend size.getSeriesAndPointForScreenCoordinate(Point screenPoint) Given screen coordinates, returns the series and point indexes of a chart element.booleanisNullValue(double value) booleanisVertical(DefaultRenderer renderer) Checks if the current chart is rendered as vertical.
-
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
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, Canvas canvas, int x, int y, int width, int height, 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(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
-
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
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
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
Checks if the current chart is rendered as vertical.
Parameters
renderer: the renderer
Returns
if the chart is rendered as a vertical one
-
getLabel
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
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
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(Canvas canvas, SimpleSeriesRenderer renderer, float x, float y, int seriesIndex, 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
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(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
-
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
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
-