Example usage for android.graphics Canvas drawCircle

List of usage examples for android.graphics Canvas drawCircle

Introduction

In this page you can find the example usage for android.graphics Canvas drawCircle.

Prototype

public void drawCircle(float cx, float cy, float radius, @NonNull Paint paint) 

Source Link

Document

Draw the specified circle using the specified paint.

Usage

From source file:br.com.leoleal.swipetorefresh.SwipeProgressBar.java

private void drawTrigger(Canvas canvas, int cx, int cy) {
    mPaint.setColor(mColor1);//from  w  w w.  ja  va  2 s .c  o m
    canvas.drawCircle(cx, cy, cx * mTriggerPercentage, mPaint);
}

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

@Override
public void draw(Canvas canvas) {
    super.draw(canvas);

    int width = getMeasuredWidth();
    int height = getMeasuredHeight();

    float radius = Math.min(width, height) / 2f - 4f;

    canvas.drawCircle(width / 2, height / 2, radius, mPaint);
    canvas.drawCircle(width / 2, height / 2, radius, mPaintBorder);

    if (mChecked) {
        mCheck.setBounds(Math.round(width / 2 - radius), 0, Math.round(width / 2 + radius), height);
        mCheck.draw(canvas);/*w ww.  j  a  v a 2  s . c  o  m*/
    }
}

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

public void setStickersSet(TLRPC.StickerSetCovered set, boolean divider, boolean unread) {
    needDivider = divider;//from w  w  w .  j a v  a  2  s.  c om
    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.dgmltn.ranger.internal.PinView.java

@Override
public void draw(Canvas canvas) {
    super.draw(canvas);

    canvas.drawCircle(mPosition.x, mPosition.y, mCircleRadiusPx, mCirclePaint);

    // Draw pin if pressed
    if (mPinRadiusPx > 0) {
        mBounds.set((int) mPosition.x - mPinRadiusPx,
                (int) mPosition.y - (mPinRadiusPx * 2) - (int) mPinPadding, (int) mPosition.x + mPinRadiusPx,
                (int) mPosition.y - (int) mPinPadding);
        mPin.setBounds(mBounds);/*w w  w .  j  a v  a 2s . c om*/
        String text = mLabel;

        calibrateTextSize(mTextPaint, text, mBounds.width());
        mTextPaint.getTextBounds(text, 0, text.length(), mBounds);
        mTextPaint.setTextAlign(Paint.Align.CENTER);
        mPin.setColorFilter(mPinFilter);
        mPin.draw(canvas);
        canvas.drawText(text, mPosition.x, mPosition.y - mPinRadiusPx - mPinPadding + mTextYPadding,
                mTextPaint);
    }
}

From source file:com.xbm.android.matisse.internal.ui.widget.CheckView.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    // draw outer and inner shadow
    initShadowPaint();//from  w  w w  .  java  2  s.c o m
    canvas.drawCircle((float) SIZE * mDensity / 2, (float) SIZE * mDensity / 2,
            (STROKE_RADIUS + STROKE_WIDTH / 2 + SHADOW_WIDTH) * mDensity, mShadowPaint);

    // draw white stroke
    canvas.drawCircle((float) SIZE * mDensity / 2, (float) SIZE * mDensity / 2, STROKE_RADIUS * mDensity,
            mStrokePaint);

    // draw content
    if (mCountable) {
        if (mCheckedNum != UNCHECKED) {
            initBackgroundPaint();
            canvas.drawCircle((float) SIZE * mDensity / 2, (float) SIZE * mDensity / 2, BG_RADIUS * mDensity,
                    mBackgroundPaint);
            initTextPaint();
            String text = String.valueOf(mCheckedNum);
            int baseX = (int) (canvas.getWidth() - mTextPaint.measureText(text)) / 2;
            int baseY = (int) (canvas.getHeight() - mTextPaint.descent() - mTextPaint.ascent()) / 2;
            canvas.drawText(text, baseX, baseY, mTextPaint);
        }
    } else {
        if (mChecked) {
            initBackgroundPaint();
            canvas.drawCircle((float) SIZE * mDensity / 2, (float) SIZE * mDensity / 2, BG_RADIUS * mDensity,
                    mBackgroundPaint);

            mCheckDrawable.setBounds(getCheckRect());
            mCheckDrawable.draw(canvas);
        }
    }

    // enable hint
    setAlpha(mEnabled ? 1.0f : 0.5f);
}

From source file:com.hippo.refreshlayout.SwipeProgressBar.java

private void drawTrigger(Canvas canvas, int cx, int cy) {
    mPaint.setColor(mColors[0]);//from  ww w. jav  a  2 s  .co  m
    canvas.drawCircle(cx, cy, cx * mTriggerPercentage, mPaint);
}

From source file:io.github.hidroh.materialistic.widget.AsteriskSpan.java

@Override
public void draw(@NonNull Canvas canvas, CharSequence text, int start, int end, float x, int top, int y,
        int bottom, @NonNull Paint paint) {
    float radius = mPadding;
    float centerX = x + radius + mPadding;
    float centerY = top + radius + mPadding;
    paint.setColor(mBackgroundColor);/*w w w . j  a  va2s  .co m*/
    canvas.drawCircle(centerX, centerY, radius, paint);
    paint.setColor(mTextColor);
    canvas.drawText(text, start, end, x + mPadding * 2, y, paint);
}

From source file:com.serchinastico.coolswitch.CoolSwitch.java

private void drawSelector(Canvas canvas) {
    paint.setStyle(Paint.Style.FILL_AND_STROKE);
    paint.setColor(Color.WHITE);//from   ww w. jav  a 2 s.  c o m
    paint.setAlpha(OPAQUE);
    canvas.drawCircle(currentSelectorCenter.x, currentSelectorCenter.y, (int) (selectorRadius * SELECTOR_RATIO),
            paint);
}

From source file:org.onebusaway.android.view.RealtimeIndicatorView.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    int height = getHeight();
    int width = getWidth();

    float x = width / 2.0f;
    float y = height / 2.0f;

    canvas.drawCircle(x, y, mNewRadius * SCALE, mFillPaint);
    canvas.drawCircle(x, y, mNewRadius * SCALE, mLinePaint);
}

From source file:com.alex.view.loop.IndicatorView.java

/**
 * // ww w .  ja va  2 s  . c o  m
 *
 * @param color ??
 * @return
 */
private Bitmap makeIndicatorBp(int color) {
    Bitmap normalBp = Bitmap.createBitmap(mRadius * 2, mRadius * 2, Bitmap.Config.ARGB_8888);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setColor(color);
    Canvas canvas = new Canvas(normalBp);
    canvas.drawCircle(mRadius, mRadius, mRadius, paint);
    return normalBp;
}