Java Code Examples for android.graphics.Paint.Cap

The following are Jave code examples for showing how to use Cap 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: circular-progress-bar   File: CircularProgressBar.java   View Source Code Vote up 6 votes
private void invalidateForegroundStrokeCapAngle() {
    Paint.Cap strokeCap = mForegroundStrokePaint.getStrokeCap();
    if (strokeCap == null) {
        mForegroundStrokeCapAngle = 0f;
        return;
    }
    switch (strokeCap) {
        case SQUARE:
        case ROUND: {
            float r = mDrawRect.width() / 2f;
            if (r != 0) {
                mForegroundStrokeCapAngle = 90f * mForegroundStrokePaint.getStrokeWidth() / (float) Math.PI / r;
            } else {
                mForegroundStrokeCapAngle = 0f;
            }
            break;
        }
        case BUTT:
        default: {
            mForegroundStrokeCapAngle = 0f;
            break;
        }
    }
}
 
Example 2
Project: phonk   File: PCanvas.java   View Source Code Vote up 6 votes
@ProtoMethod(description = "Sets a stroke cap", example = "")
@ProtoMethodParam(params = {"cap"})
public PCanvas strokeCap(String cap) {

    Paint.Cap c = Paint.Cap.SQUARE;

    switch (cap) {
        case "round":
            c = Paint.Cap.ROUND;
            break;

        case "butt":
            c = Paint.Cap.BUTT;

            break;

        case "square":
            c = Paint.Cap.SQUARE;

            break;
    }

    mPaintStroke.setStrokeCap(c);
    return this;
}
 
Example 3
Project: circular-progress-bar   File: CircularProgressBar.java   View Source Code Vote up 5 votes
@NonNull
private static Paint.Cap getStrokeCap(int value) {
    switch (value) {
        case 2: {
            return Paint.Cap.SQUARE;
        }
        case 1: {
            return Paint.Cap.ROUND;
        }
        case 0:
        default: {
            return Paint.Cap.BUTT;
        }
    }
}
 
Example 4
Project: greendao_expand   File: CircleProgressView.java   View Source Code Vote up 5 votes
/**
 * @param _barStrokeCap The stroke cap of the progress bar.
 */
public void setBarStrokeCap(Paint.Cap _barStrokeCap) {
    mBarStrokeCap = _barStrokeCap;
    mBarPaint.setStrokeCap(_barStrokeCap);
    if (mBarStrokeCap != Paint.Cap.BUTT) {
        mShaderlessBarPaint = new Paint(mBarPaint);
        mShaderlessBarPaint.setShader(null);
        mShaderlessBarPaint.setColor(mBarColors[0]);
    }
}
 
Example 5
Project: VectorMaster   File: Utils.java   View Source Code Vote up 5 votes
public static Paint.Cap getLineCapFromString(String value) {
    switch (value) {
        case "0":
            return Paint.Cap.BUTT;
        case "1":
            return Paint.Cap.ROUND;
        case "2":
            return Paint.Cap.SQUARE;
        default:
            return Paint.Cap.BUTT;
    }
}
 
Example 6
Project: atlas   File: ShapeStroke.java   View Source Code Vote up 5 votes
Paint.Cap toPaintCap() {
  switch (this) {
    case Butt:
      return Paint.Cap.BUTT;
    case Round:
      return Paint.Cap.ROUND;
    case Unknown:
    default:
      return Paint.Cap.SQUARE;
  }
}
 
Example 7
Project: GitHub   File: CircleProgressBar.java   View Source Code Vote up 4 votes
public Paint.Cap getCap() {
    return mCap;
}
 
Example 8
Project: GitHub   File: CircleProgressBar.java   View Source Code Vote up 4 votes
public void setCap(Paint.Cap cap) {
    mCap = cap;
    mProgressPaint.setStrokeCap(cap);
    mProgressBackgroundPaint.setStrokeCap(cap);
    invalidate();
}
 
Example 9
Project: AnimatedPieView   File: AnimatedPieViewConfig.java   View Source Code Vote up 4 votes
/**
 * 设置笔刷样式
 *
 * @param strokePaintCap 设置笔刷样式
 */
public AnimatedPieViewConfig setStrokePaintCap(@NonNull Paint.Cap strokePaintCap) {
    if (strokePaintCap == null) strokePaintCap = Paint.Cap.BUTT;
    this.strokePaintCap = strokePaintCap;
    return setReApply(true);
}
 
Example 10
Project: CanvasScript   File: PaintScript.java   View Source Code Vote up 4 votes
public PaintScript strokeCap(Paint.Cap cap) {
    paint.setStrokeCap(cap);
    return this;
}
 
Example 11
Project: circular-progress-bar   File: CircularProgressBar.java   View Source Code Vote up 4 votes
/**
 * Foreground stroke cap
 */
public void setForegroundStrokeCap(@NonNull Paint.Cap cap) {
    mForegroundStrokePaint.setStrokeCap(cap);
    invalidateForegroundStrokeCapAngle();
    invalidate();
}
 
Example 12
Project: CanvasScript   File: CanvasScript.java   View Source Code Vote up 4 votes
public CanvasScript strokeCap(Paint.Cap cap) {
    createPaintIfNull();
    currentPaint.setStrokeCap(cap);
    return this;
}
 
Example 13
Project: greendao_expand   File: CircleProgressView.java   View Source Code Vote up 4 votes
public Paint.Cap getSpinnerStrokeCap() {
    return mSpinnerStrokeCap;
}
 
Example 14
Project: greendao_expand   File: CircleProgressView.java   View Source Code Vote up 4 votes
/**
 * @param _spinnerStrokeCap The stroke cap of the progress bar in spinning mode.
 */
public void setSpinnerStrokeCap(Paint.Cap _spinnerStrokeCap) {
    mSpinnerStrokeCap = _spinnerStrokeCap;
    mBarSpinnerPaint.setStrokeCap(_spinnerStrokeCap);
}
 
Example 15
Project: VectorMaster   File: PathModel.java   View Source Code Vote up 4 votes
public Paint.Cap getStrokeLineCap() {
    return strokeLineCap;
}
 
Example 16
Project: VectorMaster   File: PathModel.java   View Source Code Vote up 4 votes
public void setStrokeLineCap(Paint.Cap strokeLineCap) {
    this.strokeLineCap = strokeLineCap;
    updatePaint();
}
 
Example 17
Project: Cable-Android   File: CanvasView.java   View Source Code Vote up 2 votes
/**
 * This method is setter for line cap.
 *
 * @param cap
 */
public void setLineCap(Paint.Cap cap) {
  this.lineCap = cap;
}
 
Example 18
Project: PeSanKita-android   File: CanvasView.java   View Source Code Vote up 2 votes
/**
 * This method is getter for line cap.
 *
 * @return
 */
public Paint.Cap getLineCap() {
  return this.lineCap;
}
 
Example 19
Project: PeSanKita-android   File: CanvasView.java   View Source Code Vote up 2 votes
/**
 * This method is setter for line cap.
 *
 * @param cap
 */
public void setLineCap(Paint.Cap cap) {
  this.lineCap = cap;
}
 
Example 20
Project: Cable-Android   File: CanvasView.java   View Source Code Vote up 2 votes
/**
 * This method is getter for line cap.
 *
 * @return
 */
public Paint.Cap getLineCap() {
  return this.lineCap;
}