Example usage for android.graphics Canvas drawOval

List of usage examples for android.graphics Canvas drawOval

Introduction

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

Prototype

public void drawOval(@NonNull RectF oval, @NonNull Paint paint) 

Source Link

Document

Draw the specified oval using the specified paint.

Usage

From source file:com.nextgis.maplibui.overlay.EditLayerOverlay.java

protected Bitmap getMarker() {
    float scaledDensity = mContext.getResources().getDisplayMetrics().scaledDensity;
    int size = (int) (12 * scaledDensity);
    Bitmap marker = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(marker);
    Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
    //noinspection deprecation
    p.setColor(mContext.getResources().getColor(R.color.accent));
    p.setAlpha(128);//w  ww  .j  a v a 2s . c o m
    c.drawOval(new RectF(0, 0, size * 3 / 4, size * 3 / 4), p);
    return marker;
}

From source file:com.android.screenspeak.contextmenu.RadialMenuView.java

private void drawCenterDot(Canvas canvas, int width, int height) {
    final float centerX = (width / 2.0f);
    final float centerY = (height / 2.0f);
    final float radius = mInnerRadius;
    final RectF dotBounds = new RectF((centerX - radius), (centerY - radius), (centerX + radius),
            (centerY + radius));/*from ww  w .jav  a2s.c  o m*/

    mPaint.setStyle(Style.FILL);
    mPaint.setColor(mDotFillColor);
    mPaint.setShadowLayer(mTextShadowRadius, 0, 0, mTextShadowColor);
    canvas.drawOval(dotBounds, mPaint);
    mPaint.setShadowLayer(0, 0, 0, 0);

    contractBounds(dotBounds, (DOT_STROKE_WIDTH / 2));
    mPaint.setStrokeWidth(DOT_STROKE_WIDTH);
    mPaint.setStyle(Style.STROKE);
    mPaint.setColor(mDotStrokeColor);
    mPaint.setPathEffect(mDotPathEffect);
    canvas.drawOval(dotBounds, mPaint);
    mPaint.setPathEffect(null);
}

From source file:com.googlecode.eyesfree.widget.RadialMenuView.java

private void drawCenterDot(Canvas canvas, int width, int height) {
    final Context context = getContext();
    final float centerX = (width / 2.0f);
    final float centerY = (height / 2.0f);
    final float radius = mInnerRadius;
    final RectF dotBounds = new RectF((centerX - radius), (centerY - radius), (centerX + radius),
            (centerY + radius));//from   w w  w  . j  a v  a  2 s .  c o m

    mPaint.setStyle(Style.FILL);
    mPaint.setColor(mDotFillColor);
    mPaint.setShadowLayer(mTextShadowRadius, 0, 0, mTextShadowColor);
    canvas.drawOval(dotBounds, mPaint);
    mPaint.setShadowLayer(0, 0, 0, 0);

    if (mDotStrokeWidth >= 0) {
        contractBounds(dotBounds, (mDotStrokeWidth / 2));

        mPaint.setStrokeWidth(mDotStrokeWidth);
        mPaint.setStyle(Style.STROKE);
        mPaint.setColor(mDotStrokeColor);
        mPaint.setPathEffect(mDotPathEffect);
        canvas.drawOval(dotBounds, mPaint);
        mPaint.setPathEffect(null);
    }
}

From source file:com.android.screenspeak.contextmenu.RadialMenuView.java

private void drawCancel(Canvas canvas) {
    final float centerX = mCenter.x;
    final float centerY = mCenter.y;
    final float radius = mInnerRadius;
    final float iconRadius = (radius / 4.0f);

    final RectF dotBounds = new RectF((centerX - radius), (centerY - radius), (centerX + radius),
            (centerY + radius));/*from w  ww.j av  a 2  s  .c  o m*/

    // Apply the appropriate color filters.
    final boolean selected = (mFocusedItem == null);

    mPaint.setStyle(Style.FILL);
    mPaint.setColor(selected ? mSelectionColor : mCenterFillColor);
    mPaint.setShadowLayer(mShadowRadius, 0, 0, (selected ? mSelectionShadowColor : mTextShadowColor));
    canvas.drawOval(dotBounds, mPaint);
    mPaint.setShadowLayer(0, 0, 0, 0);

    mPaint.setStyle(Style.STROKE);
    mPaint.setColor(selected ? mSelectionTextFillColor : mCenterTextFillColor);
    mPaint.setStrokeCap(Cap.SQUARE);
    mPaint.setStrokeWidth(10.0f);
    canvas.drawLine((centerX - iconRadius), (centerY - iconRadius), (centerX + iconRadius),
            (centerY + iconRadius), mPaint);
    canvas.drawLine((centerX + iconRadius), (centerY - iconRadius), (centerX - iconRadius),
            (centerY + iconRadius), mPaint);
}

