Java Code Examples for android.graphics.Paint#getStyle()
The following examples show how to use
android.graphics.Paint#getStyle() .
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: BulletSpan.java From JotaTextEditor with Apache License 2.0 | 6 votes |
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(); int oldcolor = 0; if (mWantColor) { oldcolor = p.getColor(); p.setColor(mColor); } p.setStyle(Paint.Style.FILL); c.drawCircle(x + dir * BULLET_RADIUS, (top + bottom) / 2.0f, BULLET_RADIUS, p); if (mWantColor) { p.setColor(oldcolor); } p.setStyle(style); } }
Example 2
Source File: FancyQuoteSpan.java From android-proguards with Apache License 2.0 | 6 votes |
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); }
Example 3
Source File: NumberSpan.java From memoir with Apache License 2.0 | 6 votes |
@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 l) { Spanned spanned = (Spanned) text; if (!mIgnoreSpan && spanned.getSpanStart(this) == start) { // set paint Paint.Style oldStyle = p.getStyle(); float oldTextSize = p.getTextSize(); p.setStyle(Paint.Style.FILL); mTextSize = baseline - top; p.setTextSize(mTextSize); mWidth = p.measureText(mNr + "."); // draw the number c.drawText(mNr + ".", x, baseline, p); // restore paint p.setStyle(oldStyle); p.setTextSize(oldTextSize); } }
Example 4
Source File: FancyQuoteSpan.java From materialup with Apache License 2.0 | 6 votes |
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); }
Example 5
Source File: NumberSpan.java From html-textview with Apache License 2.0 | 6 votes |
@Override public void drawLeadingMargin(@NonNull Canvas c, @NonNull Paint p, int x, int dir, int top, int baseline, int bottom, @NonNull CharSequence text, int start, int end, boolean first, @Nullable 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); } }
Example 6
Source File: GeoGebraLogoBox.java From FlexibleRichTextView with Apache License 2.0 | 6 votes |
public void draw(Canvas g2, float x, float y) { g2.save(); Paint st = AjLatexMath.getPaint(); int c = st.getColor(); Style s = st.getStyle(); float w = st.getStrokeWidth(); g2.translate(x + 0.25f * height / 2.15f, y - 1.75f / 2.15f * height); st.setColor(gray); st.setStrokeWidth(3.79999995f); g2.scale(0.05f * height / 2.15f, 0.05f * height / 2.15f); g2.rotate((float) Math.toDegrees((-26 * Math.PI / 180)), 20.5f, 17.5f); g2.drawArc(new RectF(0f, 0f, 43f, 32f), 0f, 360f, false, st); g2.rotate((float) Math.toDegrees((26 * Math.PI / 180)), 20.5f, 17.5f); st.setStyle(Style.STROKE); drawCircle(st, g2, 16f, -5f); drawCircle(st, g2, -1f, 7f); drawCircle(st, g2, 5f, 28f); drawCircle(st, g2, 27f, 24f); drawCircle(st, g2, 36f, 3f); st.setColor(c); st.setStyle(s); st.setStrokeWidth(w); g2.restore(); }
Example 7
Source File: Spans.java From Pioneer with Apache License 2.0 | 6 votes |
@Override public void draw(@NonNull Rect outRect, @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) { float oldStrokeWidth = paint.getStrokeWidth(); Paint.Style oldStyle = paint.getStyle(); int oldColor = paint.getColor(); paint.setStrokeWidth(strokeWidth); paint.setStyle(style); paint.setColor(color); canvas.save(); if (includePad) { canvas.translate(x + strokeWidth / 2, strokeWidth / 2); } else { canvas.translate(x + strokeWidth / 2, fontMetricsInt.ascent - fontMetricsInt.top + strokeWidth / 2); } shape.draw(canvas, paint); canvas.restore(); paint.setColor(oldColor); paint.setStyle(oldStyle); paint.setStrokeWidth(oldStrokeWidth); float oldTextSize = paint.getTextSize(); paint.setTextSize(oldTextSize * 0.8f); super.draw(outRect, canvas, text, start, end, x, top, y, bottom, paint); paint.setTextSize(oldTextSize); }
Example 8
Source File: QuoteSpan.java From lttrs-android with Apache License 2.0 | 6 votes |
@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 Paint.Style style = p.getStyle(); final int color = p.getColor(); p.setStyle(Paint.Style.FILL); p.setColor(this.color); for (int i = 0; i < depth; ++i) { final int dc = color(i, this.nightMode); p.setColor(dc); int additionalDistance = paddingPerLayer * i * width; c.drawRect(x + dir * paddingPerLayer + additionalDistance, top, x + dir * (paddingPerLayer + additionalDistance + width), bottom, p); } p.setStyle(style); p.setColor(color); }
Example 9
Source File: QuoteSpan.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public void drawLeadingMargin(@NonNull Canvas c, @NonNull Paint p, int x, int dir, int top, int baseline, int bottom, @NonNull CharSequence text, int start, int end, boolean first, @NonNull Layout layout) { Paint.Style style = p.getStyle(); int color = p.getColor(); p.setStyle(Paint.Style.FILL); p.setColor(mColor); c.drawRect(x, top, x + dir * mStripeWidth, bottom, p); p.setStyle(style); p.setColor(color); }
Example 10
Source File: TextLayer.java From lottie-android with Apache License 2.0 | 5 votes |
private void drawCharacter(String 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, character.length(), 0, 0, paint); }
Example 11
Source File: TypefaceManager.java From Android-Font-Library with The Unlicense | 5 votes |
public static void onDrawHelper(Canvas canvas, TextView target, DrawCallback drawCallback) { if (target.isInEditMode()) { return; } final ExtraFontData data = getFontData(target, false); if (data == null) { return; } if (data.borderWidth > 0) { final Paint paint = target.getPaint(); // setup stroke final Style oldStyle = paint.getStyle(); final ColorStateList oldTextColors = target.getTextColors(); final float oldStrokeWidth = paint.getStrokeWidth(); target.setTextColor(data.borderColor); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(data.borderWidth); drawCallback.onDrawCall(canvas); target.setTextColor(oldTextColors); paint.setStyle(oldStyle); paint.setStrokeWidth(oldStrokeWidth); } }
Example 12
Source File: MarkDownQuoteSpan.java From Markdown with MIT License | 5 votes |
@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(getColor()); c.drawRect(x, top, x + dir * STRIPE_WIDTH, bottom, p); p.setStyle(style); p.setColor(color); }
Example 13
Source File: CustomHtmlTagHandler.java From SteamGifts with MIT License | 5 votes |
@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(stripeColor); c.drawRect(x, top, x + dir * stripeWidth, bottom, p); p.setStyle(style); p.setColor(color); }
Example 14
Source File: FramedBox.java From FlexibleRichTextView with Apache License 2.0 | 5 votes |
public void draw(Canvas g2, float x, float y) { Paint st = AjLatexMath.getPaint(); float w = st.getStrokeWidth(); Style s = st.getStyle(); int c = st.getColor(); st.setStrokeWidth(thickness); st.setStyle(Style.FILL_AND_STROKE); float th = thickness / 2; if (bg != null) { st.setColor(bg); g2.drawRect(x + th, y - height + th, x + th + width - thickness, y + th + depth - thickness, st); } st.setStyle(Style.STROKE); if (line != null) { st.setColor(line); g2.drawRect(x + th, y - height + th, x + th + width - thickness, y + th + depth - thickness, st); } else { g2.drawRect(x + th, y - height + th, x + th + width - thickness, y + th + depth - thickness, st); } // drawDebug(g2, x, y); st.setStrokeWidth(w); st.setStyle(s); box.draw(g2, x + space + thickness, y); // st.setStyle(s); st.setColor(c); }
Example 15
Source File: Spans.java From Pioneer with Apache License 2.0 | 5 votes |
@Override public void draw(@NonNull Rect outRect, @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.Align oldAlign = paint.getTextAlign(); Paint.Style oldStyle = paint.getStyle(); float oldStrokeWidth = paint.getStrokeWidth(); if (align != null) { paint.setTextAlign(align); } if (style != null) { paint.setStyle(style); } if (strokeWidth > 0) { paint.setStrokeWidth(strokeWidth); } super.draw(outRect, canvas, text, start, end, x, top, y, bottom, paint); switch (paint.getTextAlign()) { case CENTER: canvas.drawText(text, start, end, x + (outRect.right - outRect.left) / 2, y, paint); break; default: canvas.drawText(text, start, end, x, y, paint); break; } paint.setTextAlign(oldAlign); paint.setStyle(oldStyle); paint.setStrokeWidth(oldStrokeWidth); }
Example 16
Source File: CustomQuoteSpan.java From Slide with GNU General Public License v3.0 | 5 votes |
@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 paintColor = p.getColor(); p.setStyle(Paint.Style.FILL); p.setColor(stripeColor); c.drawRect(x, top, x + dir * stripeWidth, bottom, p); p.setStyle(style); p.setColor(paintColor); }
Example 17
Source File: BulletSpan.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void drawLeadingMargin(Canvas canvas, Paint paint, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, int end, boolean first, Layout layout) { if (((Spanned) text).getSpanStart(this) == start) { Paint.Style style = paint.getStyle(); int oldcolor = 0; if (mWantColor) { oldcolor = paint.getColor(); paint.setColor(mColor); } paint.setStyle(Paint.Style.FILL); if (layout != null) { // "bottom" position might include extra space as a result of line spacing // configuration. Subtract extra space in order to show bullet in the vertical // center of characters. final int line = layout.getLineForOffset(start); int spacing = line != layout.getLineCount() - 1 ? (int) layout.getSpacingAdd() : 0; bottom = bottom - spacing; } final float yPosition = (top + bottom) / 2f; final float xPosition = x + dir * mBulletRadius; canvas.drawCircle(xPosition, yPosition, mBulletRadius, paint); if (mWantColor) { paint.setColor(oldcolor); } paint.setStyle(style); } }
Example 18
Source File: QuoteSpan.java From Pix-Art-Messenger with GNU General Public License v3.0 | 5 votes |
@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(this.color); c.drawRect(x + dir * paddingLeft, top, x + dir * (paddingLeft + width), bottom, p); p.setStyle(style); p.setColor(color); }
Example 19
Source File: FcscoreBox.java From FlexibleRichTextView with Apache License 2.0 | 4 votes |
public void draw(Canvas g2, float x, float y) { Paint st = AjLatexMath.getPaint(); /* * AffineTransform transf = g2.getTransform(); Stroke oldStroke = * g2.getStroke(); * * final double sx = transf.getScaleX(); final double sy = * transf.getScaleY(); */ float s = 1; /* * if (sx == sy) { // There are rounding problems due to scale factor: * lines could have different // spacing... // So the increment * (space+thickness) is done in using integer. s = sx; AffineTransform t * = (AffineTransform) transf.clone(); t.scale(1 / sx, 1 / sy); * g2.setTransform(t); } */ float w = st.getStrokeWidth(); Style ss = st.getStyle(); st.setStrokeWidth((float) (s * thickness)); st.setStyle(Style.STROKE); float th = thickness / 2.f; float xx = x + space; xx = (float) (xx * s + (space / 2.f) * s); final int inc = (int) Math.round((space + thickness) * s); for (int i = 0; i < N; i++) { g2.drawLine(xx + th * s, (y - height) * s, xx + th * s, y * s, st); xx += inc; } if (strike) { g2.drawLine((x + space) * s, (y - height / 2.f) * s, xx - s * space / 2, (y - height / 2.f) * s, st); } // g2.setTransform(transf); // g2.setStroke(oldStroke); st.setStrokeWidth(w); st.setStyle(ss); }
Example 20
Source File: FcscoreBox.java From AndroidMathKeyboard with Apache License 2.0 | 4 votes |
public void draw(Canvas g2, float x, float y) { Paint st = AjLatexMath.getPaint(); /* * AffineTransform transf = g2.getTransform(); Stroke oldStroke = * g2.getStroke(); * * final double sx = transf.getScaleX(); final double sy = * transf.getScaleY(); */ float s = 1; /* * if (sx == sy) { // There are rounding problems due to scale factor: * lines could have different // spacing... // So the increment * (space+thickness) is done in using integer. s = sx; AffineTransform t * = (AffineTransform) transf.clone(); t.scale(1 / sx, 1 / sy); * g2.setTransform(t); } */ float w = st.getStrokeWidth(); Style ss = st.getStyle(); st.setStrokeWidth((float) (s * thickness)); st.setStyle(Style.STROKE); float th = thickness / 2.f; float xx = x + space; xx = (float) (xx * s + (space / 2.f) * s); final int inc = (int) Math.round((space + thickness) * s); for (int i = 0; i < N; i++) { g2.drawLine(xx + th * s, (y - height) * s, xx + th * s, y * s, st); xx += inc; } if (strike) { g2.drawLine((x + space) * s, (y - height / 2.f) * s, xx - s * space / 2, (y - height / 2.f) * s, st); } // g2.setTransform(transf); // g2.setStroke(oldStroke); st.setStrokeWidth(w); st.setStyle(ss); }