Search in sources :

Example 11 with PathEffect

use of android.graphics.PathEffect in project UltimateAndroid by cymcsg.

the class DiscrollvablePathLayout method onDraw.

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    makeAndMeasurePath();
    if (!isInEditMode()) {
        // Apply the dash effect
        float length = mPathMeasure.getLength();
        PathEffect effect = new DashPathEffect(new float[] { length, length }, length * (1 - mRatio));
        mPaint.setPathEffect(effect);
    }
    canvas.drawPath(mPath, mPaint);
}
Also used : DashPathEffect(android.graphics.DashPathEffect) PathEffect(android.graphics.PathEffect) DashPathEffect(android.graphics.DashPathEffect)

Example 12 with PathEffect

use of android.graphics.PathEffect in project assertj-android by square.

the class AbstractPaintAssert method hasPathEffect.

public S hasPathEffect(PathEffect effect) {
    isNotNull();
    PathEffect actualEffect = actual.getPathEffect();
    // 
    assertThat(actualEffect).overridingErrorMessage("Expected path effect <%s> but was <%s>.", effect, // 
    actualEffect).isSameAs(effect);
    return myself;
}
Also used : PathEffect(android.graphics.PathEffect)

Example 13 with PathEffect

use of android.graphics.PathEffect in project RecyclerViewDecoration by arjinmc.

the class RecyclerViewItemDecoration method drawVertical.

/**
 * draw vertival decoration
 *
 * @param c
 * @param parent
 */
private void drawVertical(Canvas c, RecyclerView parent) {
    int childrenCount = parent.getChildCount();
    if (mDrawableRid != 0) {
        if (mFirstLineVisible) {
            View childView = parent.getChildAt(0);
            if (!isIgnoreType(parent.getAdapter().getItemViewType(parent.getChildLayoutPosition(childView)))) {
                int myX = childView.getLeft();
                if (hasNinePatch) {
                    Rect rect = new Rect(myX - mCurrentThickness, mPaddingStart, myX, parent.getHeight() - mPaddingEnd);
                    mNinePatch.draw(c, rect);
                } else {
                    c.drawBitmap(mBmp, myX - mCurrentThickness, mPaddingStart, mPaint);
                }
            }
        }
        for (int i = 0; i < childrenCount; i++) {
            if (!mLastLineVisible && i == childrenCount - 1)
                break;
            View childView = parent.getChildAt(i);
            if (!isIgnoreType(parent.getAdapter().getItemViewType(parent.getChildLayoutPosition(childView)))) {
                int myX = childView.getRight();
                if (hasNinePatch) {
                    Rect rect = new Rect(myX, mPaddingStart, myX + mCurrentThickness, parent.getHeight() - mPaddingEnd);
                    mNinePatch.draw(c, rect);
                } else {
                    c.drawBitmap(mBmp, myX, mPaddingStart, mPaint);
                }
            }
        }
    } else {
        boolean isPureLine = isPureLine();
        if (!isPureLine) {
            PathEffect effects = new DashPathEffect(new float[] { 0, 0, mDashWidth, mThickness }, mDashGap);
            mPaint.setPathEffect(effects);
        }
        if (mFirstLineVisible) {
            View childView = parent.getChildAt(0);
            if (!isIgnoreType(parent.getAdapter().getItemViewType(parent.getChildLayoutPosition(childView)))) {
                int myX = childView.getLeft() - mThickness / 2;
                Path path = new Path();
                path.moveTo(myX, mPaddingStart);
                path.lineTo(myX, parent.getHeight() - mPaddingEnd);
                c.drawPath(path, mPaint);
            }
        }
        for (int i = 0; i < childrenCount; i++) {
            if (!mLastLineVisible && i == childrenCount - 1)
                break;
            View childView = parent.getChildAt(i);
            if (!isIgnoreType(parent.getAdapter().getItemViewType(parent.getChildLayoutPosition(childView)))) {
                int myX = childView.getRight() + mThickness / 2;
                Path path = new Path();
                path.moveTo(myX, mPaddingStart);
                path.lineTo(myX, parent.getHeight() - mPaddingEnd);
                c.drawPath(path, mPaint);
            }
        }
    }
}
Also used : Path(android.graphics.Path) Rect(android.graphics.Rect) DashPathEffect(android.graphics.DashPathEffect) PathEffect(android.graphics.PathEffect) DashPathEffect(android.graphics.DashPathEffect) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Paint(android.graphics.Paint)

Example 14 with PathEffect

use of android.graphics.PathEffect in project RecyclerViewDecoration by arjinmc.

