下面列出了android.graphics.Paint#Cap ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
}
}
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;
}
}
@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);
}
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;
}
/**
* 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();
}
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;
}
}
@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);
}
/**
* 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;
}
}
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);
}
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);
}
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;
}
}
public void setCircleStyle(Paint.Cap style) {
mCircleStyle = style;
initPaints();
recalculateAll();
invalidate();
}
/**
* @param _spinnerStrokeCap The stroke cap of the progress bar in spinning mode.
*/
public void setSpinnerStrokeCap(Paint.Cap _spinnerStrokeCap) {
mSpinnerStrokeCap = _spinnerStrokeCap;
mBarSpinnerPaint.setStrokeCap(_spinnerStrokeCap);
}
public Paint.Cap getSpinnerStrokeCap() {
return mSpinnerStrokeCap;
}
/**
* Foreground stroke cap
*/
@NonNull
public Paint.Cap getForegroundStrokeCap() {
return mBackgroundStrokePaint.getStrokeCap();
}
public Builder strokeCap(Paint.Cap cap){
mStrokeCap = cap;
return this;
}
public Paint.Cap getCap() {
return cap;
}
/**
* 设置分割线两端形状
*
* @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();
}
/**
* 设置表盘指针的端点形状 默认:Paint.Cap.ROUND
*
* @param cap 端点形状
* @see Paint.Cap
*/
public void setCap(Paint.Cap cap) {
this.cap = cap;
}
/**
* This method is setter for line cap.
*
* @param cap
*/
public void setLineCap(Paint.Cap cap) {
this.lineCap = cap;
}