Java Code Examples for android.graphics.Paint.ANTI_ALIAS_FLAG

The following are Jave code examples for showing how to use ANTI_ALIAS_FLAG of the android.graphics.Paint class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: androidShader_rippleView_radarView   File: RadarView.java   View Source Code Vote up 6 votes
public RadarView(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    init(context,attrs);


    mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBgPaint.setColor(mRadarBackGroundColor);
    mBgPaint.setStyle(Paint.Style.FILL);

    mRadarPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mRadarPaint.setColor(mRadarCircleColor);
    mRadarPaint.setStyle(Paint.Style.STROKE);
    mRadarPaint.setStrokeWidth(2);

    mRadarGradient = new SweepGradient(0,0,mRadarStartColor,mRadarEndColor);

    mMatrix = new Matrix();
}
 
Example 2
Project: XERUNG   File: MaterialSpinner.java   View Source Code Vote up 6 votes
private void initPaintObjects() {

        int labelTextSize = getResources().getDimensionPixelSize(R.dimen.label_text_size);

        paint = new Paint(Paint.ANTI_ALIAS_FLAG);

        textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        textPaint.setTextSize(labelTextSize);
        if (typeface != null) {
            textPaint.setTypeface(typeface);
        }
        textPaint.setColor(baseColor);
        baseAlpha = textPaint.getAlpha();

        selectorPath = new Path();
        selectorPath.setFillType(Path.FillType.EVEN_ODD);

        selectorPoints = new Point[3];
        for (int i = 0; i < 3; i++) {
            selectorPoints[i] = new Point();
        }
    }
 
Example 3
Project: BBSSDK-for-Android   File: ImageUtils.java   View Source Code Vote up 6 votes
/**
 * 添加图片水印
 *
 * @param src       源图片
 * @param watermark 图片水印
 * @param x         起始坐标x
 * @param y         起始坐标y
 * @param alpha     透明度
 * @param recycle   是否回收
 * @return 带有图片水印的图片
 */
public static Bitmap addImageWatermark(final Bitmap src, final Bitmap watermark, final int x
		, final int y, final int alpha, final boolean recycle) {
	if (isEmptyBitmap(src)) {
		return null;
	}
	Bitmap ret = src.copy(src.getConfig(), true);
	if (!isEmptyBitmap(watermark)) {
		Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
		Canvas canvas = new Canvas(ret);
		paint.setAlpha(alpha);
		canvas.drawBitmap(watermark, x, y, paint);
	}
	if (recycle && !src.isRecycled()) {
		src.recycle();
	}
	return ret;
}
 
Example 4
Project: BookLoadingView   File: TickView.java   View Source Code Vote up 6 votes
private void init(Context context, AttributeSet attrs) {

        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.TickView);
        mStrokeWidth = typedArray.getDimensionPixelSize(R.styleable.TickView_tv_strokeWidth, 0);
        int color = typedArray.getColor(R.styleable.TickView_tv_color, Color.RED);
        mPercent = typedArray.getFloat(R.styleable.TickView_tv_percent, 0f);
        typedArray.recycle();

        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setColor(color);

        mTickPath = new Path();
        mArcRect = new RectF();
        mTickPoints = new Point[3];
        mTickPoints[0] = new Point();
        mTickPoints[1] = new Point();
        mTickPoints[2] = new Point();
    }
 
Example 5
Project: ScrollableChart   File: LineDrawing.java   View Source Code Vote up 6 votes
private void init() {
  mLinePath = new Path();
  mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
  mLinePaint.setColor(0xFFF90382);
  mLinePaint.setStyle(Paint.Style.STROKE);
  mLinePaint.setStrokeWidth(10.0f);

  mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
  mTextPaint.setColor(Color.WHITE);
  mTextPaint.setTextSize(Util.sp2px(mContext, 13.0f));

  mBubblePaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
  mBubblePaint.setColor(0xFF3B4DEC);

  mBubblePath = new Path();
  mBubbleRect = new RectF();
}
 
Example 6
Project: memetastic   File: ContextUtils.java   View Source Code Vote up 6 votes
public Bitmap drawTextToDrawable(@DrawableRes int resId, String text, int textSize) {
    Resources resources = _context.getResources();
    float scale = resources.getDisplayMetrics().density;
    Bitmap bitmap = getBitmapFromDrawable(resId);

    bitmap = bitmap.copy(bitmap.getConfig(), true);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.rgb(61, 61, 61));
    paint.setTextSize((int) (textSize * scale));
    paint.setShadowLayer(1f, 0f, 1f, Color.WHITE);

    Rect bounds = new Rect();
    paint.getTextBounds(text, 0, text.length(), bounds);
    int x = (bitmap.getWidth() - bounds.width()) / 2;
    int y = (bitmap.getHeight() + bounds.height()) / 2;
    canvas.drawText(text, x, y, paint);

    return bitmap;
}
 
Example 7
Project: BezierView   File: StarViewGroup.java   View Source Code Vote up 5 votes
/**
 * 进行一些初始化的操作
 */
