Java Code Examples for android.graphics.Paint#getPathEffect()

The following examples show how to use android.graphics.Paint#getPathEffect() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorldMapEquirectangular.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void drawMajorLatitudes(Canvas c, int w, int h, double[] mid, WorldMapTask.WorldMapOptions options)
{
    Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
    p.setXfermode(new PorterDuffXfermode( options.hasTransparentBaseMap ? PorterDuff.Mode.DST_OVER : PorterDuff.Mode.SRC_OVER ));

    Paint.Style prevStyle = p.getStyle();
    PathEffect prevEffect = p.getPathEffect();
    float prevStrokeWidth = p.getStrokeWidth();

    float strokeWidth = sunStroke(c, options) * options.latitudeLineScale;
    p.setStrokeWidth(strokeWidth);

    p.setColor(options.latitudeColors[0]);                    // equator
    p.setPathEffect((options.latitudeLinePatterns[0][0] > 0) ? new DashPathEffect(options.latitudeLinePatterns[0], 0) : null);
    c.drawLine(0, (int)mid[1], w, (int)mid[1], p);

    double tropics = r_tropics * mid[1];
    int tropicsY0 = (int)(mid[1] + tropics);
    int tropicsY1 = (int)(mid[1] - tropics);
    p.setColor(options.latitudeColors[1]);                    // tropics
    p.setPathEffect((options.latitudeLinePatterns[1][0] > 0) ? new DashPathEffect(options.latitudeLinePatterns[1], 0) : null);
    c.drawLine(0, tropicsY0, w, tropicsY0, p);
    c.drawLine(0, tropicsY1, w, tropicsY1, p);

    double polar = r_polar * mid[1];
    int polarY0 = (int)(mid[1] + polar);
    int polarY1 = (int)(mid[1] - polar);
    p.setColor(options.latitudeColors[2]);                    // polar
    p.setPathEffect((options.latitudeLinePatterns[2][0] > 0) ? new DashPathEffect(options.latitudeLinePatterns[2], 0) : null);
    c.drawLine(0, polarY0, w, polarY0, p);
    c.drawLine(0, polarY1, w, polarY1, p);

    p.setStyle(prevStyle);
    p.setPathEffect(prevEffect);
    p.setStrokeWidth(prevStrokeWidth);
    p.setXfermode(new PorterDuffXfermode( PorterDuff.Mode.SRC_OVER) );
}
 
Example 2
Source File: WorldMapEquiazimuthal.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void drawMajorLatitudes(Canvas c, int w, int h, double[] mid, WorldMapTask.WorldMapOptions options)
{
    Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
    p.setXfermode(options.hasTransparentBaseMap ? new PorterDuffXfermode(PorterDuff.Mode.DST_OVER) : new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER));

    Paint.Style prevStyle = p.getStyle();
    PathEffect prevEffect = p.getPathEffect();
    float prevStrokeWidth = p.getStrokeWidth();

    double equator = mid[1] * r_equator;
    double tropics = mid[1] * r_tropics;
    double polar = mid[1] * r_polar;

    float strokeWidth = sunStroke(c, options) * options.latitudeLineScale;
    p.setStrokeWidth(strokeWidth);
    p.setStyle(Paint.Style.STROKE);
    p.setStrokeCap(Paint.Cap.ROUND);

    p.setColor(options.latitudeColors[0]);
    p.setPathEffect((options.latitudeLinePatterns[0][0] > 0) ? new DashPathEffect(options.latitudeLinePatterns[0], 0) : null);

    c.drawCircle((int)mid[0], (int)mid[1], (int)equator, p);

    p.setColor(options.latitudeColors[1]);
    p.setPathEffect((options.latitudeLinePatterns[1][0] > 0) ? new DashPathEffect(options.latitudeLinePatterns[1], 0) : null);
    c.drawCircle((int)mid[0], (int)mid[1], (int)(equator + tropics), p);
    c.drawCircle((int)mid[0], (int)mid[1], (int)(equator - tropics), p);

    p.setColor(options.latitudeColors[2]);
    p.setPathEffect((options.latitudeLinePatterns[2][0] > 0) ? new DashPathEffect(options.latitudeLinePatterns[2], 0) : null);
    c.drawCircle((int)mid[0], (int)mid[1], (int)(equator + polar), p);
    c.drawCircle((int)mid[0], (int)mid[1], (int)(equator - polar), p);

    p.setStyle(prevStyle);
    p.setPathEffect(prevEffect);
    p.setStrokeWidth(prevStrokeWidth);
}
 
Example 3
Source File: SpanFormatter.java    From nfcard with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top,
		int y, int bottom, Paint paint) {

	canvas.save();
	canvas.translate(x, (bottom + top) / 2 - height);

	final int c = paint.getColor();
	final float w = paint.getStrokeWidth();
	final Style s = paint.getStyle();
	final PathEffect e = paint.getPathEffect();

	paint.setColor(color);
	paint.setStyle(Paint.Style.STROKE);
	paint.setStrokeWidth(height);
	paint.setPathEffect(effe);

	path.moveTo(x, 0);
	path.lineTo(x + width, 0);

	canvas.drawPath(path, paint);

	paint.setColor(c);
	paint.setStyle(s);
	paint.setStrokeWidth(w);
	paint.setPathEffect(e);

	canvas.restore();
}
 
