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:android.example.com.visualizerpreferences.AudioVisuals.VisualizerView.java

public VisualizerView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mBytes = null;//  w  w  w .j  av a 2 s .  c om
    TrailedShape.setMinSize(MIN_SIZE_DEFAULT);

    // Create each of the shapes and define how they are drawn on screen
    // Make bass circle
    mBassCircle = new TrailedShape(BASS_MULTIPLIER) {
        @Override
        protected void drawThisShape(float shapeCenterX, float shapeCenterY, float currentSize, Canvas canvas,
                Paint paint) {
            canvas.drawCircle(shapeCenterX, shapeCenterY, currentSize, paint);
        }
    };

    // Make midrange square
    mMidSquare = new TrailedShape(MID_MULTIPLIER) {
        @Override
        protected void drawThisShape(float shapeCenterX, float shapeCenterY, float currentSize, Canvas canvas,
                Paint paint) {
            canvas.drawRect(shapeCenterX - currentSize, shapeCenterY - currentSize, shapeCenterX + currentSize,
                    shapeCenterY + currentSize, paint);
        }
    };

    // Make treble triangle
    mTrebleTriangle = new TrailedShape(TREBLE_MULTIPLIER) {
        @Override
        protected void drawThisShape(float shapeCenterX, float shapeCenterY, float currentSize, Canvas canvas,
                Paint paint) {
            Path trianglePath = new Path();
            trianglePath.moveTo(shapeCenterX, shapeCenterY - currentSize);
            trianglePath.lineTo(shapeCenterX + currentSize, shapeCenterY + currentSize / 2);
            trianglePath.lineTo(shapeCenterX - currentSize, shapeCenterY + currentSize / 2);
            trianglePath.lineTo(shapeCenterX, shapeCenterY - currentSize);
            canvas.drawPath(trianglePath, paint);
        }
    };
}

From source file:com.dlazaro66.wheelindicatorview.WheelIndicatorView.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.translate(traslationX, traslationY);
    if (circleBackgroundPaint != null)
        canvas.drawCircle(wheelBoundsRectF.centerX(), wheelBoundsRectF.centerY(),
                wheelBoundsRectF.width() / 2 - itemsLineWidth, circleBackgroundPaint);
    canvas.drawArc(wheelBoundsRectF, ANGLE_INIT_OFFSET, 360, false, innerBackgroundCirclePaint);
    drawIndicatorItems(canvas);/*w  ww  . ja va  2 s. c o  m*/
}

From source file:com.android.gallery3d.v5.filtershow.category.CategoryView.java

private void drawSpacer(Canvas canvas) {
    mPaint.reset();//  w w  w .  j a  v  a 2  s.c om
    mPaint.setAntiAlias(true);
    mPaint.setColor(mSpacerColor);
    if (getOrientation() == CategoryView.VERTICAL) {
        canvas.drawCircle(getWidth() / 2, getHeight() / 2, getHeight() / 5, mPaint);
    } else {
        canvas.drawCircle(getWidth() / 2, getHeight() / 2, getWidth() / 5, mPaint);
    }
}

From source file:krt.com.cityguide.Fragments.PageMapFragment.java

public void addObjectMarker(ObjectModel objectModel) {
    //     googleMap.addCircle(new CircleOptions().center(new LatLng(objectModel.getLat(), objectModel.getLon()))
    //     .fillColor(0x000000).radius(1));
    //      if (objectModel == null || googleMap == null) return;
    try {// w w w.ja  v  a2 s .  c o  m
        Bitmap.Config conf = Bitmap.Config.ARGB_8888;
        Bitmap bmp = Bitmap.createBitmap(20, 20, conf);
        Canvas canvas1 = new Canvas(bmp);

        // paint defines the text color, stroke width and size
        Paint color = new Paint();
        color.setTextSize(35);
        color.setColor(Color.BLACK);
        canvas1.drawCircle(10, 10, 10, color);
        googleMap.addMarker(new MarkerOptions().position(new LatLng(objectModel.getLat(), objectModel.getLon()))
                .title(objectModel.getName()).snippet("snippet").icon(BitmapDescriptorFactory.fromBitmap(bmp)));
    } catch (NullPointerException e) {
        Log.d("error", e.getMessage());
    }

}

From source file:com.mx.hb.moon.swipeRefresh.SwipeProgressBar.java

private void drawTrigger(Canvas canvas, int cx, int cy) {
    mPaint.setColor(mColor1);/*from ww w.j ava  2 s . c  o m*/
    mPaint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawCircle(cx, cy, cx * mTriggerPercentage, mPaint);
}

From source file:com.appsimobile.appsii.module.home.SunriseDrawable.java

private void drawSun(Canvas canvas, float pct) {

    // Draw the dots
    canvas.drawCircle(mBezier1x, mBezier1y, mDotRadius, mDotPaint);
    canvas.drawCircle(mBezier4x, mBezier4y, mDotRadius, mDotPaint);

    // calculate the center point of the sun image
    float x = bezierInterpolation(pct, mBezier1x, mBezier2x, mBezier3x, mBezier4x);
    float y = bezierInterpolation(pct, mBezier1y, mBezier2y, mBezier3y, mBezier4y);

    Rect sunBounds = mSunImage.getBounds();

    x -= sunBounds.width() / 2;/*from  w  w  w  . j  a v  a  2  s.c o m*/
    y -= sunBounds.height() / 2;

    // if we are in rtl, we still want to show the image normally
    // so flip it back
    canvas.translate(x, y);
    if (mIsRtl) {
        canvas.save();
        canvas.scale(-1, 1, sunBounds.centerX(), sunBounds.centerY());
    }
    // draw the sun image
    mSunImage.draw(canvas);
    // restore the flip again
    if (mIsRtl) {
        canvas.restore();
    }
    canvas.translate(-x, -y);

}