private void initView() {
    //初始化画笔,路径
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStrokeWidth(8);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setColor(Color.BLACK);
    mPath = new Path();
    mRandom = new Random();
    //获取资源图片转化Bitmap(不可修改)
    mBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.icon_star);

    setOnClickListener(this);
}
 
Example 8
Project: Unofficial-Ups   File: RoundCircleView.java   View Source Code Vote up 5 votes
private void init(Context context, boolean isSelected ,@ColorInt int color){
    //Set circle size
    currentSize = context.getResources().getDimensionPixelSize(R.dimen.schedule_item_size);
    //Set circle color
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    if(!isInEditMode()) {
        mPaint.setColor(isSelected ? color : ContextCompat.getColor(context, R.color.week_picker_inactive));
    }
}
 
Example 9
Project: GitHub   File: DanmakuView.java   View Source Code Vote up 5 votes
private void calculation() {
    if (mShowDebug) {
        fpsPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        fpsPaint.setColor(Color.YELLOW);
        fpsPaint.setTextSize(20);
        times = new LinkedList<>();
        lines = new LinkedList<>();
    }
    initChannelMap();
    initChannelY();
}
 
Example 10
Project: Channelize   File: HoloCircularProgressBar.java   View Source Code Vote up 5 votes
/**
 * updates the paint of the progress and the thumb to give them a new visual style
 */
private void updateProgressColor() {
    mProgressColorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mProgressColorPaint.setColor(mProgressColor);
    mProgressColorPaint.setStyle(Paint.Style.STROKE);
    mProgressColorPaint.setStrokeWidth(mCircleStrokeWidth);

    mThumbColorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mThumbColorPaint.setColor(mProgressColor);
    mThumbColorPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    mThumbColorPaint.setStrokeWidth(mCircleStrokeWidth);

    invalidate();
}
 
Example 11
Project: Selector-Switch-UI-Component   File: SelectorUtil.java   View Source Code Vote up 5 votes
/**
 * Returns a paint instance created as per the required specs.
 *
 * @param color         <tt>int</tt> : Color of the paint.
 * @param style         <tt>Paint.Style></tt> : Style of the paint. Eg - Fill, Stroke, etc.
 * @param shadowEnabled <tt>boolean</tt> : Enables shadow for the objects using this paint if
 *                      true.
 * @param shadowColor   <tt>int</tt> : Color of the shadow if the shadow is enabled.
 * @param shadowLength  <tt>int</tt> : Length of the shadow in pixels.
 * @return paint        Paint instance created.
 * @see <a href="https://developer.android.com/reference/android/graphics/Paint.Style.html">Paint.Style</a>
 */
static Paint createPaintFromColor(int color, Paint.Style style, boolean shadowEnabled,
                                  int shadowColor, int shadowLength) {

    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(color);
    paint.setStyle(style);
    paint.setAntiAlias(true);
    if (shadowEnabled) {
        paint.setShadowLayer(shadowLength, 0, 0, shadowColor);
    }
    return paint;
}
 
Example 12
Project: FlickLauncher   File: PageIndicatorDots.java   View Source Code Vote up 5 votes
public PageIndicatorDots(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCirclePaint.setStyle(Style.FILL);
    mDotRadius = getResources().getDimension(R.dimen.page_indicator_dot_size) / 2;
    setOutlineProvider(new MyOutlineProver());

    mActiveColor = Utilities.getColorAccent(context);
    mInActiveColor = getResources().getColor(R.color.page_indicator_dot_color);

    mIsRtl = Utilities.isRtl(getResources());
}
 
Example 13
Project: GeekZone   File: WaveBezier.java   View Source Code Vote up 5 votes
public WaveBezier(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mDarkerPath = new Path();
    mLightPath = new Path();
    mDarkerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mDarkerPaint.setColor(Color.parseColor("#77512DA8"));
    mDarkerPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    mLightPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mLightPaint.setColor(Color.parseColor("#55512DA8"));
    mLightPaint.setStyle(Paint.Style.FILL_AND_STROKE);
}
 
