Search in sources :

Example 96 with Paint

use of android.graphics.Paint in project XobotOS by xamarin.

the class BoringLayout method isBoring.

/**
     * Returns null if not boring; the width, ascent, and descent in the
     * provided Metrics object (or a new one if the provided one was null)
     * if boring.
     * @hide
     */
public static Metrics isBoring(CharSequence text, TextPaint paint, TextDirectionHeuristic textDir, Metrics metrics) {
    char[] temp = TextUtils.obtain(500);
    int length = text.length();
    boolean boring = true;
    outer: for (int i = 0; i < length; i += 500) {
        int j = i + 500;
        if (j > length)
            j = length;
        TextUtils.getChars(text, i, j, temp, 0);
        int n = j - i;
        for (int a = 0; a < n; a++) {
            char c = temp[a];
            if (c == '\n' || c == '\t' || c >= FIRST_RIGHT_TO_LEFT) {
                boring = false;
                break outer;
            }
        }
        if (textDir != null && textDir.isRtl(temp, 0, n)) {
            boring = false;
            break outer;
        }
    }
    TextUtils.recycle(temp);
    if (boring && text instanceof Spanned) {
        Spanned sp = (Spanned) text;
        Object[] styles = sp.getSpans(0, length, ParagraphStyle.class);
        if (styles.length > 0) {
            boring = false;
        }
    }
    if (boring) {
        Metrics fm = metrics;
        if (fm == null) {
            fm = new Metrics();
        }
        TextLine line = TextLine.obtain();
        line.set(paint, text, 0, length, Layout.DIR_LEFT_TO_RIGHT, Layout.DIRS_ALL_LEFT_TO_RIGHT, false, null);
        fm.width = (int) FloatMath.ceil(line.metrics(fm));
        TextLine.recycle(line);
        return fm;
    } else {
        return null;
    }
}
Also used : Paint(android.graphics.Paint)

Example 97 with Paint

use of android.graphics.Paint in project XobotOS by xamarin.

the class SpannableStringBuilder method getTextWidths.

/**
     * Don't call this yourself -- exists for Paint to use internally.
     * {@hide}
     */
public int getTextWidths(int start, int end, float[] widths, Paint p) {
    checkRange("getTextWidths", start, end);
    int ret;
    if (end <= mGapStart) {
        ret = p.getTextWidths(mText, start, end - start, widths);
    } else if (start >= mGapStart) {
        ret = p.getTextWidths(mText, start + mGapLength, end - start, widths);
    } else {
        char[] buf = TextUtils.obtain(end - start);
        getChars(start, end, buf, 0);
        ret = p.getTextWidths(buf, 0, end - start, widths);
        TextUtils.recycle(buf);
    }
    return ret;
}
Also used : Paint(android.graphics.Paint)

Example 98 with Paint

use of android.graphics.Paint in project XobotOS by xamarin.

the class SpannableStringBuilder method drawTextRun.

/**
     * Don't call this yourself -- exists for Canvas to use internally.
     * {@hide}
     */
public void drawTextRun(Canvas c, int start, int end, int contextStart, int contextEnd, float x, float y, int flags, Paint p) {
    checkRange("drawTextRun", start, end);
    int contextLen = contextEnd - contextStart;
    int len = end - start;
    if (contextEnd <= mGapStart) {
        c.drawTextRun(mText, start, len, contextStart, contextLen, x, y, flags, p);
    } else if (contextStart >= mGapStart) {
        c.drawTextRun(mText, start + mGapLength, len, contextStart + mGapLength, contextLen, x, y, flags, p);
    } else {
        char[] buf = TextUtils.obtain(contextLen);
        getChars(contextStart, contextEnd, buf, 0);
        c.drawTextRun(buf, start - contextStart, len, 0, contextLen, x, y, flags, p);
        TextUtils.recycle(buf);
    }
}
Also used : Paint(android.graphics.Paint)

Example 99 with Paint

use of android.graphics.Paint in project TastyToast by yadav-rahul.

the class ErrorToastView method initPaint.

private void initPaint() {
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setColor(Color.parseColor("#d9534f"));
    mPaint.setStrokeWidth(dip2px(2));
}
Also used : Paint(android.graphics.Paint)

Example 100 with Paint

use of android.graphics.Paint in project TastyToast by yadav-rahul.

the class InfoToastView method initPaint.

private void initPaint() {
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setColor(Color.parseColor("#337ab7"));
    mPaint.setStrokeWidth(dip2px(2));
}
Also used : Paint(android.graphics.Paint)

Aggregations

Paint (android.graphics.Paint)3611 Canvas (android.graphics.Canvas)815 Bitmap (android.graphics.Bitmap)735 RectF (android.graphics.RectF)484 Rect (android.graphics.Rect)400 Path (android.graphics.Path)281 TextPaint (android.text.TextPaint)269 PorterDuffXfermode (android.graphics.PorterDuffXfermode)232 Matrix (android.graphics.Matrix)173 SuppressLint (android.annotation.SuppressLint)148 Point (android.graphics.Point)147 TypedArray (android.content.res.TypedArray)134 BitmapShader (android.graphics.BitmapShader)117 View (android.view.View)103 Drawable (android.graphics.drawable.Drawable)99 BitmapDrawable (android.graphics.drawable.BitmapDrawable)92 ColorMatrix (android.graphics.ColorMatrix)76 ColorMatrixColorFilter (android.graphics.ColorMatrixColorFilter)66 Resources (android.content.res.Resources)65 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)57