List of usage examples for android.graphics Paint ANTI_ALIAS_FLAG
int ANTI_ALIAS_FLAG
To view the source code for android.graphics Paint ANTI_ALIAS_FLAG.
Click Source Link
From source file:me.drozdzynski.library.steppers.RoundedView.java
private void drawChecked(Canvas canvas) { Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_check); if (bitmap != null) { float posX = (canvas.getWidth() - bitmap.getWidth()) / 2; float posY = (canvas.getHeight() - bitmap.getHeight()) / 2; canvas.drawBitmap(bitmap, posX, posY, paint); }//from w w w . java 2s . c o m }
From source file:com.apache.fastandroid.novel.view.readview.PageFactory.java
public PageFactory(Context context, int width, int height, int fontSize, String bookId, List<BookMixAToc.mixToc.Chapters> chaptersList) { mContext = context;/* w w w .ja va 2 s. c om*/ mWidth = width; mHeight = height; mFontSize = fontSize; mLineSpace = mFontSize / 5 * 2; mNumFontSize = DimensUtil.dp2px(context, 16); marginWidth = DimensUtil.dp2px(context, 15); marginHeight = DimensUtil.dp2px(context, 15); mVisibleHeight = mHeight - marginHeight * 2 - mNumFontSize * 2 - mLineSpace * 2; mVisibleWidth = mWidth - marginWidth * 2; mPageLineCount = mVisibleHeight / (mFontSize + mLineSpace); rectF = new Rect(0, 0, mWidth, mHeight); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setTextSize(mFontSize); mPaint.setTextSize(ContextCompat.getColor(context, R.color.chapter_content_day)); mPaint.setColor(Color.BLACK); mTitlePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mTitlePaint.setTextSize(mNumFontSize); mTitlePaint.setColor(ContextCompat.getColor(FrameworkApplication.getContext(), R.color.chapter_title_day)); timeLen = (int) mTitlePaint.measureText("00:00"); percentLen = (int) mTitlePaint.measureText("00.00%"); // Typeface typeface = Typeface.createFromAsset(context.getAssets(),"fonts/FZBYSK.TTF"); // mPaint.setTypeface(typeface); // mNumPaint.setTypeface(typeface); this.bookId = bookId; this.chaptersList = chaptersList; time = dateFormat.format(new Date()); }
From source file:ggikko.me.steppertest.stepper.RoundedView.java
private void drawChecked(Canvas canvas) { Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_check); float posX = (canvas.getWidth() - bitmap.getWidth()) / 2; float posY = (canvas.getHeight() - bitmap.getHeight()) / 2; canvas.drawBitmap(bitmap, posX, posY, paint); }
From source file:org.telegram.ui.Cells.ArchivedStickerSetCell.java
public void setStickersSet(TLRPC.StickerSetCovered set, boolean divider, boolean unread) { needDivider = divider;/* w w w . j a v a 2s .co m*/ stickersSet = set; setWillNotDraw(!needDivider); textView.setText(stickersSet.set.title); if (unread) { Drawable drawable = new Drawable() { Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); @Override public void draw(Canvas canvas) { paint.setColor(0xff44a8ea); canvas.drawCircle(AndroidUtilities.dp(4), AndroidUtilities.dp(5), AndroidUtilities.dp(3), paint); } @Override public void setAlpha(int alpha) { } @Override public void setColorFilter(ColorFilter colorFilter) { } @Override public int getOpacity() { return 0; } @Override public int getIntrinsicWidth() { return AndroidUtilities.dp(12); } @Override public int getIntrinsicHeight() { return AndroidUtilities.dp(8); } }; textView.setCompoundDrawablesWithIntrinsicBounds(LocaleController.isRTL ? null : drawable, null, LocaleController.isRTL ? drawable : null, null); } else { textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); } valueTextView.setText(LocaleController.formatPluralString("Stickers", set.set.count)); if (set.cover != null && set.cover.thumb != null && set.cover.thumb.location != null) { imageView.setImage(set.cover.thumb.location, null, "webp", null); } else if (!set.covers.isEmpty()) { imageView.setImage(set.covers.get(0).thumb.location, null, "webp", null); } }
From source file:com.nextgis.maplibui.util.ControlHelper.java
public static Drawable getIconByVectorType(Context context, int geometryType, int color, int defaultIcon, boolean syncable) { int drawableId; switch (geometryType) { case GTPoint: drawableId = R.drawable.ic_type_point; break;//from w w w . j a v a2s . co m case GTMultiPoint: drawableId = R.drawable.ic_type_multipoint; break; case GTLineString: drawableId = R.drawable.ic_type_line; break; case GTMultiLineString: drawableId = R.drawable.ic_type_multiline; break; case GTPolygon: drawableId = R.drawable.ic_type_polygon; break; case GTMultiPolygon: drawableId = R.drawable.ic_type_multipolygon; break; default: return ContextCompat.getDrawable(context, defaultIcon); } BitmapDrawable icon = (BitmapDrawable) ContextCompat.getDrawable(context, drawableId); if (icon != null) { Bitmap src = icon.getBitmap(); Bitmap bitmap = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig()); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); ColorFilter filter = new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP); paint.setColorFilter(filter); canvas.drawBitmap(src, 0, 0, paint); if (syncable) { int syncIconId = isDarkTheme(context) ? R.drawable.ic_action_refresh_dark : R.drawable.ic_action_refresh_light; ; src = BitmapFactory.decodeResource(context.getResources(), syncIconId); src = Bitmap.createScaledBitmap(src, bitmap.getWidth() / 2, bitmap.getWidth() / 2, true); canvas.drawBitmap(src, bitmap.getWidth() - bitmap.getWidth() / 2, bitmap.getWidth() - bitmap.getWidth() / 2, new Paint()); } icon = new BitmapDrawable(context.getResources(), bitmap); } return icon; }
From source file:com.filemanager.free.ui.views.Indicator.java
public Indicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final int density = (int) context.getResources().getDisplayMetrics().density; // Load attributes final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Indicator, defStyle, 0); dotDiameter = a.getDimensionPixelSize(R.styleable.Indicator_dotDiameter, DEFAULT_DOT_SIZE * density); dotRadius = dotDiameter / 2;/*from w w w . ja va2 s . co m*/ halfDotRadius = dotRadius / 2; gap = a.getDimensionPixelSize(R.styleable.Indicator_dotGap, DEFAULT_GAP * density); animDuration = (long) a.getInteger(R.styleable.Indicator_animationDuration, DEFAULT_ANIM_DURATION); animHalfDuration = animDuration / 2; int unselectedColour = a.getColor(R.styleable.Indicator_pageIndicatorColor, DEFAULT_UNSELECTED_COLOUR); int selectedColour = a.getColor(R.styleable.Indicator_currentPageIndicatorColor, DEFAULT_SELECTED_COLOUR); a.recycle(); unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG); unselectedPaint.setColor(unselectedColour); selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG); selectedPaint.setColor(selectedColour); interpolator = AnimUtils.getFastOutSlowInInterpolator(context); // create paths & rect now reuse & rewind later combinedUnselectedPath = new Path(); unselectedDotPath = new Path(); unselectedDotLeftPath = new Path(); unselectedDotRightPath = new Path(); rectF = new RectF(); addOnAttachStateChangeListener(this); }
From source file:com.visenze.visearch.camerademo.views.RoundImageView.java
@Override protected void onDraw(Canvas canvas) { if (mBounds == null) { return;/*from w ww .ja v a 2 s . co m*/ } int width = mBounds.width(); int height = mBounds.height(); if (width == 0 || height == 0) { return; } canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG)); if (!mCacheValid || width != mCachedWidth || height != mCachedHeight) { // Need to redraw the cache if (width == mCachedWidth && height == mCachedHeight) { // Have a correct-sized bitmap cache already allocated. Just erase it. mCacheBitmap.eraseColor(0); } else { // Allocate a new bitmap with the correct dimensions. mCacheBitmap.recycle(); //noinspection AndroidLintDrawAllocation mCacheBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); mCachedWidth = width; mCachedHeight = height; } Canvas cacheCanvas = new Canvas(mCacheBitmap); cacheCanvas .setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG)); if (mMaskDrawable != null) { int sc = cacheCanvas.save(); mMaskDrawable.draw(cacheCanvas); mMaskedPaint.setColorFilter((mDesaturateOnPress && isPressed()) ? mDesaturateColorFilter : null); cacheCanvas.saveLayer(mBoundsF, mMaskedPaint, Canvas.HAS_ALPHA_LAYER_SAVE_FLAG | Canvas.FULL_COLOR_LAYER_SAVE_FLAG); super.onDraw(cacheCanvas); cacheCanvas.restoreToCount(sc); } else if (mDesaturateOnPress && isPressed()) { int sc = cacheCanvas.save(); cacheCanvas.drawRect(0, 0, mCachedWidth, mCachedHeight, mBlackPaint); mMaskedPaint.setColorFilter(mDesaturateColorFilter); cacheCanvas.saveLayer(mBoundsF, mMaskedPaint, Canvas.HAS_ALPHA_LAYER_SAVE_FLAG | Canvas.FULL_COLOR_LAYER_SAVE_FLAG); super.onDraw(cacheCanvas); cacheCanvas.restoreToCount(sc); } else { super.onDraw(cacheCanvas); } if (mBorderDrawable != null) { mBorderDrawable.draw(cacheCanvas); } } // Draw from cache canvas.drawBitmap(mCacheBitmap, mBounds.left, mBounds.top, null); }
From source file:com.aniruddhc.acemusic.player.Dialogs.AddToPlaylistDialog.java
public void showNewPlaylistDialog() { View dialogView = getActivity().getLayoutInflater().inflate(R.layout.add_new_playlist_dialog_layout, null); final EditText newPlaylistEditText = (EditText) dialogView.findViewById(R.id.new_playlist_name_text_field); newPlaylistEditText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light")); newPlaylistEditText.setPaintFlags(/*ww w. ja v a 2 s .c o m*/ newPlaylistEditText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.new_playlist); builder.setView(dialogView); builder.setPositiveButton(R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Retrieve the name of the new playlist. String playlistName = newPlaylistEditText.getText().toString(); AsyncCreateNewPlaylistTask task = new AsyncCreateNewPlaylistTask(mContext, playlistName, ARTIST, ALBUM, SONG, GENRE, ALBUM_ARTIST, ADD_TYPE); task.execute(); dialog.dismiss(); } }); builder.setNegativeButton(R.string.cancel, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); }
From source file:ru.phplego.core.etc.viewpagerindicator.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color", "default_circle_indicator_page_color")); final int defaultFillColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color", "default_circle_indicator_fill_color")); final int defaultOrientation = res.getInteger(Res.getId(Application.getContext().getPackageName(), "integer", "default_circle_indicator_orientation")); final int defaultStrokeColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color", "default_circle_indicator_stroke_color")); final float defaultStrokeWidth = res.getDimension(Res.getId(Application.getContext().getPackageName(), "dimen", "default_circle_indicator_stroke_width")); final float defaultRadius = res.getDimension( Res.getId(Application.getContext().getPackageName(), "dimen", "default_circle_indicator_radius")); final boolean defaultCentered = res.getBoolean( Res.getId(Application.getContext().getPackageName(), "bool", "default_circle_indicator_centered")); final boolean defaultSnap = res.getBoolean( Res.getId(Application.getContext().getPackageName(), "bool", "default_circle_indicator_snap")); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, Res.getIds(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator"), defStyle, Res.getId(Application.getContext().getPackageName(), "style", "Widget_CirclePageIndicator")); mCentered = a.getBoolean(/* w w w .j ava 2 s. c o m*/ Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_centered"), defaultCentered); mOrientation = a.getInt(Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_orientation"), defaultOrientation); mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor( Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_pageColor"), defaultPageColor)); mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_strokeColor"), defaultStrokeColor)); mPaintStroke.setStrokeWidth(a.getDimension(Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_strokeWidth"), defaultStrokeWidth)); mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor(a.getColor( Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_fillColor"), defaultFillColor)); mRadius = a.getDimension( Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_radius"), defaultRadius); mSnap = a.getBoolean( Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_snap"), defaultSnap); a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.dirkgassen.wator.ui.view.RollingGraphView.java
/** * Read out the attributes from the given attribute set and initialize whatever they represent. * * @param attributeArray typed array containing the attribute values from the XML file *///from www . j a v a2s .co m private void setupAttributes(TypedArray attributeArray) { String series1Name = attributeArray.getString(R.styleable.RollingGraphView_series1name); if (series1Name == null) { seriesNames = null; } else { String series2Name = attributeArray.getString(R.styleable.RollingGraphView_series2name); if (series2Name == null) { seriesNames = new String[] { series1Name }; } else { String series3Name = attributeArray.getString(R.styleable.RollingGraphView_series3name); if (series3Name == null) { seriesNames = new String[] { series1Name, series2Name }; } else { String series4Name = attributeArray.getString(R.styleable.RollingGraphView_series4name); if (series4Name == null) { seriesNames = new String[] { series1Name, series2Name, series3Name }; } else { seriesNames = new String[] { series1Name, series2Name, series3Name, series4Name }; } } } maxValues = attributeArray.getInt(R.styleable.RollingGraphView_maxValues, -1); seriesPaints = new Paint[seriesNames.length]; seriesPaints[0] = new Paint(Paint.ANTI_ALIAS_FLAG); seriesPaints[0] .setColor(attributeArray.getColor(R.styleable.RollingGraphView_series1color, 0xFFFF0000)); seriesPaints[0].setStrokeWidth(attributeArray .getDimension(R.styleable.RollingGraphView_series1thickness, 1 /* dp */ * displayDensity)); seriesPaints[0].setTextSize( attributeArray.getDimension(R.styleable.RollingGraphView_label1textSize, 14 * displayDensity)); if (seriesPaints.length > 1) { seriesPaints[1] = new Paint(Paint.ANTI_ALIAS_FLAG); seriesPaints[1] .setColor(attributeArray.getColor(R.styleable.RollingGraphView_series2color, 0xFFFF0000)); seriesPaints[1].setStrokeWidth(attributeArray .getDimension(R.styleable.RollingGraphView_series2thickness, 1 /* dp */ * displayDensity)); seriesPaints[1].setTextSize(attributeArray.getDimension(R.styleable.RollingGraphView_label2textSize, 14 * displayDensity)); if (seriesPaints.length > 2) { seriesPaints[2] = new Paint(Paint.ANTI_ALIAS_FLAG); seriesPaints[2].setColor( attributeArray.getColor(R.styleable.RollingGraphView_series3color, 0xFFFF0000)); seriesPaints[2].setStrokeWidth(attributeArray.getDimension( R.styleable.RollingGraphView_series3thickness, 1 /* dp */ * displayDensity)); seriesPaints[2].setTextSize(attributeArray .getDimension(R.styleable.RollingGraphView_label3textSize, 14 * displayDensity)); if (seriesPaints.length > 3) { seriesPaints[3] = new Paint(Paint.ANTI_ALIAS_FLAG); seriesPaints[3].setColor( attributeArray.getColor(R.styleable.RollingGraphView_series4color, 0xFFFF0000)); seriesPaints[3].setStrokeWidth(attributeArray.getDimension( R.styleable.RollingGraphView_series4thickness, 1 /* dp */ * displayDensity)); seriesPaints[3].setTextSize(attributeArray .getDimension(R.styleable.RollingGraphView_label4textSize, 14 * displayDensity)); } } } background = getBackground(); if (background == null) { background = new ColorDrawable(ContextCompat.getColor(getContext(), android.R.color.white)); } } horizontal = attributeArray.getInt(R.styleable.RollingGraphView_android_orientation, 0) == 0; }