Example 14
Project: AndroidDigIn   File: SweepGradientRadarView.java   View Source Code Vote up 5 votes
private Bitmap createSpotBitmap(String data) {
    Bitmap bitmap = Bitmap.createBitmap(
            (int) mSpotRadius * 2,
            (int) mSpotRadius * 2, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawColor(Color.rgb(235, 160, 160));
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStrokeWidth(5);
    paint.setTextSize(80);
    paint.setColor(Color.BLACK);
    canvas.drawText(data, 0, 80, paint);
    return bitmap;
}
 
Example 15
Project: GitHub   File: HoloCircularProgressBar.java   View Source Code Vote up 5 votes
/**
 * updates the paint of the progress and the thumb to give them a new visual style
 */
private void updateProgressColor() {
    mProgressColorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mProgressColorPaint.setColor(mProgressColor);
    mProgressColorPaint.setStyle(Paint.Style.STROKE);
    mProgressColorPaint.setStrokeWidth(mCircleStrokeWidth);

    mThumbColorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mThumbColorPaint.setColor(mProgressColor);
    mThumbColorPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    mThumbColorPaint.setStrokeWidth(mCircleStrokeWidth);

    invalidate();
}
 
Example 16
Project: IOS11RectProgress   File: RectProgress.java   View Source Code Vote up 5 votes
private void init(Context context, AttributeSet attrs) {
    //关闭硬件加速,不然setXfermode()可能会不生效
    setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    if (attrs != null) {
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RectProgress);
        bgColor = typedArray.getColor(R.styleable.RectProgress_bgColor, defaultBgColor);
        progressColor = typedArray.getColor(R.styleable.RectProgress_progressColor, defaultProgressColor);
        progress = typedArray.getInteger(R.styleable.RectProgress_progressValue, progress);
        max = typedArray.getInteger(R.styleable.RectProgress_progressMax, max);
        if (max <= 0)
            throw new RuntimeException("Max 必须大于 0");
        orientation = typedArray.getInteger(R.styleable.RectProgress_progressOrientation, VERTICAL);
        int imgSrc = typedArray.getResourceId(R.styleable.RectProgress_iconSrc, 0);
        iconPadding = typedArray.getDimensionPixelSize(R.styleable.RectProgress_iconPadding, 10);
        rectRadius = typedArray.getDimensionPixelSize(R.styleable.RectProgress_rectRadius, 20);
        if (max < progress) {
            progress = max;
        }
        typedArray.recycle();

        if (imgSrc != 0) {
            bitmap = ((BitmapDrawable) getResources().getDrawable(imgSrc)).getBitmap();
        }
    }

    bgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    bgPaint.setColor(bgColor);

    progressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    progressPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
    progressPaint.setColor(progressColor);


}
 
Example 17
Project: limitjson   File: LinearGraphView.java   View Source Code Vote up 5 votes
private void drawText(String text, int x, int y, Canvas canvas) {
    Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
    p.setTextSize(dip2px(12));
    p.setColor(res.getColor(R.color.color_999999));
    p.setTextAlign(Paint.Align.LEFT);
    canvas.drawText(text, x, y, p);
}
 
Example 18
Project: GitHub   File: TriangularPagerIndicator.java   View Source Code Vote up 5 votes
private void init(Context context) {
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.FILL);
    mLineHeight = UIUtil.dip2px(context, 3);
    mTriangleWidth = UIUtil.dip2px(context, 14);
    mTriangleHeight = UIUtil.dip2px(context, 8);
}
 
Example 19
Project: SuperNote   File: LockView.java   View Source Code Vote up 4 votes
private void init() {

        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mErrorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        // 按下状态的画笔
        mPressPaint.setColor(mPressColor);
        mPressPaint.setAlpha(66);
        mPressPaint.setStrokeWidth(mPointRadius*2);
        // 错误状态的画笔
        mErrorPaint.setColor(mErrorColor);
        mErrorPaint.setAlpha(66);
        mErrorPaint.setStrokeWidth(mPointRadius*2);

        // 当前视图的大小
        int width = getMeasuredWidth();
        int height = getMeasuredHeight();
        // 九宫格点的偏移量
        int offSet = Math.abs(width - height) / 2;
        // x、y轴上的偏移量
        int offSetX = 0, offSetY = 0;
        int pointItemWidth = 0; // 每个点所占用方格的宽度
        if (width >= height){ // 横屏的时候
            offSetX = offSet;
            offSetY = 0;
            pointItemWidth = height / 4;
        }
        if (width <= height){ // 竖屏的时候
            offSetX = 0;
            offSetY = offSet;
            pointItemWidth = width / 4;
        }

        // 初始化九个点
        mPoints[0][0] = new Point(offSetX + pointItemWidth, offSetY + pointItemWidth);
        mPoints[0][1] = new Point(offSetX + pointItemWidth * 2, offSetY + pointItemWidth);
        mPoints[0][2] = new Point(offSetX + pointItemWidth * 3, offSetY + pointItemWidth);

        mPoints[1][0] = new Point(offSetX + pointItemWidth, offSetY + pointItemWidth * 2);
        mPoints[1][1] = new Point(offSetX + pointItemWidth * 2, offSetY + pointItemWidth * 2);
        mPoints[1][2] = new Point(offSetX + pointItemWidth * 3, offSetY + pointItemWidth * 2);

        mPoints[2][0] = new Point(offSetX + pointItemWidth, offSetY + pointItemWidth * 3);
        mPoints[2][1] = new Point(offSetX + pointItemWidth * 2, offSetY + pointItemWidth * 3);
        mPoints[2][2] = new Point(offSetX + pointItemWidth * 3, offSetY + pointItemWidth * 3);
    }
 
Example 20
Project: Espresso   File: FastScrollPopup.java   View Source Code Vote up 3 votes
public FastScrollPopup(Resources resources, FastScrollRecyclerView recyclerView) {

        mRes = resources;

        mRecyclerView = recyclerView;

        mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

        mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mTextPaint.setAlpha(0);

        setTextSize(DensityUtil.dip2sp(recyclerView.getContext(),56));
        setBackgroundSize(DensityUtil.dip2px(recyclerView.getContext(),88));
    }