Example 4
Source File: SpanFormatter.java    From NFCard with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top,
		int y, int bottom, Paint paint) {

	canvas.save();
	canvas.translate(x, (bottom + top) / 2 - height);

	final int c = paint.getColor();
	final float w = paint.getStrokeWidth();
	final Style s = paint.getStyle();
	final PathEffect e = paint.getPathEffect();

	paint.setColor(color);
	paint.setStyle(Paint.Style.STROKE);
	paint.setStrokeWidth(height);
	paint.setPathEffect(effe);

	path.moveTo(x, 0);
	path.lineTo(x + width, 0);

	canvas.drawPath(path, paint);

	paint.setColor(c);
	paint.setStyle(s);
	paint.setStrokeWidth(w);
	paint.setPathEffect(e);

	canvas.restore();
}
 
Example 5
Source File: XYChart.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
protected void drawSeries(XYSeries xyseries, Canvas canvas, Paint paint, List list, SimpleSeriesRenderer simpleseriesrenderer, float f1, int i, 
        org.achartengine.renderer.XYMultipleSeriesRenderer.Orientation orientation, int j)
{
    BasicStroke basicstroke = simpleseriesrenderer.getStroke();
    android.graphics.Paint.Cap cap = paint.getStrokeCap();
    android.graphics.Paint.Join join = paint.getStrokeJoin();
    float f2 = paint.getStrokeMiter();
    PathEffect patheffect = paint.getPathEffect();
    android.graphics.Paint.Style style = paint.getStyle();
    if (basicstroke != null)
    {
        float af[] = basicstroke.getIntervals();
        DashPathEffect dashpatheffect = null;
        if (af != null)
        {
            dashpatheffect = new DashPathEffect(basicstroke.getIntervals(), basicstroke.getPhase());
        }
        a(basicstroke.getCap(), basicstroke.getJoin(), basicstroke.getMiter(), android.graphics.Paint.Style.FILL_AND_STROKE, dashpatheffect, paint);
    }
    drawSeries(canvas, paint, list, simpleseriesrenderer, f1, i, j);
    if (isRenderPoints(simpleseriesrenderer))
    {
        ScatterChart scatterchart = getPointsChart();
        if (scatterchart != null)
        {
            scatterchart.drawSeries(canvas, paint, list, simpleseriesrenderer, f1, i, j);
        }
    }
    paint.setTextSize(simpleseriesrenderer.getChartValuesTextSize());
    if (orientation == org.achartengine.renderer.XYMultipleSeriesRenderer.Orientation.HORIZONTAL)
    {
        paint.setTextAlign(android.graphics.Paint.Align.CENTER);
    } else
    {
        paint.setTextAlign(android.graphics.Paint.Align.LEFT);
    }
    if (simpleseriesrenderer.isDisplayChartValues())
    {
        paint.setTextAlign(simpleseriesrenderer.getChartValuesTextAlign());
        drawChartValuesText(canvas, xyseries, simpleseriesrenderer, paint, list, i, j);
    }
    if (basicstroke != null)
    {
        a(cap, join, f2, style, patheffect, paint);
    }
}
 
Example 6
Source File: BorderShape.java    From Genius-Android with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("SuspiciousNameCombination")
@Override
public void draw(Canvas canvas, Paint paint) {
    if (mBorder == null)
        return;

    float width = getWidth();
    float height = getHeight();

    if (mPathEffect == null) {

        // left
        if (mBorder.left > 0)
            canvas.drawRect(0, 0, mBorder.left, height, paint);

        // top
        if (mBorder.top > 0)
            canvas.drawRect(0, 0, width, mBorder.top, paint);

        // right
        if (mBorder.right > 0)
            canvas.drawRect(width - mBorder.right, 0, width, height, paint);

        // bottom
        if (mBorder.bottom > 0)
            canvas.drawRect(0, height - mBorder.bottom, width, height, paint);

    } else {
        if (paint.getPathEffect() != mPathEffect) {
            paint.setStyle(Paint.Style.STROKE);
            paint.setPathEffect(mPathEffect);
        }

        // left
        if (mBorder.left > 0) {
            paint.setStrokeWidth(mBorder.left);
            initPath(mBorder.left / 2, 0, mBorder.left / 2, height);
            canvas.drawPath(mPath, paint);
        }

        // top
        if (mBorder.top > 0) {
            paint.setStrokeWidth(mBorder.top);
            initPath(0, mBorder.top / 2, width, mBorder.top / 2);
            canvas.drawPath(mPath, paint);
        }

        // right
        if (mBorder.right > 0) {
            paint.setStrokeWidth(mBorder.right);
            initPath(width - mBorder.right / 2, 0, width - mBorder.right / 2, height);
            canvas.drawPath(mPath, paint);
        }

        // bottom
        if (mBorder.bottom > 0) {
            paint.setStrokeWidth(mBorder.bottom);
            initPath(0, height - mBorder.bottom / 2, width, height - mBorder.bottom / 2);
            canvas.drawPath(mPath, paint);
        }
    }
}