Search in sources :

Example 6 with XYSeriesRenderer

use of org.achartengine.renderer.XYSeriesRenderer in project Anki-Android by Ramblurr.

the class ScatterChart method drawSeries.

/**
   * 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
   * @param startIndex the start index of the rendering points
   */
public void drawSeries(Canvas canvas, Paint paint, float[] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex, int range) {
    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;
    }
}
Also used : XYSeriesRenderer(org.achartengine.renderer.XYSeriesRenderer) Paint(android.graphics.Paint)

Aggregations

XYSeriesRenderer (org.achartengine.renderer.XYSeriesRenderer)6 Paint (android.graphics.Paint)4 XYSeries (org.achartengine.model.XYSeries)3 Resources (android.content.res.Resources)2 LayoutParams (android.view.ViewGroup.LayoutParams)2 GraphicalView (org.achartengine.GraphicalView)2 Align (android.graphics.Paint.Align)1 Rect (android.graphics.Rect)1 GestureDetector (android.view.GestureDetector)1 MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 Stats (com.ichi2.libanki.Stats)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Point (org.achartengine.model.Point)1 XYMultipleSeriesDataset (org.achartengine.model.XYMultipleSeriesDataset)1 XYValueSeries (org.achartengine.model.XYValueSeries)1