android.graphics.Paint#getStyle ( )源码实例Demo

下面列出了android.graphics.Paint#getStyle ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: html-textview   文件: NumberSpan.java
@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);
    }
}
 
源代码2 项目: android_9.0.0_r45   文件: QuoteSpan.java
@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);
}
 
源代码3 项目: lttrs-android   文件: QuoteSpan.java
@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);
}
 
源代码4 项目: Pioneer   文件: Spans.java
@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);
}
 
源代码5 项目: FlexibleRichTextView   文件: GeoGebraLogoBox.java
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();
}
 
源代码6 项目: JotaTextEditor   文件: BulletSpan.java
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);
    }
}
 
源代码7 项目: materialup   文件: FancyQuoteSpan.java
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);
}
 
源代码8 项目: memoir   文件: NumberSpan.java
@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);
    }
}
 
源代码9 项目: android-proguards   文件: FancyQuoteSpan.java
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);
}
 
源代码10 项目: Pix-Art-Messenger   文件: QuoteSpan.java
@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);
}
 
源代码11 项目: Telegram-FOSS   文件: BulletSpan.java
@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);
    }
}
 
源代码12 项目: lottie-android   文件: TextLayer.java
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);
}
 
源代码13 项目: Android-Font-Library   文件: TypefaceManager.java
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);
	}
}
 
源代码14 项目: Markdown   文件: MarkDownQuoteSpan.java
@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);
}
 
源代码15 项目: SteamGifts   文件: CustomHtmlTagHandler.java
@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);
}
 
源代码16 项目: FlexibleRichTextView   文件: FramedBox.java
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);
}
 
源代码17 项目: Pioneer   文件: Spans.java
@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);
}
 
源代码18 项目: Slide   文件: CustomQuoteSpan.java
@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);
}
 
源代码19 项目: FlexibleRichTextView   文件: FcscoreBox.java
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);
}
 
源代码20 项目: AndroidMathKeyboard   文件: FcscoreBox.java
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);
}