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;
}
}
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;
}
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);
}
}
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));
}
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));
}
Aggregations