Example usage for android.graphics Paint ANTI_ALIAS_FLAG

List of usage examples for android.graphics Paint ANTI_ALIAS_FLAG

Introduction

In this page you can find the example usage for android.graphics Paint ANTI_ALIAS_FLAG.

Prototype

int ANTI_ALIAS_FLAG

To view the source code for android.graphics Paint ANTI_ALIAS_FLAG.

Click Source Link

Document

Paint flag that enables antialiasing when drawing.

Usage

From source file:de.hs_bremen.aurora_hunter.ui.views.PredictionGraphView.java

public PredictionGraphView(Context pContext, AttributeSet pAttributeSet) {
    super(pContext, pAttributeSet);

    setFocusable(true);/*from w  w w.j a  v  a 2s .  co  m*/
    setFocusableInTouchMode(true);
    setOnTouchListener(this);

    int color = ContextCompat.getColor(getContext(), R.color.colorAccent);
    mNotificationLevelPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mNotificationLevelPaint.setColor(color);

    mNotificationLevelTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mNotificationLevelTextPaint.setTextAlign(Paint.Align.LEFT);
    mNotificationLevelTextPaint.setTextSize(80);
    mNotificationLevelTextPaint.setColor(color);

    mGraphPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    //mGraphPaint.setStyle(Paint.Style.STROKE);
    mGraphPaint.setStrokeWidth(STROKE_WIDTH);
    mGraphPaint.setColor(Color.BLACK);
    mGraphPaint.setStyle(Paint.Style.FILL);

    mGraphPaint.setDither(true);
    mGraphPaint.setStrokeJoin(Paint.Join.ROUND);
    mGraphPaint.setStrokeCap(Paint.Cap.ROUND);
    mGraphPaint.setAntiAlias(true);
    mGraphPaint.setAlpha(220);

    mTextPaint.setStrokeWidth(10f);
    mTextPaint.setDither(true);
    mTextPaint.setStrokeJoin(Paint.Join.ROUND);
    mTextPaint.setStrokeCap(Paint.Cap.ROUND);
    mTextPaint.setPathEffect(new CornerPathEffect(10));
    mTextPaint.setAntiAlias(true);
    mTextPaint.setColor(Color.WHITE);
    mTextPaint.setTextSize(30);
    mTextPaint.setFakeBoldText(true);
    mTextPaint.setAlpha(220);
}

From source file:net.simno.dmach.ui.view.PanView.java

private void init(Context context) {
    DMachApp.get(context).component().inject(this);

    textSize = getResources().getDimension(R.dimen.text_size_channel);
    rectHeight = getResources().getDimension(R.dimen.rect_height);
    shapeStrokeWidth = getResources().getDimension(R.dimen.shape_stroke_width);
    offset = (shapeStrokeWidth / 2f) + (rectHeight / 2f);

    shapePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    shapePaint.setStrokeWidth(shapeStrokeWidth);
    shapePaint.setStyle(Paint.Style.STROKE);
    shapePaint.setColor(getColor(context, R.color.gamboge));

    textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setColor(getColor(context, R.color.dune));
    textPaint.setTextSize(textSize);//  w  w w  .  ja v a 2 s .  com
    textPaint.setStyle(Paint.Style.FILL);
    textPaint.setTypeface(typeface);
}

From source file:com.grarak.kerneladiutor.views.BorderCircleView.java

public BorderCircleView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    if (isClickable()) {
        setForeground(ViewUtils.getSelectableBackground(context));
    }// w  w w  .  j  av  a2s. com
    mCheck = ContextCompat.getDrawable(context, R.drawable.ic_done);
    DrawableCompat.setTint(mCheck, Color.WHITE);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setColor(ViewUtils.getThemeAccentColor(context));

    mPaintBorder = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintBorder.setColor(ViewUtils.getColorPrimaryColor(context));
    mPaintBorder.setStrokeWidth((int) getResources().getDimension(R.dimen.circleview_border));
    mPaintBorder.setStyle(Paint.Style.STROKE);

    setWillNotDraw(false);
}

From source file:com.google.zxing.client.android.ViewfinderView.java

public ViewfinderView(Context context, AttributeSet attrs) {
    super(context, attrs);

    // Initialize these once for performance rather than calling them every time in onDraw().
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    maskColor = ContextCompat.getColor(context, R.color.viewfinder_mask);
    resultColor = ContextCompat.getColor(context, R.color.barcode_result_view);
    laserColor = ContextCompat.getColor(context, R.color.viewfinder_laser);
    resultPointColor = ContextCompat.getColor(context, R.color.possible_result_points);
    scannerAlpha = 0;// w w w .j a  v  a2  s .  c o  m
    possibleResultPoints = new ArrayList<>(5);
    lastPossibleResultPoints = null;
    //  GradientDrawable?lineDrawable
    mRect = new Rect();
    lineDrawable = getResources().getDrawable(R.drawable.zx_code_line);

}

