Java Code Examples for android.graphics.Paint#Cap

The following examples show how to use android.graphics.Paint#Cap . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
private void invalidateForegroundStrokeCapAngle() {
    final Paint.Cap strokeCap = mForegroundStrokePaint.getStrokeCap();
    if (strokeCap == null) {
        mForegroundStrokeCapAngle = 0f;
        return;
    }
    switch (strokeCap) {
        case SQUARE:
        case ROUND: {
            final 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
Source Project: Mover   File: VectorDrawable.java    License: Apache License 2.0 5 votes vote down vote up
private Paint.Cap getStrokeLineCap(int id, Paint.Cap defValue) {
  switch (id) {
    case LINECAP_BUTT:
      return Paint.Cap.BUTT;
    case LINECAP_ROUND:
      return Paint.Cap.ROUND;
    case LINECAP_SQUARE:
      return Paint.Cap.SQUARE;
    default:
      return defValue;
  }
}
 
Example 3
@Override
public BezierDrawingRenderer createFromParcel(Parcel in) {
  int        color      = in.readInt();
  float      thickness  = in.readFloat();
  Paint.Cap  cap        = Paint.Cap.values()[in.readInt()];
  AutomaticControlPointBezierLine bezierLine = in.readParcelable(AutomaticControlPointBezierLine.class.getClassLoader());
  RectF      clipRect   = in.readParcelable(RectF.class.getClassLoader());

  return new BezierDrawingRenderer(color, thickness, cap, bezierLine, clipRect);
}
 
Example 4
public S hasStrokeCap(Paint.Cap cap) {
  isNotNull();
  Paint.Cap actualCap = actual.getStrokeCap();
  assertThat(actualCap) //
      .overridingErrorMessage("Expected stroke cap <%s> but was <%s>.", cap, actualCap) //
      .isEqualTo(cap);
  return myself;
}
 
Example 5
Source Project: ProjectX   File: CornerDrawable.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Set the paint's Cap.
 *
 * @param cap set the paint's line cap style, used whenever the paint's
 *            style is Stroke or StrokeAndFill.
 */
public void setStrokeCap(Paint.Cap cap) {
    if (mPaint.getStrokeCap() == cap)
        return;
    mPaint.setStrokeCap(cap);
    invalidateSelf();
}
 
Example 6
private Paint.Cap getStrokeLineCap(int id, Paint.Cap defValue) {
    switch (id) {
        case LINECAP_BUTT:
            return Paint.Cap.BUTT;
        case LINECAP_ROUND:
            return Paint.Cap.ROUND;
        case LINECAP_SQUARE:
            return Paint.Cap.SQUARE;
        default:
            return defValue;
    }
}
 
Example 7
@Override
public BezierDrawingRenderer createFromParcel(Parcel in) {
  int        color      = in.readInt();
  float      thickness  = in.readFloat();
  Paint.Cap  cap        = Paint.Cap.values()[in.readInt()];
  AutomaticControlPointBezierLine bezierLine = in.readParcelable(AutomaticControlPointBezierLine.class.getClassLoader());
  RectF      clipRect   = in.readParcelable(RectF.class.getClassLoader());

  return new BezierDrawingRenderer(color, thickness, cap, bezierLine, clipRect);
}
 
Example 8
/**
 * This will get the line cap style.
 *
 * @return null or the LC value of the dictionary.
 */
public Paint.Cap getLineCapStyle()
{
    switch(dict.getInt( COSName.LC ))  {
        case 0:
            return Paint.Cap.BUTT;
        case 1:
            return Paint.Cap.ROUND;
        case 2:
            return Paint.Cap.SQUARE;
        default:
            return null;
    }
}
 
Example 9
private LineMorphingDrawable(State[] states, int curState, int paddingLeft, int paddingTop, int paddingRight, int paddingBottom, int animDuration, Interpolator interpolator, int strokeSize, int strokeColor, Paint.Cap strokeCap, Paint.Join strokeJoin, boolean clockwise, boolean isRtl){
	mStates = states;
	mPaddingLeft = paddingLeft;
	mPaddingTop = paddingTop;
	mPaddingRight = paddingRight;
	mPaddingBottom = paddingBottom;
	
	mAnimDuration = animDuration;
	mInterpolator = interpolator;
	mStrokeSize = strokeSize;
	mStrokeColor = strokeColor;
	mStrokeCap = strokeCap;
	mStrokeJoin = strokeJoin;
	mClockwise = clockwise;
       mIsRtl = isRtl;
	
	mPaint = new Paint();
	mPaint.setAntiAlias(true);
	mPaint.setStyle(Paint.Style.STROKE);
	mPaint.setStrokeCap(mStrokeCap);
	mPaint.setStrokeJoin(mStrokeJoin);
	mPaint.setColor(mStrokeColor);
	mPaint.setStrokeWidth(mStrokeSize);
	
	mDrawBound = new RectF();
	
	mPath = new Path();			
		
	switchLineState(curState, false);
}
 
Example 10
Source Project: richmaps   File: RichPolyline.java    License: Apache License 2.0 5 votes vote down vote up
RichPolyline(final int zIndex,
             final List<RichPoint> points,
             final int strokeWidth,
             final Paint.Cap strokeCap,
             final Paint.Join strokeJoin,
             final PathEffect pathEffect,
             final MaskFilter maskFilter,
             final Shader strokeShader,
             final boolean linearGradient,
             final Integer strokeColor,
             final boolean antialias,
             final boolean closed) {
    super(zIndex, points, strokeWidth, strokeCap, strokeJoin, pathEffect, maskFilter,
            strokeShader, linearGradient, strokeColor, antialias, closed);
}
 
Example 11
Source Project: CanDialog   File: VectorDrawable.java    License: Apache License 2.0 5 votes vote down vote up
private Paint.Cap getStrokeLineCap(int id, Paint.Cap defValue) {
    switch (id) {
        case LINECAP_BUTT:
            return Paint.Cap.BUTT;
        case LINECAP_ROUND:
            return Paint.Cap.ROUND;
        case LINECAP_SQUARE:
            return Paint.Cap.SQUARE;
        default:
            return defValue;
    }
}
 
Example 12
Source Project: CircularSeekBar   File: CircularSeekBar.java    License: Apache License 2.0 4 votes vote down vote up
public void setCircleStyle(Paint.Cap style) {
    mCircleStyle = style;
    initPaints();
    recalculateAll();
    invalidate();
}
 
Example 13
/**
 * @param _spinnerStrokeCap The stroke cap of the progress bar in spinning mode.
 */
public void setSpinnerStrokeCap(Paint.Cap _spinnerStrokeCap) {
    mSpinnerStrokeCap = _spinnerStrokeCap;
    mBarSpinnerPaint.setStrokeCap(_spinnerStrokeCap);
}
 
Example 14
public Paint.Cap getSpinnerStrokeCap() {
    return mSpinnerStrokeCap;
}
 
Example 15
/**
 * Foreground stroke cap
 */
@NonNull
public Paint.Cap getForegroundStrokeCap() {
    return mBackgroundStrokePaint.getStrokeCap();
}
 
Example 16
Source Project: material   File: LineMorphingDrawable.java    License: Apache License 2.0 4 votes vote down vote up
public Builder strokeCap(Paint.Cap cap){
	mStrokeCap = cap;
	return this;
}
 
Example 17
Source Project: AndroidWear-OpenWear   File: OpenWatchFaceHand.java    License: MIT License 4 votes vote down vote up
public Paint.Cap getCap() {
    return cap;
}
 
Example 18
Source Project: WheelPicker   File: WheelView.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * 设置分割线两端形状
 *
 * @param dividerCap 分割线两端形状
 *                   {@link Paint.Cap#BUTT}
 *                   {@link Paint.Cap#ROUND}
 *                   {@link Paint.Cap#SQUARE}
 */
public void setDividerCap(Paint.Cap dividerCap) {
    if (mDividerCap == dividerCap) {
        return;
    }
    mDividerCap = dividerCap;
    invalidate();
}
 
Example 19
Source Project: AndroidWear-OpenWear   File: OpenWatchFaceHand.java    License: MIT License 2 votes vote down vote up
/**
 * 设置表盘指针的端点形状 默认:Paint.Cap.ROUND
 *
 * @param cap 端点形状
 * @see Paint.Cap
 */
public void setCap(Paint.Cap cap) {
    this.cap = cap;
}
 
Example 20
Source Project: Memento   File: CanvasView.java    License: MIT License 2 votes vote down vote up
/**
 * This method is setter for line cap.
 *
 * @param cap
 */
public void setLineCap(Paint.Cap cap) {
    this.lineCap = cap;
}