Class XYChart
- Direct Known Subclasses:
BarChart, BubbleChart, CombinedXYChart, LineChart, ScatterChart
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected XYMultipleSeriesDatasetThe multiple series dataset.protected XYMultipleSeriesRendererThe multiple series renderer. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedXYChart()XYChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) Builds a new XY chart instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ClickableArea[]clickableAreasForPoints(List<Float> points, List<Double> values, float yAxisValue, int seriesIndex, int startIndex) Returns the clickable areas for all passed pointsvoidThe graphical representation of the XY chart.protected voiddrawChartValuesText(Canvas canvas, XYSeries series, XYSeriesRenderer renderer, Paint paint, List<Float> points, int seriesIndex, int startIndex) The graphical representation of the series values as text.protected voiddrawPoints(Canvas canvas, Paint paint, List<Float> pointsList, XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex) Draws the series points.abstract voiddrawSeries(Canvas canvas, Paint paint, List<Float> points, XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex) The graphical representation of a series.protected voiddrawSeries(XYSeries series, Canvas canvas, Paint paint, List<Float> pointsList, XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, XYMultipleSeriesRenderer.Orientation or, int startIndex) Draws the series.protected voidThe graphical representation of a text, to handle both HORIZONTAL and VERTICAL orientations and extra rotation angles.protected voiddrawXLabels(List<Double> xLabels, Double[] xTextLabelLocations, Canvas canvas, 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 voiddrawXTextLabels(Double[] xTextLabelLocations, Canvas canvas, 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.protected voiddrawYLabels(Map<Integer, List<Double>> allYLabels, Canvas canvas, Paint paint, int maxScaleNumber, int left, int right, int bottom, double[] yPixelsPerUnit, double[] minY) The graphical representation of the labels on the Y axis.double[]getCalcRange(int scale) abstract StringReturns the chart type identifier.doubleReturns the default axis minimum.Returns the scatter chart to be used for drawing the data points.protected RectanglegetSeriesAndPointForScreenCoordinate(Point screenPoint) Given screen coordinates, returns the series and point indexes of a chart element.getXLabels(double min, double max, int count) getYLabels(double[] minY, double[] maxY, int maxScaleNumber) protected booleanReturns if the chart should display the null values.booleanisRenderPoints(SimpleSeriesRenderer renderer) Returns if the chart should display the points as a certain shape.voidsetCalcRange(double[] range, int scale) protected voidsetDatasetRenderer(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) protected voidsetScreenR(Rectangle 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 AbstractChart
calculateDrawPoints, drawBackground, drawLabel, drawLegend, drawLegendShape, drawPath, drawPath, drawString, getExceed, getLabel, getLegendShapeWidth, getLegendSize, isNullValue, isVerticalModifier and TypeMethodDescriptionprotected static float[]calculateDrawPoints(float p1x, float p1y, float p2x, float p2y, int screenHeight, int screenWidth) 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.booleanisNullValue(double value) booleanisVertical(DefaultRenderer renderer) Checks if the current chart is rendered as vertical.Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()booleanIndicates whether some other object is "equal to" this one.final ClassgetClass()Returns the runtime class of an object.inthashCode()Returns a hash code value for the object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes current thread to wait until another thread invokes the method or the method for this object.final voidwait(long timeout) Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.final voidwait(long timeout, int nanos) Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
-
Field Details
-
mDataset
The multiple series dataset. -
mRenderer
The multiple series renderer.
-
-
Constructor Details
-
XYChart
protected XYChart() -
XYChart
Builds a new XY chart instance.
Parameters
-
dataset: the multiple series dataset -
renderer: the multiple series renderer
-
-
-
Method Details
-
setDatasetRenderer
protected void setDatasetRenderer(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer) -
draw
The graphical representation of the XY 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
- Specified by:
drawin classAbstractChart
-
-
getXLabels
-
getYLabels
-
getScreenR
-
setScreenR
-
drawSeries
protected void drawSeries(XYSeries series, Canvas canvas, Paint paint, List<Float> pointsList, XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, XYMultipleSeriesRenderer.Orientation or, int startIndex) Draws the series.
Parameters
-
series: the series -
canvas: the canvas -
paint: the paint object -
pointsList: the points to be rendered -
seriesRenderer: the series renderer -
yAxisValue: the y axis value in pixels -
seriesIndex: the series index -
or: the orientation -
startIndex: the start index of the rendering points
-
-
drawPoints
protected void drawPoints(Canvas canvas, Paint paint, List<Float> pointsList, XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex) Draws the series points.
Parameters
-
canvas: the canvas -
paint: the paint object -
pointsList: the points to be rendered -
seriesRenderer: the series renderer -
yAxisValue: the y axis value in pixels -
seriesIndex: the series index -
startIndex: the start index of the rendering points
-
-
drawChartValuesText
protected void drawChartValuesText(Canvas canvas, XYSeries series, XYSeriesRenderer renderer, Paint paint, List<Float> points, int seriesIndex, int startIndex) 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 -
startIndex: the start index of the rendering points
-
-
drawText
protected void drawText(Canvas canvas, String text, float x, float y, 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
-
-
drawXLabels
protected void drawXLabels(List<Double> xLabels, Double[] xTextLabelLocations, Canvas canvas, 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
-
-
drawYLabels
protected void drawYLabels(Map<Integer, List<Double>> allYLabels, Canvas canvas, Paint paint, int maxScaleNumber, int left, int right, int bottom, double[] yPixelsPerUnit, double[] minY) The graphical representation of the labels on the Y axis.
Parameters
-
allYLabels: the Y labels values -
canvas: the canvas to paint to -
paint: the paint to be used for drawing -
maxScaleNumber: the maximum scale number -
left: the left value of the labels area -
right: the right value of the labels area -
bottom: the bottom value of the labels area -
yPixelsPerUnit: the amount of pixels per one unit in the chart labels -
minY: the minimum value on the Y axis in the chart
-
-
drawXTextLabels
protected void drawXTextLabels(Double[] xTextLabelLocations, Canvas canvas, 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
-
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
Description copied from class:AbstractChartGiven 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
- Overrides:
getSeriesAndPointForScreenCoordinatein classAbstractChart
-
drawSeries
public abstract void drawSeries(Canvas canvas, Paint paint, List<Float> points, XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex) 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 -
startIndex: the start index of the rendering points
-
-
clickableAreasForPoints
protected abstract ClickableArea[] clickableAreasForPoints(List<Float> points, List<Double> values, float yAxisValue, int seriesIndex, int startIndex) Returns the clickable areas for all passed points
Parameters
-
points: the array of points -
values: the array of values of each point -
yAxisValue: the minimum value of the y axis -
seriesIndex: the index of the series to which the points belong -
startIndex: the start index of the rendering points
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
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
Returns the scatter chart to be used for drawing the data points.
Returns
the data points scatter chart
-
getChartType
Returns the chart type identifier.
Returns
the chart type
-