From source file:im.ene.ribbon.ActionTabView.java

public ActionTabView(final BottomNavigationView parent, final boolean expanded, final MenuParser.Menu menu) {
    super(parent.getContext());
    this.evaluator = new ArgbEvaluator();
    this.rippleColor = menu.getRippleColor();
    this.textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    this.textDirty = true;
    this.expanded = expanded;
    this.provider = parent.getBadgeProvider();
}

From source file:Main.java

public static Bitmap createRoundedFramedImage(Drawable imageDrawable, int borderThickness, int color) {
    int size = Math.min(imageDrawable.getMinimumWidth(), imageDrawable.getMinimumHeight());
    //      Drawable imageDrawable = (image != null) ? new BitmapDrawable(image) : placeHolder;

    Bitmap output = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    RectF outerRect = new RectF(0, 0, size, size);
    float cornerRadius = size / 18f;

    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.RED);//from   ww w  .j  a v  a2 s  .c  om
    canvas.drawRoundRect(outerRect, cornerRadius, cornerRadius, paint);

    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    imageDrawable.setBounds(0, 0, size, size);

    // Save the layer to apply the paint
    canvas.saveLayer(outerRect, paint, Canvas.ALL_SAVE_FLAG);
    imageDrawable.draw(canvas);
    canvas.restore();

    // FRAMING THE PHOTO
    float border = size / 15f;

    // 1. Create offscreen bitmap link: http://www.youtube.com/watch?feature=player_detailpage&v=jF6Ad4GYjRU#t=1035s
    Bitmap framedOutput = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
    Canvas framedCanvas = new Canvas(framedOutput);
    // End of Step 1

    // Start - TODO IMPORTANT - this section shouldn't be included in the final code
    // It's needed here to differentiate step 2 (red) with the background color of the activity
    // It's should be commented out after the codes includes step 3 onwards
    // Paint squaredPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    // squaredPaint.setColor(Color.BLUE);
    // framedCanvas.drawRoundRect(outerRect, 0f, 0f, squaredPaint);
    // End

    // 2. Draw an opaque rounded rectangle link:
    // http://www.youtube.com/watch?feature=player_detailpage&v=jF6Ad4GYjRU#t=1044s
    RectF innerRect = new RectF(border, border, size - border, size - border);

    Paint innerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    innerPaint.setColor(Color.RED);
    framedCanvas.drawRoundRect(innerRect, cornerRadius, cornerRadius, innerPaint);

    // 3. Set the Power Duff mode link:
    // http://www.youtube.com/watch?feature=player_detailpage&v=jF6Ad4GYjRU#t=1056s
    Paint outerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    outerPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT));

    // 4. Draw a translucent rounded rectangle link:
    // http://www.youtube.com/watch?feature=player_detailpage&v=jF6Ad4GYjRU
    outerPaint.setColor(color);
    framedCanvas.drawRoundRect(outerRect, cornerRadius, cornerRadius, outerPaint);

    // 5. Draw the frame on top of original bitmap
    canvas.drawBitmap(framedOutput, 0f, 0f, null);

    return output;
}

From source file:net.nym.napply.library.recycler.RecyclerViewLinearDivider.java

/**
 * /*from  w  ww.  j a v  a2s . co m*/
 *
 * @param context
 * @param orientation   ?
 * @param dividerHeight 
 * @param dividerColor  
 */
public RecyclerViewLinearDivider(Context context, int orientation, int dividerHeight, int dividerColor) {
    this(context, orientation);
    mDividerHeight = dividerHeight;
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setColor(dividerColor);
    mPaint.setStyle(Paint.Style.FILL);
}

From source file:com.example.aqing.materialdesign.deleteitem.DividerItemDecoration.java

private void init() {
    updatePaddint();/*  w  w  w.  j  a  va2 s  .c  o  m*/
    dividerHeight = DEFAULT_DIVIDER_HEIGHT;

    mPaddingPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaddingPaint.setColor(ContextCompat.getColor(mContext, android.R.color.white));
    mPaddingPaint.setStyle(Paint.Style.FILL);

    mDividerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mDividerPaint.setColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
    mDividerPaint.setStyle(Paint.Style.FILL);
}

From source file:org.telegram.ui.Cells.FeaturedStickerSetCell.java