From source file:com.microsoft.mimickeralarm.mimics.ProgressButton.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (mState == State.ReadyCamera) {
        prepareDrawFill(sYellow);/*  ww  w  .  ja va 2s.c  o  m*/
        canvas.drawCircle(mCenterX, mCenterY, mRadius, mBrush);

        canvas.drawBitmap(mCameraIcon, mCenterX - (mCameraIcon.getWidth() / 2),
                mCenterY - (mCameraIcon.getHeight() / 2), mBrush);
    } else if (mState == State.ReadyAudio) {
        prepareDrawFill(sYellow);
        canvas.drawCircle(mCenterX, mCenterY, mRadius, mBrush);

        canvas.drawBitmap(mMicrophoneIcon, mCenterX - (mMicrophoneIcon.getWidth() / 2),
                mCenterY - (mMicrophoneIcon.getHeight() / 2), mBrush);
    } else if (mState == State.Loading) {
        prepareDrawFill(sBlue);
        canvas.drawCircle(mCenterX, mCenterY, mRadius, mBrush);

        prepareDrawStroke(sWhite);
        canvas.drawArc(mLoadingAnimationRect, mLoadingAnimationProgress, 300f, false, mBrush);
    } else if (mState == State.Waiting) {
        prepareDrawFill(sGrey);
        canvas.drawCircle(mCenterX, mCenterY, mRadius, mBrush);
        prepareDrawFill(sWhite);
        canvas.drawCircle(mCenterX, mCenterY, (float) (mRadius * 0.7), mBrush);
        prepareDrawFill(sGrey);
        float w = (float) (mRadius * 0.3);
        canvas.drawRect(mCenterX - w, mCenterY - w, mCenterX + w, mCenterY + w, mBrush);
    }
}

From source file:ggikko.me.steppertest.stepper.RoundedView.java

@Override
protected void onDraw(Canvas canvas) {
    //if (getBackgroundColor(this) != 0) color = getBackgroundColor(this);

    paint.setAntiAlias(true);//from ww w .ja  va  2s.  c  o  m
    paint.setFilterBitmap(true);
    paint.setDither(true);
    canvas.drawARGB(0, 0, 0, 0);

    paint.setColor(color);
    canvas.drawCircle(getWidth() / 2, getHeight() / 2, getWidth() / 2, paint);

    if (text != null && !checked)
        drawText(canvas);
    if (checked && text == null)
        drawChecked(canvas);
}

From source file:com.appyvet.materialrangebar.PinView.java

@Override
public void draw(Canvas canvas) {
    //Draw the circle boundary only if mCircleBoundaryPaint was initialized
    if (mCircleBoundaryPaint != null)
        canvas.drawCircle(mX, mY, mCircleRadiusPx, mCircleBoundaryPaint);

    canvas.drawCircle(mX, mY, mCircleRadiusPx, mCirclePaint);
    //Draw pin if pressed
    if (mPinRadiusPx > 0 && (mHasBeenPressed || !mPinsAreTemporary)) {
        mBounds.set((int) mX - mPinRadiusPx, (int) mY - (mPinRadiusPx * 2) - (int) mPinPadding,
                (int) mX + mPinRadiusPx, (int) mY - (int) mPinPadding);
        mPin.setBounds(mBounds);// www  .  j  a v  a  2s. c  om
        String text = mValue;

        if (this.formatter != null) {
            text = formatter.format(text);
        }

        calibrateTextSize(mTextPaint, text, mBounds.width());
        mTextPaint.getTextBounds(text, 0, text.length(), mBounds);
        mTextPaint.setTextAlign(Paint.Align.CENTER);
        DrawableCompat.setTint(mPin, pinColor);
        mPin.draw(canvas);
        canvas.drawText(text, mX, mY - mPinRadiusPx - mPinPadding + mTextYPadding, mTextPaint);
    }
    super.draw(canvas);
}

From source file:com.cuelogic.android.WheelIndicatorView.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.translate(traslationX, traslationY);
    if (circleBackgroundPaint != null)
        canvas.drawCircle(wheelBoundsRectF.centerX(), wheelBoundsRectF.centerY(),
                wheelBoundsRectF.width() / 2 - itemsLineWidth, circleBackgroundPaint);
    canvas.drawArc(wheelBoundsRectF, ANGLE_INIT_OFFSET, 360, false, innerBackgroundCirclePaint);
    drawIndicatorItems("First", canvas);

    //        itemArcPaint.setColor(Color.parseColor("#FF9000"));
    //        canvas.drawArc((float)wheelBoundsRectF.centerX(), wheelBoundsRectF.centerY(),
    //                wheelBoundsRectF.width() / 2 - itemsLineWidth,false, itemArcPaint);
    drawIndicatorArc(canvas);//from www.  j a  v a 2  s .  co m
    drawIndicatorItems("Second", canvas);

}