Java Code Examples for android.graphics.Paint#setStrikeThruText()

The following examples show how to use android.graphics.Paint#setStrikeThruText() . 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: XulBasicTextRenderer.java    From starcor.xul with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected Paint _getTextPaint(float fontSizeScale) {
	XulRenderContext ctx = _render.getRenderContext();
	Paint defPaint = ctx.getTextPaintByName(_fontFace);

	if (!(_fontShadowSize == 0 || (_fontShadowColor & 0xFF000000) == 0)) {
		defPaint = ctx.getShadowTextPaintByName(_fontFace);
		defPaint.setShadowLayer(_fontShadowSize, _fontShadowX, _fontShadowY, _fontShadowColor);
	}

	defPaint.setColor(_fontColor);
	if (Math.abs(fontSizeScale - 1.0f) > 0.01f) {
		defPaint.setTextSize(_fontSize * fontSizeScale);
	} else {
		defPaint.setTextSize(_fontSize);
	}

	if (_fontWeight > 1.0) {
		if (_fontWeight > 2.5) {
			defPaint.setStrokeWidth(_fontWeight*fontSizeScale/2);
		} else {
			defPaint.setFakeBoldText(true);
		}
	} else {
		defPaint.setFakeBoldText(false);
	}
	defPaint.setTextScaleX(_fontScaleX);
	defPaint.setUnderlineText(_fontUnderline);
	defPaint.setStrikeThruText(_fontStrikeThrough);
	defPaint.setTextSkewX(_fontItalic ? -0.25f : 0);
	defPaint.setTextAlign(Paint.Align.LEFT);
	return defPaint;
}
 
Example 2
Source File: NumberGraphic.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public static Bitmap getBitmap(final String text, int fillColor, final String arrow, final int width, final int height, final int margin, final boolean strike_through, boolean expandable, final boolean shadow) {
    {
        if ((text == null) || (text.length() > 4)) return null;
        try {

            if ((width > 2000) || height > 2000 || height < 16 || width < 16) return null;

            final Paint paint = new Paint();
            paint.setStrikeThruText(strike_through);
            paint.setStyle(Paint.Style.FILL);
            paint.setColor(fillColor);
            paint.setAntiAlias(true);
            //paint.setTypeface(Typeface.MONOSPACE);
            paint.setTypeface(Typeface.SANS_SERIF); // TODO BEST?
            paint.setTextAlign(Paint.Align.LEFT);
            float paintTs = (arrow == null ? 17 : 17 - arrow.length());
            paint.setTextSize(paintTs);
            final Rect bounds = new Rect();

            final String fullText = text + (arrow != null ? arrow : "");

            paint.getTextBounds(fullText, 0, fullText.length(), bounds);
            float textsize = ((paintTs - 1) * (width - margin)) / bounds.width();
            paint.setTextSize(textsize);
            paint.getTextBounds(fullText, 0, fullText.length(), bounds);

            // cannot be Config.ALPHA_8 as it doesn't work on Samsung
            final Bitmap bitmap = Bitmap.createBitmap(width, expandable ? Math.max(height, bounds.height() + 30) : height, Bitmap.Config.ARGB_8888);
            final Canvas c = new Canvas(bitmap);

            if (shadow) {
                paint.setShadowLayer(10, 0, 0, getCol(ColorCache.X.color_number_wall_shadow));
            }
            c.drawText(fullText, 0, (height / 2) + (bounds.height() / 2), paint);

            return bitmap;
        } catch (Exception e) {
            if (JoH.ratelimit("icon-failure", 60)) {
                UserError.Log.e(TAG, "Cannot create number icon: " + e);
            }
            return null;
        }
    }
}
 
Example 3
Source File: NumberGraphic.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public static Bitmap getBitmap(final String text, int fillColor, final String arrow, final int width, final int height, final int margin, final boolean strike_through, boolean expandable, final boolean shadow) {
    {
        if ((text == null) || (text.length() > 4)) return null;
        try {

            if ((width > 2000) || height > 2000 || height < 16 || width < 16) return null;

            final Paint paint = new Paint();
            paint.setStrikeThruText(strike_through);
            paint.setStyle(Paint.Style.FILL);
            paint.setColor(fillColor);
            paint.setAntiAlias(true);
            //paint.setTypeface(Typeface.MONOSPACE);
            paint.setTypeface(Typeface.SANS_SERIF); // TODO BEST?
            paint.setTextAlign(Paint.Align.LEFT);
            float paintTs = (arrow == null ? 17 : 17 - arrow.length());
            paint.setTextSize(paintTs);
            final Rect bounds = new Rect();

            final String fullText = text + (arrow != null ? arrow : "");

            paint.getTextBounds(fullText, 0, fullText.length(), bounds);
            float textsize = ((paintTs - 1) * (width - margin)) / bounds.width();
            paint.setTextSize(textsize);
            paint.getTextBounds(fullText, 0, fullText.length(), bounds);

            // cannot be Config.ALPHA_8 as it doesn't work on Samsung
            final Bitmap bitmap = Bitmap.createBitmap(width, expandable ? Math.max(height, bounds.height() + 30) : height, Bitmap.Config.ARGB_8888);
            final Canvas c = new Canvas(bitmap);

            if (shadow) {
                paint.setShadowLayer(10, 0, 0, getCol(ColorCache.X.color_number_wall_shadow));
            }
            c.drawText(fullText, 0, (height / 2) + (bounds.height() / 2), paint);

            return bitmap;
        } catch (Exception e) {
            if (JoH.ratelimit("icon-failure", 60)) {
                UserError.Log.e(TAG, "Cannot create number icon: " + e);
            }
            return null;
        }
    }
}