public FeaturedStickerSetCell(Context context) {
    super(context);

    setBackgroundColor(ContextCompat.getColor(context, R.color.card_background));
    setElevation(AndroidUtilities.dp(2));

    if (paint == null) {
        paint = new Paint();
        paint.setColor(ContextCompat.getColor(context, R.color.divider));
    }//from www.j  a  va  2 s.co  m
    if (botProgressPaint == null) {
        botProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        botProgressPaint.setColor(ContextCompat.getColor(context, R.color.primary_text_inverse));
        botProgressPaint.setStrokeCap(Paint.Cap.ROUND);
        botProgressPaint.setStyle(Paint.Style.STROKE);
    }
    botProgressPaint.setStrokeWidth(AndroidUtilities.dp(2));

    textView = new TextView(context);
    textView.setTextColor(ContextCompat.getColor(context, R.color.primary_text));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    addView(textView,
            LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT,
                    LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, LocaleController.isRTL ? 100 : 71,
                    10, LocaleController.isRTL ? 71 : 100, 0));

    valueTextView = new TextView(context);
    //valueTextView.setTextColor(0xff8a8a8a);
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    valueTextView.setLines(1);
    valueTextView.setMaxLines(1);
    valueTextView.setSingleLine(true);
    valueTextView.setEllipsize(TextUtils.TruncateAt.END);
    valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    addView(valueTextView,
            LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT,
                    LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, LocaleController.isRTL ? 100 : 71,
                    35, LocaleController.isRTL ? 71 : 100, 0));

    imageView = new BackupImageView(context);
    imageView.setAspectFit(true);
    addView(imageView,
            LayoutHelper.createFrame(48, 48,
                    (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP,
                    LocaleController.isRTL ? 0 : 12, 8, LocaleController.isRTL ? 12 : 0, 0));

    addButton = new TextView(context) {
        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            if (drawProgress || !drawProgress && progressAlpha != 0) {
                botProgressPaint.setAlpha(Math.min(255, (int) (progressAlpha * 255)));
                int x = getMeasuredWidth() - AndroidUtilities.dp(11);
                progressRect.set(x, AndroidUtilities.dp(3), x + AndroidUtilities.dp(8),
                        AndroidUtilities.dp(8 + 3));
                canvas.drawArc(progressRect, angle, 220, false, botProgressPaint);
                invalidate((int) progressRect.left - AndroidUtilities.dp(2),
                        (int) progressRect.top - AndroidUtilities.dp(2),
                        (int) progressRect.right + AndroidUtilities.dp(2),
                        (int) progressRect.bottom + AndroidUtilities.dp(2));
                long newTime = System.currentTimeMillis();
                if (Math.abs(lastUpdateTime - System.currentTimeMillis()) < 1000) {
                    long delta = (newTime - lastUpdateTime);
                    float dt = 360 * delta / 2000.0f;
                    angle += dt;
                    angle -= 360 * (angle / 360);
                    if (drawProgress) {
                        if (progressAlpha < 1.0f) {
                            progressAlpha += delta / 200.0f;
                            if (progressAlpha > 1.0f) {
                                progressAlpha = 1.0f;
                            }
                        }
                    } else {
                        if (progressAlpha > 0.0f) {
                            progressAlpha -= delta / 200.0f;
                            if (progressAlpha < 0.0f) {
                                progressAlpha = 0.0f;
                            }
                        }
                    }
                }
                lastUpdateTime = newTime;
                invalidate();
            }
        }
    };
    addButton.setPadding(AndroidUtilities.dp(17), 0, AndroidUtilities.dp(17), 0);
    addButton.setGravity(Gravity.CENTER);
    // TODO
    addButton.setTextColor(0xffffffff);
    addButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    addButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    addButton.setBackgroundResource(R.drawable.add_states);
    addButton.setText(LocaleController.getString("Add", R.string.Add).toUpperCase());
    addView(addButton,
            LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 28,
                    Gravity.TOP | (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT),
                    LocaleController.isRTL ? 14 : 0, 18, LocaleController.isRTL ? 0 : 14, 0));

    checkImage = new ImageView(context);
    checkImage.setImageResource(R.drawable.sticker_added);
    addView(checkImage, LayoutHelper.createFrame(19, 14));
}

From source file:net.simno.dmach.ui.view.SettingView.java

private void init(Context context) {
    DMachApp.get(context).component().inject(this);

    backgroundColor = getColor(context, R.color.gamboge);
    textSize = getResources().getDimension(R.dimen.text_size_setting);
    circleRadius = getResources().getDimension(R.dimen.circle_radius);
    shapeStrokeWidth = getResources().getDimension(R.dimen.shape_stroke_width);

    shapePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    shapePaint.setStrokeWidth(shapeStrokeWidth);
    shapePaint.setStyle(Paint.Style.STROKE);
    shapePaint.setColor(getColor(context, R.color.colonial));

    textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setColor(getColor(context, R.color.dune));
    textPaint.setTextSize(textSize);/*from   w ww.  j  av  a 2s  . c  o m*/
    textPaint.setStyle(Paint.Style.FILL);
    textPaint.setTypeface(typeface);
}