Java Code Examples for android.graphics.Paint#Cap

The following examples show how to use android.graphics.Paint#Cap . 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: CircularProgressBar.java    From circular-progress-bar with MIT License 6 votes vote down vote up
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 File: BezierDrawingRenderer.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@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 3
Source File: VectorDrawable.java    From CanDialog with 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 4
Source File: AbstractPaintAssert.java    From assertj-android with Apache License 2.0 5 votes vote down vote up
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 File: RichPolyline.java    From richmaps with 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 6
Source File: LineMorphingDrawable.java    From MDPreference with Apache License 2.0 5 votes vote down vote up
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 7
Source File: CornerDrawable.java    From ProjectX with 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 8
Source File: VectorDrawable.java    From ElasticProgressBar with 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 9
Source File: VectorDrawable.java    From Mover with 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 10
Source File: PDExtendedGraphicsState.java    From PdfBox-Android with Apache License 2.0 5 votes vote down vote up
/**
 * 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 11
Source File: BezierDrawingRenderer.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
@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 12
Source File: CircularProgressBar.java    From circular-progress-bar with MIT License 4 votes vote down vote up
/**
 * Foreground stroke cap
 */
@NonNull
public Paint.Cap getForegroundStrokeCap() {
    return mBackgroundStrokePaint.getStrokeCap();
}
 
Example 13
Source File: OpenWatchFaceHand.java    From AndroidWear-OpenWear with MIT License 4 votes vote down vote up
public Paint.Cap getCap() {
    return cap;
}
 
Example 14
Source File: LineMorphingDrawable.java    From material with Apache License 2.0 4 votes vote down vote up
public Builder strokeCap(Paint.Cap cap){
	mStrokeCap = cap;
	return this;
}
 
Example 15
Source File: CircleProgressView.java    From Circle-Progress-View with MIT License 4 votes vote down vote up
public Paint.Cap getSpinnerStrokeCap() {
    return mSpinnerStrokeCap;
}
 
Example 16
Source File: CircleProgressView.java    From Circle-Progress-View with MIT License 4 votes vote down vote up
/**
 * @param _spinnerStrokeCap The stroke cap of the progress bar in spinning mode.
 */
public void setSpinnerStrokeCap(Paint.Cap _spinnerStrokeCap) {
    mSpinnerStrokeCap = _spinnerStrokeCap;
    mBarSpinnerPaint.setStrokeCap(_spinnerStrokeCap);
}
 
Example 17
Source File: CircularSeekBar.java    From CircularSeekBar with Apache License 2.0 4 votes vote down vote up
public void setCircleStyle(Paint.Cap style) {
    mCircleStyle = style;
    initPaints();
    recalculateAll();
    invalidate();
}
 
Example 18
Source File: WheelView.java    From WheelPicker with 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 File: CanvasView.java    From Memento with 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;
}
 
Example 20
Source File: OpenWatchFaceHand.java    From AndroidWear-OpenWear with 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;
}