Search in sources :

Example 6 with DashPathEffect

use of android.graphics.DashPathEffect 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 7 with DashPathEffect

use of android.graphics.DashPathEffect 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)

Example 8 with DashPathEffect

use of android.graphics.DashPathEffect in project fitscales by paulburton.

the class ScaleView method init.

private void init() {
    regions = new ScaleRegion[4];
    regions[0] = new ScaleRegion("underweight", 0.0f, 18.5f, 0xffff4020);
    regions[1] = new ScaleRegion("normal", 18.5f, 25.0f, 0xff00ff00);
    regions[2] = new ScaleRegion("overweight", 25.0f, 30.0f, 0xffffff00);
    regions[3] = new ScaleRegion("obese", 30.0f, Float.MAX_VALUE, 0xffff4020);
    paintLine = new Paint();
    paintLine.setColor(0xff33b5e5);
    paintLine.setStrokeWidth(2);
    if (DRAW_REGION_SEPARATORS) {
        paintSeparator = new Paint();
        paintSeparator.setColor(0xff606060);
        paintSeparator.setStyle(Style.STROKE);
        paintSeparator.setStrokeWidth(1);
        paintSeparator.setPathEffect(new DashPathEffect(new float[] { 20, 10 }, 0));
    }
    paintOverlay = new Paint();
    paintOverlay.setColor(0);
    paintOverlay.setStyle(Style.FILL);
    paintCurrBmi = new Paint();
    paintCurrBmi.setColor(0xff33b5e5);
    paintCurrBmi.setStrokeWidth(3);
    paintCurrBmiTriangle = new Paint(Paint.ANTI_ALIAS_FLAG);
    paintCurrBmiTriangle.setColor(0xff33b5e5);
    paintCurrBmiTriangle.setStyle(Style.FILL);
    paintCurrWeight = new Paint(Paint.ANTI_ALIAS_FLAG);
    paintCurrWeight.setColor(0xff202020);
    paintCurrWeight.setTypeface(Typeface.DEFAULT);
    paintPrevBmi = new Paint();
    paintPrevBmi.setColor(0xff808080);
    paintPrevBmi.setStrokeWidth(3);
    paintPrevBmiTriangle = new Paint(Paint.ANTI_ALIAS_FLAG);
    paintPrevBmiTriangle.setColor(0xff808080);
}
Also used : DashPathEffect(android.graphics.DashPathEffect) Paint(android.graphics.Paint)

Example 9 with DashPathEffect

use of android.graphics.DashPathEffect in project muzei by romannurik.

the class AnimatedMuzeiLoadingSpinnerView method onDraw.

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (mStartTime < 0 || mGlyphData == null) {
        return;
    }
    long t = (System.currentTimeMillis() - mStartTime) % (TRACE_TIME * 2);
    int sc = canvas.save();
    canvas.translate(-VIEWPORT.left * mWidth / VIEWPORT.width(), -VIEWPORT.top * mHeight / VIEWPORT.height());
    // Draw outlines (starts as traced)
    float phase = MathUtil.constrain(0, 1, (t % TRACE_TIME) * 1f / TRACE_TIME);
    float distance = INTERPOLATOR.getInterpolation(phase) * mGlyphData.length;
    mGlyphData.paint.setColor(TRACE_RESIDUE_COLOR);
    if (t < TRACE_TIME) {
        mGlyphData.paint.setPathEffect(new DashPathEffect(new float[] { distance, mGlyphData.length }, 0));
    } else {
        mGlyphData.paint.setPathEffect(new DashPathEffect(new float[] { 0, distance, mGlyphData.length, 0 }, 0));
    }
    canvas.drawPath(mGlyphData.path, mGlyphData.paint);
    mGlyphData.paint.setColor(TRACE_COLOR);
    mGlyphData.paint.setPathEffect(new DashPathEffect(new float[] { 0, distance, phase > 0 ? mMarkerLength : 0, mGlyphData.length }, 0));
    canvas.drawPath(mGlyphData.path, mGlyphData.paint);
    canvas.restoreToCount(sc);
    postInvalidateOnAnimation();
}
Also used : DashPathEffect(android.graphics.DashPathEffect) Paint(android.graphics.Paint)

Example 10 with DashPathEffect

use of android.graphics.DashPathEffect in project platform_frameworks_base by android.

the class GradientDrawable method updateLocalState.

private void updateLocalState(Resources res) {
    final GradientState state = mGradientState;
    if (state.mSolidColors != null) {
        final int[] currentState = getState();
        final int stateColor = state.mSolidColors.getColorForState(currentState, 0);
        mFillPaint.setColor(stateColor);
    } else if (state.mGradientColors == null) {
        // If we don't have a solid color and we don't have a gradient,
        // the app is stroking the shape, set the color to the default
        // value of state.mSolidColor
        mFillPaint.setColor(0);
    } else {
        // Otherwise, make sure the fill alpha is maxed out.
        mFillPaint.setColor(Color.BLACK);
    }
    mPadding = state.mPadding;
    if (state.mStrokeWidth >= 0) {
        mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mStrokePaint.setStyle(Paint.Style.STROKE);
        mStrokePaint.setStrokeWidth(state.mStrokeWidth);
        if (state.mStrokeColors != null) {
            final int[] currentState = getState();
            final int strokeStateColor = state.mStrokeColors.getColorForState(currentState, 0);
            mStrokePaint.setColor(strokeStateColor);
        }
        if (state.mStrokeDashWidth != 0.0f) {
            final DashPathEffect e = new DashPathEffect(new float[] { state.mStrokeDashWidth, state.mStrokeDashGap }, 0);
            mStrokePaint.setPathEffect(e);
        }
    }
    mTintFilter = updateTintFilter(mTintFilter, state.mTint, state.mTintMode);
    mGradientIsDirty = true;
    state.computeOpacity();
}
Also used : DashPathEffect(android.graphics.DashPathEffect) Paint(android.graphics.Paint) Paint(android.graphics.Paint)

Aggregations

DashPathEffect (android.graphics.DashPathEffect)45 Paint (android.graphics.Paint)34 Path (android.graphics.Path)7 PathEffect (android.graphics.PathEffect)7 Animation (com.db.chart.animation.Animation)4 LineSet (com.db.chart.model.LineSet)3 Cap (android.graphics.Paint.Cap)2 Join (android.graphics.Paint.Join)2 Style (android.graphics.Paint.Style)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 View (android.view.View)2 BarSet (com.db.chart.model.BarSet)2 Point (com.db.chart.model.Point)2 ArrayList (java.util.ArrayList)2 BasicStroke (org.achartengine.renderer.BasicStroke)2 SuppressLint (android.annotation.SuppressLint)1 TypedArray (android.content.res.TypedArray)1 LinearGradient (android.graphics.LinearGradient)1 Rect (android.graphics.Rect)1 Shader (android.graphics.Shader)1