private void drawGlyph(Path path, Paint paint, Canvas canvas) { if (paint.getColor() == Color.TRANSPARENT) { return; } if (paint.getStyle() == Paint.Style.STROKE && paint.getStrokeWidth() == 0) { return; } canvas.drawPath(path, paint); }
private void drawCharacter(char[] character, Paint paint, Canvas canvas) { if (paint.getColor() == Color.TRANSPARENT) { return; } if (paint.getStyle() == Paint.Style.STROKE && paint.getStrokeWidth() == 0) { return; } canvas.drawText(character, 0, 1, 0, 0, paint); }
@Override public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, int end, boolean first, Layout layout) { final Style style = p.getStyle(); final int color = p.getColor(); p.setStyle(FILL); p.setColor(this.color); c.drawRect(x, top, x + dir * 6, bottom, p); p.setStyle(style); p.setColor(color); } }
public void drawRect(float x, float y, float width, float height) { Style oldStyle = paint.getStyle(); paint.setStyle(Style.STROKE); canvas.drawRect(x, y, x + width, y + height, paint); paint.setStyle(oldStyle); }
public void drawString(String text, float x, float y) { Style oldStyle = paint.getStyle(); paint.setStyle(Style.FILL); canvas.drawText(text, x, y, paint); paint.setStyle(oldStyle); }
public void drawLine(float x1, float y1, float x2, float y2) { Style oldStyle = paint.getStyle(); paint.setStyle(Style.FILL_AND_STROKE); canvas.drawLine(x1, y1, x2, y2, paint); paint.setStyle(oldStyle); }
public void fillRect(float x, float y, float width, float height) { Style oldStyle = paint.getStyle(); paint.setStyle(Style.FILL); canvas.drawRect(x, y, x + width, y + height, paint); paint.setStyle(oldStyle); }
public void drawArc(float x, float y, float width, float height, float startAngle, float arcAngle) { if (arcAngle == 0) { return; } Style oldStyle = paint.getStyle(); paint.setStyle(Style.STROKE); RectF rectF = new RectF(x, y, x + width, y + height); canvas.drawArc(rectF, startAngle, arcAngle, true, paint); paint.setStyle(oldStyle); }
public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, int end, boolean first, Layout layout) { Paint.Style prevStyle = p.getStyle(); int prevColor = p.getColor(); p.setStyle(Paint.Style.FILL); p.setColor(lineColor); c.drawRect(x, top, x + dir * lineWidth, bottom, p); p.setStyle(prevStyle); p.setColor(prevColor); } }
public void fillArc(float x, float y, float width, float height, float startAngle, float arcAngle) { if (arcAngle == 0) { return; } Style oldStyle = paint.getStyle(); paint.setStyle(Style.FILL); RectF rectF = new RectF(x, y, x + width, y + height); canvas.drawArc(rectF, startAngle, arcAngle, true, paint); paint.setStyle(oldStyle); }
@Override public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, int end, boolean first, Layout layout) { Paint.Style style = p.getStyle(); int color = p.getColor(); p.setStyle(Paint.Style.FILL); p.setColor(quoteColor); c.drawRect(x, top, x + dir * quoteGapWidth, bottom, p); p.setStyle(style); p.setColor(color); } }
private RectPaintHistoryEvent( float left, float top, float right, float bottom, Paint paint){ this.rect = new RectF(left, top, right, bottom); this.paint = new Paint(paint); this.paint.setColor(paint.getColor()); this.paint.setStrokeWidth(paint.getStrokeWidth()); this.paint.setTextSize(paint.getTextSize()); this.paint.setStyle(paint.getStyle()); this.left = left; this.top = top; this.right = right; this.bottom = bottom; } }
/** * Draws the provided path in filled mode with the provided color and alpha. * Special thanks to Angelo Suzuki (https://github.com/tinsukE) for this. * * @param c * @param filledPath * @param fillColor * @param fillAlpha */ protected void drawFilledPath(Canvas c, Path filledPath, int fillColor, int fillAlpha) { int color = (fillAlpha << 24) | (fillColor & 0xffffff); if (clipPathSupported()) { int save = c.save(); c.clipPath(filledPath); c.drawColor(color); c.restoreToCount(save); } else { // save Paint.Style previous = mRenderPaint.getStyle(); int previousColor = mRenderPaint.getColor(); // set mRenderPaint.setStyle(Paint.Style.FILL); mRenderPaint.setColor(color); c.drawPath(filledPath, mRenderPaint); // restore mRenderPaint.setColor(previousColor); mRenderPaint.setStyle(previous); } }
public S hasStyle(Paint.Style style) { isNotNull(); Paint.Style actualStyle = actual.getStyle(); assertThat(actualStyle) // .overridingErrorMessage("Expected style <%s> but was <%s>.", style, actualStyle) // .isEqualTo(style); return myself; }
public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, int end, boolean first, Layout l) { if (((Spanned) text).getSpanStart(this) == start) { Paint.Style style = p.getStyle(); p.setStyle(Paint.Style.FILL); if (c.isHardwareAccelerated()) { c.save(); c.drawText(mNumber,x + dir, baseline, p); c.restore(); } else { c.drawText(mNumber,x + dir, (top + bottom) / 2.0f, p); } p.setStyle(style); } } }
boolean first, Layout l) { if (((Spanned) text).getSpanStart(this) == start) { Paint.Style style = p.getStyle();
@Override public void draw(@NonNull Canvas canvas, CharSequence text, @IntRange(from = 0) int start, @IntRange(from = 0) int end, float x, int top, int y, int bottom, @NonNull Paint paint) { Paint.Style style = paint.getStyle(); int color = paint.getColor(); paint.setStyle(Paint.Style.FILL); paint.setColor(this.color); canvas.drawRect(x, top, x + width, bottom, paint); paint.setStyle(style); paint.setColor(color); } }
public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, int end, boolean first, Layout layout) { Paint.Style style = p.getStyle(); int color = p.getColor(); p.setStyle(Paint.Style.FILL); p.setColor(getColor()); c.drawRect(x, top, x + dir * STRIPE_WIDTH, bottom, p); p.setStyle(style); p.setColor(color); } }
void drawMultiLineText(String str, float x, float y, Paint paint, Canvas canvas) { String[] lines = str.split("\n"); float txtSize = -paint.ascent() + paint.descent(); if (paint.getStyle() == Style.FILL_AND_STROKE || paint.getStyle() == Style.STROKE){ txtSize += paint.getStrokeWidth(); //add stroke width to the text size } float lineSpace = txtSize * 0.2f; //default line spacing for (int i = 0; i < lines.length; ++i) { canvas.drawText(lines[i], x, y + (txtSize + lineSpace) * i, paint); } }
public S hasStyle(Paint.Style style) { isNotNull(); Paint.Style actualStyle = actual.getStyle(); assertThat(actualStyle) // .overridingErrorMessage("Expected style <%s> but was <%s>.", style, actualStyle) // .isEqualTo(style); return myself; }