From source file:com.googlecode.eyesfree.widget.RadialMenuView.java

private void drawCancel(Canvas canvas, int width, int height, float center) {
    final float centerX = mCenter.x;
    final float centerY = mCenter.y;
    final float radius = mInnerRadius;
    final float iconRadius = (radius / 4.0f);

    final RectF dotBounds = new RectF((centerX - radius), (centerY - radius), (centerX + radius),
            (centerY + radius));//from   w w  w . j a  v  a2  s  .  co m

    // Apply the appropriate color filters.
    final boolean selected = (mFocusedItem == null);

    mPaint.setStyle(Style.FILL);
    mPaint.setColor(selected ? mSelectionColor : mCenterFillColor);
    mPaint.setShadowLayer(mShadowRadius, 0, 0, (selected ? mSelectionShadowColor : mTextShadowColor));
    canvas.drawOval(dotBounds, mPaint);
    mPaint.setShadowLayer(0, 0, 0, 0);

    mPaint.setStyle(Style.STROKE);
    mPaint.setColor(selected ? mSelectionTextFillColor : mCenterTextFillColor);
    mPaint.setStrokeCap(Cap.SQUARE);
    mPaint.setStrokeWidth(10.0f);
    canvas.drawLine((centerX - iconRadius), (centerY - iconRadius), (centerX + iconRadius),
            (centerY + iconRadius), mPaint);
    canvas.drawLine((centerX + iconRadius), (centerY - iconRadius), (centerX - iconRadius),
            (centerY + iconRadius), mPaint);
}

From source file:me.tb.player.SkeletonActivity.java

@Override
public Bitmap getCircleBitmap(Bitmap bitmap) {
    final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(output);

    final int color = Color.RED;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);

    paint.setAntiAlias(true);//  w ww .  j  a v  a 2s  . co m
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawOval(rectF, paint);

    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);

    bitmap.recycle();

    return output;
}

From source file:in.sc9.discreteslider.DiscreteSlider.java

@Override
protected synchronized void onDraw(Canvas canvas) {

    int thumbWidth = mThumb.getIntrinsicWidth();
    int thumbHeight = mThumb.getIntrinsicHeight();
    int addedThumb = mAddedTouchBounds;
    int halfThumb = thumbWidth / 2;
    int paddingLeft = getPaddingLeft() + addedThumb;
    int paddingRight = getPaddingRight();
    int bottom = getHeight() - getPaddingBottom() - addedThumb;
    int trackHeight = Math.max(mTrackHeight / 2, 1);
    int paddingTop = getPaddingTop();
    float margin = (canvas.getWidth() - (paddingLeft + getPaddingRight())) / 4;
    float halfHeight = (halfThumb + (trackHeight * .5f) + mAddedTouchBounds + paddingTop);
    float h = paddingTop + mAddedTouchBounds + halfThumb;
    int scrubberHeight = Math.max(mScrubberHeight / 2, 2);

    if (!isLollipopOrGreater) {
        mRipple.draw(canvas);//from  w ww.  jav a2 s . c o  m
    }

    mTrack.draw(canvas);
    mScrubber.draw(canvas);

    //float interval = (((getWidth() - halfThumb - paddingRight) - (paddingLeft + halfThumb)) / (mMax - mMin));
    //float interval = ((getWidth() - halfThumb - paddingRight - addedThumb - paddingLeft - halfThumb) / (mMax - mMin));
    //float interval = ((getMeasuredWidth()-halfThumb-paddingLeft-paddingRight-addedThumb) / (mMax - mMin));
    float interval = (((float) mTrack.getBounds().right - (float) mTrack.getBounds().left)
            / (float) (mMax - mMin));
    for (int i = mMin; i <= mMax; i++) {
        /* position.set(paddingLeft+(i*margin)-halfSize,halfHeight-halfSize,
        paddingLeft+(i*margin)+halfSize, halfHeight+halfSize);  */

        position.set(mTrack.getBounds().left + ((i - mMin) * interval) - halfSize, h - halfSize,
                mTrack.getBounds().left + ((i - mMin) * interval) + halfSize, h + halfSize);

        if (mDiscretePointsShowAlways) {
            canvas.drawOval(position, mDiscretePoints);
        } else if (mDiscretePointsShowOnTouch && mDiscretePointsEnabled) {
            canvas.drawOval(position, mDiscretePoints);
        } else {
            canvas.drawOval(position, mDiscretePointsTran);
        }
    }

    mThumb.draw(canvas);
    super.onDraw(canvas);
    if (textStyle == NONE) {

    } else {
        drawTextArray(canvas, thumbWidth, halfThumb, mThumb.getBounds().bottom + mTextPaddingTop + mTextSize,
                mTrack.getBounds().left, interval);
    }
}