Search in sources :

Example 1 with BasicStroke

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

the class XYChart method drawSeries.

/**
   * Draws the series.
   * 
   * @param series the series
   * @param canvas the canvas
   * @param paint the paint object
   * @param pointsList the points to be rendered
   * @param seriesRenderer the series renderer
   * @param yAxisValue the y axis value in pixels
   * @param seriesIndex the series index
   * @param or the orientation
   * @param startIndex the start index of the rendering points
   */
protected void drawSeries(XYSeries series, Canvas canvas, Paint paint, List<Float> pointsList, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, Orientation or, int startIndex, int range) {
    BasicStroke stroke = seriesRenderer.getStroke();
    Cap cap = paint.getStrokeCap();
    Join join = paint.getStrokeJoin();
    float miter = paint.getStrokeMiter();
    PathEffect pathEffect = paint.getPathEffect();
    Style style = paint.getStyle();
    if (stroke != null) {
        PathEffect effect = null;
        if (stroke.getIntervals() != null) {
            effect = new DashPathEffect(stroke.getIntervals(), stroke.getPhase());
        }
        setStroke(stroke.getCap(), stroke.getJoin(), stroke.getMiter(), Style.FILL_AND_STROKE, effect, paint);
    }
    float[] points = MathHelper.getFloats(pointsList);
    drawSeries(canvas, paint, points, seriesRenderer, yAxisValue, seriesIndex, startIndex, range);
    if (isRenderPoints(seriesRenderer)) {
        ScatterChart pointsChart = getPointsChart();
        if (pointsChart != null) {
            pointsChart.drawSeries(canvas, paint, points, seriesRenderer, yAxisValue, seriesIndex, startIndex, range);
        }
    }
    paint.setTextSize(seriesRenderer.getChartValuesTextSize());
    if (or == Orientation.HORIZONTAL) {
        paint.setTextAlign(Align.CENTER);
    } else {
        paint.setTextAlign(Align.LEFT);
    }
    if (seriesRenderer.isDisplayChartValues()) {
        paint.setTextAlign(seriesRenderer.getChartValuesTextAlign());
        drawChartValuesText(canvas, series, seriesRenderer, paint, points, seriesIndex, startIndex);
    }
    if (stroke != null) {
        setStroke(cap, join, miter, style, pathEffect, paint);
    }
}
Also used : BasicStroke(org.achartengine.renderer.BasicStroke) Cap(android.graphics.Paint.Cap) Join(android.graphics.Paint.Join) Style(android.graphics.Paint.Style) DashPathEffect(android.graphics.DashPathEffect) PathEffect(android.graphics.PathEffect) DashPathEffect(android.graphics.DashPathEffect)

Example 2 with BasicStroke

use of org.achartengine.renderer.BasicStroke in project sensorreadout by onyxbits.

the class XYChart method drawSeries.

/**
   * Draws the series.
   * 
   * @param series the series
   * @param canvas the canvas
   * @param paint the paint object
   * @param pointsList the points to be rendered
   * @param seriesRenderer the series renderer
   * @param yAxisValue the y axis value in pixels
   * @param seriesIndex the series index
   * @param or the orientation
   * @param startIndex the start index of the rendering points
   */
protected void drawSeries(XYSeries series, Canvas canvas, Paint paint, List<Float> pointsList, XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, Orientation or, int startIndex) {
    BasicStroke stroke = seriesRenderer.getStroke();
    Cap cap = paint.getStrokeCap();
    Join join = paint.getStrokeJoin();
    float miter = paint.getStrokeMiter();
    PathEffect pathEffect = paint.getPathEffect();
    Style style = paint.getStyle();
    if (stroke != null) {
        PathEffect effect = null;
        if (stroke.getIntervals() != null) {
            effect = new DashPathEffect(stroke.getIntervals(), stroke.getPhase());
        }
        setStroke(stroke.getCap(), stroke.getJoin(), stroke.getMiter(), Style.FILL_AND_STROKE, effect, paint);
    }
    // float[] points = MathHelper.getFloats(pointsList);
    drawSeries(canvas, paint, pointsList, seriesRenderer, yAxisValue, seriesIndex, startIndex);
    if (isRenderPoints(seriesRenderer)) {
        ScatterChart pointsChart = getPointsChart();
        if (pointsChart != null) {
            pointsChart.drawSeries(canvas, paint, pointsList, seriesRenderer, yAxisValue, seriesIndex, startIndex);
        }
    }
    paint.setTextSize(seriesRenderer.getChartValuesTextSize());
    if (or == Orientation.HORIZONTAL) {
        paint.setTextAlign(Align.CENTER);
    } else {
        paint.setTextAlign(Align.LEFT);
    }
    if (seriesRenderer.isDisplayChartValues()) {
        paint.setTextAlign(seriesRenderer.getChartValuesTextAlign());
        drawChartValuesText(canvas, series, seriesRenderer, paint, pointsList, seriesIndex, startIndex);
    }
    if (stroke != null) {
        setStroke(cap, join, miter, style, pathEffect, paint);
    }
}
Also used : BasicStroke(org.achartengine.renderer.BasicStroke) Cap(android.graphics.Paint.Cap) Join(android.graphics.Paint.Join) Style(android.graphics.Paint.Style) DashPathEffect(android.graphics.DashPathEffect) PathEffect(android.graphics.PathEffect) DashPathEffect(android.graphics.DashPathEffect)

Aggregations

DashPathEffect (android.graphics.DashPathEffect)2 Cap (android.graphics.Paint.Cap)2 Join (android.graphics.Paint.Join)2 Style (android.graphics.Paint.Style)2 PathEffect (android.graphics.PathEffect)2 BasicStroke (org.achartengine.renderer.BasicStroke)2