Java Code Examples for android.graphics.Paint.setStrokeMiter()

The following are Jave code examples for showing how to use setStrokeMiter() of the android.graphics.Paint class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: weex-svg   File: WXSvgPath.java   View Source Code Vote up 6 votes
/**
 * Sets up paint according to the props set on a shadow view. Returns {@code true}
 * if the stroke should be drawn, {@code false} if not.
 */
protected boolean setupStrokePaint(Paint paint, float opacity, @Nullable RectF box) {
  paint.reset();
  if (TextUtils.isEmpty(mStrokeColor)) {
    return false;
  }

  paint.setFlags(Paint.ANTI_ALIAS_FLAG);
  paint.setStyle(Paint.Style.STROKE);
  paint.setStrokeCap(mStrokeLinecap);
  paint.setStrokeJoin(mStrokeLinejoin);
  paint.setStrokeMiter(mStrokeMiterlimit * mScale);
  paint.setStrokeWidth(mStrokeWidth * mScale);
  setupPaint(paint, opacity, mStrokeColor, box);

  if (mStrokeDasharray != null && mStrokeDasharray.length > 0) {
    paint.setPathEffect(new DashPathEffect(mStrokeDasharray, mStrokeDashoffset));
  }

  return true;
}
 
Example 2
Project: buildAPKsApps   File: XYChart.java   View Source Code Vote up 5 votes
private void setStroke(Cap cap, Join join, float miter, Style style, PathEffect pathEffect,
    Paint paint) {
  paint.setStrokeCap(cap);
  paint.setStrokeJoin(join);
  paint.setStrokeMiter(miter);
  paint.setPathEffect(pathEffect);
  paint.setStyle(style);
}
 
Example 3
Project: ChinaMapInfoView   File: CnSvgBigRenderer.java   View Source Code Vote up 5 votes
private void renderGo(Canvas canvas, ColorFilter filter, Paint paint, int i) {
    if (i >= 0 && i <= 8) {
        renderByProvince1(i);
    } else if (i >= 9 && i <= 19) {
        renderByProvince2(i);
    } else if (i >= 20 && i <= 29) {
        renderByProvince3(i);
    } else if (i >= 29 && i <= 33) {
        renderByProvince4(i);
    }
    mRenderPath.addPath(mPath, mFinalPathMatrix);
    paint.setStrokeJoin(Paint.Join.MITER);
    paint.setStrokeCap(Paint.Cap.BUTT);
    paint.setStrokeMiter(4.0f);
    paint.setColorFilter(filter);
    canvas.drawPath(mRenderPath, paint);

    // Region
    mRegion = mRegionList.get(i);
    mRegion.setPath(mRenderPath, mGlobalRegion);
    mRegionList.set(i, mRegion);

    mPath.reset();
    mRenderPath.reset();

    mFinalPathMatrix.setValues(
            new float[]{1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}
    );
    mFinalPathMatrix.postScale(scaleX, scaleY);
}
 
Example 4
Project: boohee_v5.6   File: VectorDrawableCompat.java   View Source Code Vote up 4 votes
private void drawPath(VGroup vGroup, VPath vPath, Canvas canvas, int w, int h, ColorFilter filter) {
    float scaleX = ((float) w) / this.mViewportWidth;
    float scaleY = ((float) h) / this.mViewportHeight;
    float minScale = Math.min(scaleX, scaleY);
    Matrix groupStackedMatrix = vGroup.mStackedMatrix;
    this.mFinalPathMatrix.set(groupStackedMatrix);
    this.mFinalPathMatrix.postScale(scaleX, scaleY);
    float matrixScale = getMatrixScale(groupStackedMatrix);
    if (matrixScale != 0.0f) {
        vPath.toPath(this.mPath);
        Path path = this.mPath;
        this.mRenderPath.reset();
        if (vPath.isClipPath()) {
            this.mRenderPath.addPath(path, this.mFinalPathMatrix);
            canvas.clipPath(this.mRenderPath, Op.REPLACE);
            return;
        }
        VFullPath fullPath = (VFullPath) vPath;
        if (!(fullPath.mTrimPathStart == 0.0f && fullPath.mTrimPathEnd == 1.0f)) {
            float start = (fullPath.mTrimPathStart + fullPath.mTrimPathOffset) % 1.0f;
            float end = (fullPath.mTrimPathEnd + fullPath.mTrimPathOffset) % 1.0f;
            if (this.mPathMeasure == null) {
                this.mPathMeasure = new PathMeasure();
            }
            this.mPathMeasure.setPath(this.mPath, false);
            float len = this.mPathMeasure.getLength();
            start *= len;
            end *= len;
            path.reset();
            if (start > end) {
                this.mPathMeasure.getSegment(start, len, path, true);
                this.mPathMeasure.getSegment(0.0f, end, path, true);
            } else {
                this.mPathMeasure.getSegment(start, end, path, true);
            }
            path.rLineTo(0.0f, 0.0f);
        }
        this.mRenderPath.addPath(path, this.mFinalPathMatrix);
        if (fullPath.mFillColor != 0) {
            if (this.mFillPaint == null) {
                this.mFillPaint = new Paint();
                this.mFillPaint.setStyle(Style.FILL);
                this.mFillPaint.setAntiAlias(true);
            }
            Paint fillPaint = this.mFillPaint;
            fillPaint.setColor(VectorDrawableCompat.applyAlpha(fullPath.mFillColor, fullPath.mFillAlpha));
            fillPaint.setColorFilter(filter);
            canvas.drawPath(this.mRenderPath, fillPaint);
        }
        if (fullPath.mStrokeColor != 0) {
            if (this.mStrokePaint == null) {
                this.mStrokePaint = new Paint();
                this.mStrokePaint.setStyle(Style.STROKE);
                this.mStrokePaint.setAntiAlias(true);
            }
            Paint strokePaint = this.mStrokePaint;
            if (fullPath.mStrokeLineJoin != null) {
                strokePaint.setStrokeJoin(fullPath.mStrokeLineJoin);
            }
            if (fullPath.mStrokeLineCap != null) {
                strokePaint.setStrokeCap(fullPath.mStrokeLineCap);
            }
            strokePaint.setStrokeMiter(fullPath.mStrokeMiterlimit);
            strokePaint.setColor(VectorDrawableCompat.applyAlpha(fullPath.mStrokeColor, fullPath.mStrokeAlpha));
            strokePaint.setColorFilter(filter);
            strokePaint.setStrokeWidth(fullPath.mStrokeWidth * (minScale * matrixScale));
            canvas.drawPath(this.mRenderPath, strokePaint);
        }
    }
}