下面列出了怎么用android.graphics.Paint.Join的API类实例代码及写法,或者点击链接到github查看源代码。
public MultiBoxTracker(final Context context) {
this.context = context;
for (final int color : COLORS) {
availableColors.add(color);
}
boxPaint.setColor(Color.RED);
boxPaint.setStyle(Style.STROKE);
boxPaint.setStrokeWidth(12.0f);
boxPaint.setStrokeCap(Cap.ROUND);
boxPaint.setStrokeJoin(Join.ROUND);
boxPaint.setStrokeMiter(100);
textSizePx =
TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, TEXT_SIZE_DIP, context.getResources().getDisplayMetrics());
borderedText = new BorderedText(textSizePx);
}
public void UpdateCanvas() {
canvasMaster.drawColor(0, Mode.CLEAR);
canvasMaster.drawBitmap(lastEditedBitmap, 0.0f, 0.0f, null);
int i = 0;
while (true) {
if (i >= paths.size()) {
break;
}
int brushSize = brushSizes.get(i);
Paint paint = new Paint();
paint.setColor(0);
paint.setStyle(Style.STROKE);
paint.setAntiAlias(true);
paint.setStrokeJoin(Join.ROUND);
paint.setStrokeCap(Cap.ROUND);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC));
paint.setStrokeWidth((float) brushSize);
canvasMaster.drawPath(paths.get(i), paint);
i += 1;
}
touchImageView.invalidate();
}
private SimpleGraph(final int color, final long maxNsecs, final float width, final float height, final float strokeWidth)
{
this.maxNsecs = maxNsecs;
// this.width = width;
this.height = height;
nsecWidth = width / maxNsecs;
paintStroke = new Paint();
paintStroke.setColor(color);
paintStroke.setAlpha(204); // 80%
paintStroke.setStyle(Style.STROKE);
paintStroke.setStrokeWidth(strokeWidth);
paintStroke.setStrokeCap(Cap.ROUND);
paintStroke.setStrokeJoin(Join.ROUND);
paintStroke.setAntiAlias(true);
paintFill = new Paint();
paintFill.setColor(color);
paintFill.setAlpha(51); // 20%
paintFill.setStyle(Style.FILL);
paintFill.setAntiAlias(true);
pathStroke = new Path();
pathFill = new Path();
}
private StaticGraph(final int color, final float width, final float height, final float strokeWidth)
{
this.height = height;
this.width = width;
pathStroke = new Path();
pathFill = new Path();
paintStroke = new Paint();
paintFill = new Paint();
paintStroke.setColor(color);
paintStroke.setAlpha(204); // 80%
paintStroke.setStyle(Style.STROKE);
paintStroke.setStrokeWidth(strokeWidth);
paintStroke.setStrokeCap(Cap.ROUND);
paintStroke.setStrokeJoin(Join.ROUND);
paintStroke.setAntiAlias(true);
paintFill.setColor(color);
paintFill.setAlpha(51); // 20%
paintFill.setStyle(Style.FILL);
paintFill.setAntiAlias(true);
}
private SmoothGraph(final int color, final float width, final float height, final float strokeWidth)
{
this.height = height;
this.width = width;
paintStroke = new Paint();
paintStroke.setColor(color);
paintStroke.setAlpha(204); // 80%
paintStroke.setStyle(Style.STROKE);
paintStroke.setStrokeWidth(strokeWidth);
paintStroke.setStrokeCap(Cap.ROUND);
paintStroke.setStrokeJoin(Join.ROUND);
paintStroke.setAntiAlias(true);
paintFill = new Paint();
paintFill.setColor(color);
paintFill.setAlpha(51); // 20%
paintFill.setStyle(Style.FILL);
paintFill.setAntiAlias(true);
pathStroke = new Path();
pathFill = new Path();
}
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
this.canvas = canvas;
this.paint.setStrokeWidth(8.0f);
this.paint.setAntiAlias(true);
this.paint.setStyle(Style.FILL);
this.paint.setStrokeJoin(Join.ROUND);
if (this.clean) {
this.clean = false;
removeAll(canvas);
recycle(this.birmapbg, this.ringbg);
canvas.drawBitmap(this.birmapbg, 0.0f, 0.0f, this.paint);
this.paint.setColor(getResources().getColor(R.color.white_100));
canvas.drawBitmap(this.ringbg, this.endX - this.radius, this.endY - this.radius, this.paint);
return;
}
if (this.joyOkay) {
this.joyOkay = false;
removeAll(canvas);
recycle(this.birmapbg, this.ringbg);
canvas.drawBitmap(this.rtBmp, 0.0f, 0.0f, this.paint);
} else {
canvas.drawBitmap(this.birmapbg, 0.0f, 0.0f, this.paint);
this.paint.setColor(getResources().getColor(R.color.white_100));
canvas.drawLine(this.centerX, this.centerY, this.centerX, this.endY, this.paint);
canvas.drawLine(this.centerX, this.centerY, this.endX, this.centerY, this.paint);
clipPath(this.type);
canvas.drawBitmap(this.ringbg, this.endX - this.radius, this.endY - this.radius, this.paint);
}
recycle(this.birmapbg, this.ringbg, this.rtBmp);
}
private void drawOnTouchMove() {
Paint paint = new Paint();
paint.setStrokeWidth((float) updatedBrushSize);
paint.setColor(0);
paint.setStyle(Style.STROKE);
paint.setAntiAlias(true);
paint.setStrokeJoin(Join.ROUND);
paint.setStrokeCap(Cap.ROUND);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC));
canvasMaster.drawPath(drawingPath, paint);
touchImageView.invalidate();
}
public void UpdateLastEiditedBitmapForUndoLimit() {
Canvas canvas = new Canvas(lastEditedBitmap);
for (int i = 0; i < 1; i += 1) {
int brushSize = brushSizes.get(i);
Paint paint = new Paint();
paint.setColor(0);
paint.setStyle(Style.STROKE);
paint.setAntiAlias(true);
paint.setStrokeJoin(Join.ROUND);
paint.setStrokeCap(Cap.ROUND);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC));
paint.setStrokeWidth((float) brushSize);
canvas.drawPath(paths.get(i), paint);
}
}
private void drawPointerArrow(Canvas canvas) {
int centerX = getWidth() / 2;
int centerY = getHeight() / 2;
double tipAngle = (colorHSV[2] - 0.5f) * Math.PI;
double leftAngle = tipAngle + Math.PI / 96;
double rightAngle = tipAngle - Math.PI / 96;
double tipAngleX = Math.cos(tipAngle) * outerWheelRadius;
double tipAngleY = Math.sin(tipAngle) * outerWheelRadius;
double leftAngleX = Math.cos(leftAngle) * (outerWheelRadius + arrowPointerSize);
double leftAngleY = Math.sin(leftAngle) * (outerWheelRadius + arrowPointerSize);
double rightAngleX = Math.cos(rightAngle) * (outerWheelRadius + arrowPointerSize);
double rightAngleY = Math.sin(rightAngle) * (outerWheelRadius + arrowPointerSize);
arrowPointerPath.reset();
arrowPointerPath.moveTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
arrowPointerPath.lineTo((float) leftAngleX + centerX, (float) leftAngleY + centerY);
arrowPointerPath.lineTo((float) rightAngleX + centerX, (float) rightAngleY + centerY);
arrowPointerPath.lineTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
valuePointerArrowPaint.setColor(Color.HSVToColor(colorHSV));
valuePointerArrowPaint.setStyle(Style.FILL);
canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);
valuePointerArrowPaint.setStyle(Style.STROKE);
valuePointerArrowPaint.setStrokeJoin(Join.ROUND);
valuePointerArrowPaint.setColor(Color.BLACK);
canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);
}
public CellContainer(Context context, AttributeSet attr) {
super(context, attr);
_paint.setStyle(Style.STROKE);
_paint.setStrokeWidth(2.0f);
_paint.setStrokeJoin(Join.ROUND);
_paint.setColor(Color.WHITE);
_paint.setAlpha(0);
_bgPaint.setStyle(Style.FILL);
_bgPaint.setColor(Color.WHITE);
_bgPaint.setAlpha(0);
_outlinePaint.setColor(Color.WHITE);
_outlinePaint.setAlpha(0);
init();
}
private void drawPointerArrow(Canvas canvas) {
int centerX = getWidth() / 2;
int centerY = getHeight() / 2;
double tipAngle = (colorHSV[2] - 0.5f) * Math.PI;
double leftAngle = tipAngle + Math.PI / 96;
double rightAngle = tipAngle - Math.PI / 96;
double tipAngleX = Math.cos(tipAngle) * outerWheelRadius;
double tipAngleY = Math.sin(tipAngle) * outerWheelRadius;
double leftAngleX = Math.cos(leftAngle) * (outerWheelRadius + arrowPointerSize);
double leftAngleY = Math.sin(leftAngle) * (outerWheelRadius + arrowPointerSize);
double rightAngleX = Math.cos(rightAngle) * (outerWheelRadius + arrowPointerSize);
double rightAngleY = Math.sin(rightAngle) * (outerWheelRadius + arrowPointerSize);
arrowPointerPath.reset();
arrowPointerPath.moveTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
arrowPointerPath.lineTo((float) leftAngleX + centerX, (float) leftAngleY + centerY);
arrowPointerPath.lineTo((float) rightAngleX + centerX, (float) rightAngleY + centerY);
arrowPointerPath.lineTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
valuePointerArrowPaint.setColor(Color.HSVToColor(colorHSV));
valuePointerArrowPaint.setStyle(Style.FILL);
canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);
valuePointerArrowPaint.setStyle(Style.STROKE);
valuePointerArrowPaint.setStrokeJoin(Join.ROUND);
valuePointerArrowPaint.setColor(Color.BLACK);
canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);
}
private void drawPointerArrow(Canvas canvas) {
int centerX = getWidth() / 2;
int centerY = getHeight() / 2;
double tipAngle = (colorHSV[2] - 0.5f) * Math.PI;
double leftAngle = tipAngle + Math.PI / 96;
double rightAngle = tipAngle - Math.PI / 96;
double tipAngleX = Math.cos(tipAngle) * outerWheelRadius;
double tipAngleY = Math.sin(tipAngle) * outerWheelRadius;
double leftAngleX = Math.cos(leftAngle) * (outerWheelRadius + arrowPointerSize);
double leftAngleY = Math.sin(leftAngle) * (outerWheelRadius + arrowPointerSize);
double rightAngleX = Math.cos(rightAngle) * (outerWheelRadius + arrowPointerSize);
double rightAngleY = Math.sin(rightAngle) * (outerWheelRadius + arrowPointerSize);
arrowPointerPath.reset();
arrowPointerPath.moveTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
arrowPointerPath.lineTo((float) leftAngleX + centerX, (float) leftAngleY + centerY);
arrowPointerPath.lineTo((float) rightAngleX + centerX, (float) rightAngleY + centerY);
arrowPointerPath.lineTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
valuePointerArrowPaint.setColor(Color.HSVToColor(colorHSV));
valuePointerArrowPaint.setStyle(Style.FILL);
canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);
valuePointerArrowPaint.setStyle(Style.STROKE);
valuePointerArrowPaint.setStrokeJoin(Join.ROUND);
valuePointerArrowPaint.setColor(Color.BLACK);
canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);
}
/**
* Constructs a new PX stroke.
*/
public PXStroke() {
this.type = PXStrokeType.CENTER;
this.width = 1.0f;
this.dashOffset = 0;
this.lineCap = Cap.BUTT;
this.lineJoin = Join.MITER;
this.miterLimit = 4.0f; // What is a reasonable default here?
}
private static Join lineJoinFromString(String value) {
if (value == null) {
return Join.MITER;
}
Join join = Join.valueOf(value.toUpperCase(Locale.US));
if (join == null) {
PXLog.e(TAG, "Unrecognized line join: " + value);
}
return join;
}
private static void drawDOMArrow(Canvas ctx, Point[] domPoints, int alpha, Color lineColor)
{
Paint domPaint = new Paint();
domPaint.setStrokeCap(Cap.BUTT);
domPaint.setStrokeJoin(Join.MITER);
domPaint.setStrokeWidth(3);
domPaint.setColor(lineColor.toInt());
domPaint.setStyle(Style.STROKE);
if(alpha > -1)
domPaint.setAlpha(alpha);
Path domPath = new Path();
domPath.moveTo(domPoints[0].x, domPoints[0].y);
if (domPoints[1] != null)
{
domPath.lineTo(domPoints[1].x, domPoints[1].y);
}
if (domPoints[2] != null)
{
domPath.lineTo(domPoints[2].x, domPoints[2].y);
}
ctx.drawPath(domPath, domPaint);
domPath.reset();
domPaint.setStyle(Style.FILL);
domPath.moveTo(domPoints[3].x, domPoints[3].y);
domPath.lineTo(domPoints[4].x, domPoints[4].y);
domPath.lineTo(domPoints[5].x, domPoints[5].y);
ctx.drawPath(domPath, domPaint);
}
private void drawPointerArrow(Canvas canvas) {
int centerX = getWidth() / 2;
int centerY = getHeight() / 2;
double tipAngle = (colorHSV[2] - 0.5f) * Math.PI;
double leftAngle = tipAngle + Math.PI / 96;
double rightAngle = tipAngle - Math.PI / 96;
double tipAngleX = Math.cos(tipAngle) * outerWheelRadius;
double tipAngleY = Math.sin(tipAngle) * outerWheelRadius;
double leftAngleX = Math.cos(leftAngle) * (outerWheelRadius + arrowPointerSize);
double leftAngleY = Math.sin(leftAngle) * (outerWheelRadius + arrowPointerSize);
double rightAngleX = Math.cos(rightAngle) * (outerWheelRadius + arrowPointerSize);
double rightAngleY = Math.sin(rightAngle) * (outerWheelRadius + arrowPointerSize);
arrowPointerPath.reset();
arrowPointerPath.moveTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
arrowPointerPath.lineTo((float) leftAngleX + centerX, (float) leftAngleY + centerY);
arrowPointerPath.lineTo((float) rightAngleX + centerX, (float) rightAngleY + centerY);
arrowPointerPath.lineTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
valuePointerArrowPaint.setColor(Color.HSVToColor(colorHSV));
valuePointerArrowPaint.setStyle(Style.FILL);
canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);
valuePointerArrowPaint.setStyle(Style.STROKE);
valuePointerArrowPaint.setStrokeJoin(Join.ROUND);
valuePointerArrowPaint.setColor(Color.BLACK);
canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);
}
private void drawPointerArrow(Canvas canvas) {
int centerX = getWidth() / 2;
int centerY = getHeight() / 2;
double tipAngle = (colorHSV[2] - 0.5f) * Math.PI;
double leftAngle = tipAngle + Math.PI / 96;
double rightAngle = tipAngle - Math.PI / 96;
double tipAngleX = Math.cos(tipAngle) * outerWheelRadius;
double tipAngleY = Math.sin(tipAngle) * outerWheelRadius;
double leftAngleX = Math.cos(leftAngle) * (outerWheelRadius + arrowPointerSize);
double leftAngleY = Math.sin(leftAngle) * (outerWheelRadius + arrowPointerSize);
double rightAngleX = Math.cos(rightAngle) * (outerWheelRadius + arrowPointerSize);
double rightAngleY = Math.sin(rightAngle) * (outerWheelRadius + arrowPointerSize);
arrowPointerPath.reset();
arrowPointerPath.moveTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
arrowPointerPath.lineTo((float) leftAngleX + centerX, (float) leftAngleY + centerY);
arrowPointerPath.lineTo((float) rightAngleX + centerX, (float) rightAngleY + centerY);
arrowPointerPath.lineTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
valuePointerArrowPaint.setColor(Color.HSVToColor(colorHSV));
valuePointerArrowPaint.setStyle(Style.FILL);
canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);
valuePointerArrowPaint.setStyle(Style.STROKE);
valuePointerArrowPaint.setStrokeJoin(Join.ROUND);
valuePointerArrowPaint.setColor(Color.BLACK);
canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);
}
private void drawPointerArrow(Canvas canvas) {
int centerX = getWidth() / 2;
int centerY = getHeight() / 2;
double tipAngle = (colorHSV[2] - 0.5f) * Math.PI;
double leftAngle = tipAngle + Math.PI / 96;
double rightAngle = tipAngle - Math.PI / 96;
double tipAngleX = Math.cos(tipAngle) * outerWheelRadius;
double tipAngleY = Math.sin(tipAngle) * outerWheelRadius;
double leftAngleX = Math.cos(leftAngle) * (outerWheelRadius + arrowPointerSize);
double leftAngleY = Math.sin(leftAngle) * (outerWheelRadius + arrowPointerSize);
double rightAngleX = Math.cos(rightAngle) * (outerWheelRadius + arrowPointerSize);
double rightAngleY = Math.sin(rightAngle) * (outerWheelRadius + arrowPointerSize);
arrowPointerPath.reset();
arrowPointerPath.moveTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
arrowPointerPath.lineTo((float) leftAngleX + centerX, (float) leftAngleY + centerY);
arrowPointerPath.lineTo((float) rightAngleX + centerX, (float) rightAngleY + centerY);
arrowPointerPath.lineTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
valuePointerArrowPaint.setColor(Color.HSVToColor(colorHSV));
valuePointerArrowPaint.setStyle(Style.FILL);
canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);
valuePointerArrowPaint.setStyle(Style.STROKE);
valuePointerArrowPaint.setStrokeJoin(Join.ROUND);
valuePointerArrowPaint.setColor(Color.BLACK);
canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);
}
@SuppressWarnings("PMD.NPathComplexity") // TODO break this method up
private void drawTextLayout(Canvas canvas) {
StaticLayout layout = textLayout;
if (layout == null) {
// Nothing to draw.
return;
}
int saveCount = canvas.save();
canvas.translate(textLeft, textTop);
if (Color.alpha(windowColor) > 0) {
paint.setColor(windowColor);
canvas.drawRect(-textPaddingX, 0, layout.getWidth() + textPaddingX, layout.getHeight(),
paint);
}
if (Color.alpha(backgroundColor) > 0) {
paint.setColor(backgroundColor);
float previousBottom = layout.getLineTop(0);
int lineCount = layout.getLineCount();
for (int i = 0; i < lineCount; i++) {
lineBounds.left = layout.getLineLeft(i) - textPaddingX;
lineBounds.right = layout.getLineRight(i) + textPaddingX;
lineBounds.top = previousBottom;
lineBounds.bottom = layout.getLineBottom(i);
previousBottom = lineBounds.bottom;
canvas.drawRoundRect(lineBounds, cornerRadius, cornerRadius, paint);
}
}
if (edgeType == CaptionStyleCompat.EDGE_TYPE_OUTLINE) {
textPaint.setStrokeJoin(Join.ROUND);
textPaint.setStrokeWidth(outlineWidth);
textPaint.setColor(edgeColor);
textPaint.setStyle(Style.FILL_AND_STROKE);
layout.draw(canvas);
} else if (edgeType == CaptionStyleCompat.EDGE_TYPE_DROP_SHADOW) {
textPaint.setShadowLayer(shadowRadius, shadowOffset, shadowOffset, edgeColor);
} else if (edgeType == CaptionStyleCompat.EDGE_TYPE_RAISED
|| edgeType == CaptionStyleCompat.EDGE_TYPE_DEPRESSED) {
boolean raised = edgeType == CaptionStyleCompat.EDGE_TYPE_RAISED;
int colorUp = raised ? Color.WHITE : edgeColor;
int colorDown = raised ? edgeColor : Color.WHITE;
float offset = shadowRadius / 2;
textPaint.setColor(foregroundColor);
textPaint.setStyle(Style.FILL);
textPaint.setShadowLayer(shadowRadius, -offset, -offset, colorUp);
layout.draw(canvas);
textPaint.setShadowLayer(shadowRadius, offset, offset, colorDown);
}
textPaint.setColor(foregroundColor);
textPaint.setStyle(Style.FILL);
layout.draw(canvas);
textPaint.setShadowLayer(0, 0, 0, 0);
canvas.restoreToCount(saveCount);
}
private void drawTextLayout(Canvas canvas) {
StaticLayout layout = textLayout;
if (layout == null) {
// Nothing to draw.
return;
}
int saveCount = canvas.save();
canvas.translate(textLeft, textTop);
if (Color.alpha(windowColor) > 0) {
paint.setColor(windowColor);
canvas.drawRect(-textPaddingX, 0, layout.getWidth() + textPaddingX, layout.getHeight(),
paint);
}
if (Color.alpha(backgroundColor) > 0) {
paint.setColor(backgroundColor);
float previousBottom = layout.getLineTop(0);
int lineCount = layout.getLineCount();
for (int i = 0; i < lineCount; i++) {
lineBounds.left = layout.getLineLeft(i) - textPaddingX;
lineBounds.right = layout.getLineRight(i) + textPaddingX;
lineBounds.top = previousBottom;
lineBounds.bottom = layout.getLineBottom(i);
previousBottom = lineBounds.bottom;
canvas.drawRoundRect(lineBounds, cornerRadius, cornerRadius, paint);
}
}
if (edgeType == CaptionStyleCompat.EDGE_TYPE_OUTLINE) {
textPaint.setStrokeJoin(Join.ROUND);
textPaint.setStrokeWidth(outlineWidth);
textPaint.setColor(edgeColor);
textPaint.setStyle(Style.FILL_AND_STROKE);
layout.draw(canvas);
} else if (edgeType == CaptionStyleCompat.EDGE_TYPE_DROP_SHADOW) {
textPaint.setShadowLayer(shadowRadius, shadowOffset, shadowOffset, edgeColor);
} else if (edgeType == CaptionStyleCompat.EDGE_TYPE_RAISED
|| edgeType == CaptionStyleCompat.EDGE_TYPE_DEPRESSED) {
boolean raised = edgeType == CaptionStyleCompat.EDGE_TYPE_RAISED;
int colorUp = raised ? Color.WHITE : edgeColor;
int colorDown = raised ? edgeColor : Color.WHITE;
float offset = shadowRadius / 2f;
textPaint.setColor(foregroundColor);
textPaint.setStyle(Style.FILL);
textPaint.setShadowLayer(shadowRadius, -offset, -offset, colorUp);
layout.draw(canvas);
textPaint.setShadowLayer(shadowRadius, offset, offset, colorDown);
}
textPaint.setColor(foregroundColor);
textPaint.setStyle(Style.FILL);
layout.draw(canvas);
textPaint.setShadowLayer(0, 0, 0, 0);
canvas.restoreToCount(saveCount);
}
@Override
protected void onDraw(Canvas c) {
final StaticLayout layout = this.layout;
if (layout == null) {
return;
}
final int saveCount = c.save();
final int innerPaddingX = this.innerPaddingX;
c.translate(getPaddingLeft() + innerPaddingX, getPaddingTop());
final int lineCount = layout.getLineCount();
final Paint textPaint = this.textPaint;
final Paint paint = this.paint;
final RectF bounds = lineBounds;
if (Color.alpha(backgroundColor) > 0) {
final float cornerRadius = this.cornerRadius;
float previousBottom = layout.getLineTop(0);
paint.setColor(backgroundColor);
paint.setStyle(Style.FILL);
for (int i = 0; i < lineCount; i++) {
bounds.left = layout.getLineLeft(i) - innerPaddingX;
bounds.right = layout.getLineRight(i) + innerPaddingX;
bounds.top = previousBottom;
bounds.bottom = layout.getLineBottom(i);
previousBottom = bounds.bottom;
c.drawRoundRect(bounds, cornerRadius, cornerRadius, paint);
}
}
if (edgeType == CaptionStyleCompat.EDGE_TYPE_OUTLINE) {
textPaint.setStrokeJoin(Join.ROUND);
textPaint.setStrokeWidth(outlineWidth);
textPaint.setColor(edgeColor);
textPaint.setStyle(Style.FILL_AND_STROKE);
layout.draw(c);
} else if (edgeType == CaptionStyleCompat.EDGE_TYPE_DROP_SHADOW) {
textPaint.setShadowLayer(shadowRadius, shadowOffset, shadowOffset, edgeColor);
} else if (edgeType == CaptionStyleCompat.EDGE_TYPE_RAISED
|| edgeType == CaptionStyleCompat.EDGE_TYPE_DEPRESSED) {
boolean raised = edgeType == CaptionStyleCompat.EDGE_TYPE_RAISED;
int colorUp = raised ? Color.WHITE : edgeColor;
int colorDown = raised ? edgeColor : Color.WHITE;
float offset = shadowRadius / 2f;
textPaint.setColor(foregroundColor);
textPaint.setStyle(Style.FILL);
textPaint.setShadowLayer(shadowRadius, -offset, -offset, colorUp);
layout.draw(c);
textPaint.setShadowLayer(shadowRadius, offset, offset, colorDown);
}
textPaint.setColor(foregroundColor);
textPaint.setStyle(Style.FILL);
layout.draw(c);
textPaint.setShadowLayer(0, 0, 0, 0);
c.restoreToCount(saveCount);
}
/**
* @return the lineJoin
*/
public Join getLineJoin() {
return lineJoin;
}
/**
* @param lineJoin the lineJoin to set
*/
public void setLineJoin(Join lineJoin) {
this.lineJoin = lineJoin;
}