the class RecyclerViewItemDecoration method drawHorizontal.

/**
 * draw horizontal decoration
 *
 * @param c
 * @param parent
 */
private void drawHorizontal(Canvas c, RecyclerView parent) {
    int childrenCount = parent.getChildCount();
    if (mDrawableRid != 0) {
        if (mFirstLineVisible) {
            View childView = parent.getChildAt(0);
            int myY = childView.getTop();
            if (!isIgnoreType(parent.getAdapter().getItemViewType(parent.getChildLayoutPosition(childView)))) {
                if (hasNinePatch) {
                    Rect rect = new Rect(mPaddingStart, myY - mCurrentThickness, parent.getWidth() - mPaddingEnd, myY);
                    mNinePatch.draw(c, rect);
                } else {
                    c.drawBitmap(mBmp, mPaddingStart, myY - mCurrentThickness, mPaint);
                }
            }
        }
        for (int i = 0; i < childrenCount; i++) {
            if (!mLastLineVisible && i == childrenCount - 1)
                break;
            View childView = parent.getChildAt(i);
            if (!isIgnoreType(parent.getAdapter().getItemViewType(parent.getChildLayoutPosition(childView)))) {
                int myY = childView.getBottom();
                if (hasNinePatch) {
                    Rect rect = new Rect(mPaddingStart, myY, parent.getWidth() - mPaddingEnd, myY + mCurrentThickness);
                    mNinePatch.draw(c, rect);
                } else {
                    c.drawBitmap(mBmp, mPaddingStart, myY, mPaint);
                }
            }
        }
    } else {
        boolean isPureLine = isPureLine();
        if (!isPureLine) {
            PathEffect effects = new DashPathEffect(new float[] { 0, 0, mDashWidth, mThickness }, mDashGap);
            mPaint.setPathEffect(effects);
        }
        if (mFirstLineVisible) {
            View childView = parent.getChildAt(0);
            if (!isIgnoreType(parent.getAdapter().getItemViewType(parent.getChildLayoutPosition(childView)))) {
                int myY = childView.getTop() - mThickness / 2;
                Path path = new Path();
                path.moveTo(mPaddingStart, myY);
                path.lineTo(parent.getWidth() - mPaddingEnd, myY);
                c.drawPath(path, mPaint);
            }
        }
        for (int i = 0; i < childrenCount; i++) {
            if (!mLastLineVisible && i == childrenCount - 1)
                break;
            View childView = parent.getChildAt(i);
            if (!isIgnoreType(parent.getAdapter().getItemViewType(parent.getChildLayoutPosition(childView)))) {
                int myY = childView.getBottom() + mThickness / 2;
                Path path = new Path();
                path.moveTo(mPaddingStart, myY);
                path.lineTo(parent.getWidth() - mPaddingEnd, myY);
                c.drawPath(path, mPaint);
            }
        }
    }
}
Also used : Path(android.graphics.Path) Rect(android.graphics.Rect) DashPathEffect(android.graphics.DashPathEffect) PathEffect(android.graphics.PathEffect) DashPathEffect(android.graphics.DashPathEffect) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Paint(android.graphics.Paint)

Example 15 with PathEffect

use of android.graphics.PathEffect in project YhLibraryForAndroid by android-coco.

the class LineChartView method setAnim.

// 设置动画
private void setAnim(Canvas canvas) {
    PathMeasure measure = new PathMeasure(mPath, false);
    float pathLength = measure.getLength();
    PathEffect effect = new DashPathEffect(new float[] { pathLength, pathLength }, pathLength - pathLength * mProgress);
    mPaintLine.setPathEffect(effect);
    canvas.drawPath(mPath, mPaintLine);
}
Also used : PathMeasure(android.graphics.PathMeasure) DashPathEffect(android.graphics.DashPathEffect) PathEffect(android.graphics.PathEffect) DashPathEffect(android.graphics.DashPathEffect)

Aggregations

PathEffect (android.graphics.PathEffect)15 DashPathEffect (android.graphics.DashPathEffect)14 Paint (android.graphics.Paint)6 Path (android.graphics.Path)6 Rect (android.graphics.Rect)3 RecyclerView (android.support.v7.widget.RecyclerView)3 View (android.view.View)3 Cap (android.graphics.Paint.Cap)2 Join (android.graphics.Paint.Join)2 Style (android.graphics.Paint.Style)2 BasicStroke (org.achartengine.renderer.BasicStroke)2 LinearGradient (android.graphics.LinearGradient)1 PathMeasure (android.graphics.PathMeasure)1 Shader (android.graphics.Shader)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1