/** * The graphical representation of the legend shape. * * @param canvas the canvas to paint to * @param renderer the series renderer * @param x the x value of the point the shape should be drawn at * @param y the y value of the point the shape should be drawn at * @param seriesIndex the series index * @param paint the paint to be used for drawing */ public void drawLegendShape( Canvas canvas, SimpleSeriesRenderer renderer, float x, float y, int seriesIndex, Paint paint) { if (((XYSeriesRenderer) renderer).isFillPoints()) { paint.setStyle(Style.FILL); } else { paint.setStyle(Style.STROKE); } switch (((XYSeriesRenderer) renderer).getPointStyle()) { case X: drawX(canvas, paint, x + size, y); break; case CIRCLE: drawCircle(canvas, paint, x + size, y); break; case TRIANGLE: drawTriangle(canvas, paint, new float[6], x + size, y); break; case SQUARE: drawSquare(canvas, paint, x + size, y); break; case DIAMOND: drawDiamond(canvas, paint, new float[8], x + size, y); break; case POINT: canvas.drawPoint(x + size, y, paint); break; } }
/** * The graphical representation of a series. * * @param canvas the canvas to paint to * @param paint the paint to be used for drawing * @param points the array of points to be used for drawing the series * @param seriesRenderer the series renderer * @param yAxisValue the minimum value of the y axis * @param seriesIndex the index of the series currently being drawn */ public void drawSeries( Canvas canvas, Paint paint, float[] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex) { XYSeriesRenderer renderer = (XYSeriesRenderer) seriesRenderer; paint.setColor(renderer.getColor()); if (renderer.isFillPoints()) { paint.setStyle(Style.FILL); } else { paint.setStyle(Style.STROKE); } int length = points.length; switch (renderer.getPointStyle()) { case X: for (int i = 0; i < length; i += 2) { drawX(canvas, paint, points[i], points[i + 1]); } break; case CIRCLE: for (int i = 0; i < length; i += 2) { drawCircle(canvas, paint, points[i], points[i + 1]); } break; case TRIANGLE: float[] path = new float[6]; for (int i = 0; i < length; i += 2) { drawTriangle(canvas, paint, path, points[i], points[i + 1]); } break; case SQUARE: for (int i = 0; i < length; i += 2) { drawSquare(canvas, paint, points[i], points[i + 1]); } break; case DIAMOND: path = new float[8]; for (int i = 0; i < length; i += 2) { drawDiamond(canvas, paint, path, points[i], points[i + 1]); } break; case POINT: canvas.drawPoints(points, paint); break; } }