Example usage for android.graphics Canvas drawRoundRect

List of usage examples for android.graphics Canvas drawRoundRect

Introduction

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

Prototype

public void drawRoundRect(@NonNull RectF rect, float rx, float ry, @NonNull Paint paint) 

Source Link

Document

Draw the specified round-rect using the specified paint.

Usage

From source file:talex.zsw.baselibrary.widget.NavigationTabBar.java

@Override
protected void onDraw(final Canvas canvas) {
    if (mCanvas == null || mPointerCanvas == null || mIconsCanvas == null)
        return;//from  w  w  w . j  a  v a2  s.  co  m

    // Reset and clear canvases
    mCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
    mPointerCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
    mIconsCanvas.drawColor(0, PorterDuff.Mode.CLEAR);

    // Get pointer badge margin for gravity
    final float pointerBadgeMargin = mBadgeGravity == BadgeGravity.TOP ? mBadgeMargin : 0.0f;

    // Draw our model colors
    for (int i = 0; i < mModels.size(); i++) {
        mPaint.setColor(mModels.get(i).getColor());

        if (mIsHorizontalOrientation) {
            final float left = mModelSize * i;
            final float right = left + mModelSize;
            mCanvas.drawRect(left, pointerBadgeMargin, right, mBounds.height() + pointerBadgeMargin, mPaint);
        } else {
            final float top = mModelSize * i;
            final float bottom = top + mModelSize;
            mCanvas.drawRect(0.0f, top, mBounds.width(), bottom, mPaint);
        }
    }

    // Set bound of pointer
    if (mIsHorizontalOrientation) {
        mPointerBounds.set(mPointerLeftTop, pointerBadgeMargin, mPointerRightBottom,
                mBounds.height() + pointerBadgeMargin);
    } else {
        mPointerBounds.set(0.0f, mPointerLeftTop, mBounds.width(), mPointerRightBottom);
    }

    // Draw pointer for model colors
    if (mCornersRadius == 0) {
        mPointerCanvas.drawRect(mPointerBounds, mPaint);
    } else {
        mPointerCanvas.drawRoundRect(mPointerBounds, mCornersRadius, mCornersRadius, mPaint);
    }

    // Draw pointer into main canvas
    mCanvas.drawBitmap(mPointerBitmap, 0.0f, 0.0f, mPointerPaint);

    // Draw model icons
    for (int i = 0; i < mModels.size(); i++) {
        final Model model = mModels.get(i);

        // Variables to center our icons
        final float leftOffset;
        final float topOffset;
        final float matrixCenterX;
        final float matrixCenterY;

        // Set vars for icon when model with title or without
        final float iconMarginTitleHeight = mIconSize + mTitleMargin + mModelTitleSize;
        final float leftTitleOffset = (mModelSize * i) + (mModelSize * 0.5f);
        final float topTitleOffset = mBounds.height() - (mBounds.height() - iconMarginTitleHeight) * 0.5f;

        if (mIsHorizontalOrientation) {
            leftOffset = (mModelSize * i) + (mModelSize - model.mIcon.getWidth()) * 0.5f;
            topOffset = (mBounds.height() - model.mIcon.getHeight()) * 0.5f;

            matrixCenterX = leftOffset + model.mIcon.getWidth() * 0.5f;
            matrixCenterY = topOffset + model.mIcon.getHeight() * 0.5f
                    + (mIsTitled && mTitleMode == TitleMode.ALL ? mTitleMargin * 0.5f : 0.0f);
        } else {
            leftOffset = (mBounds.width() - model.mIcon.getWidth()) * 0.5f;
            topOffset = (mModelSize * i) + (mModelSize - model.mIcon.getHeight()) * 0.5f;

            matrixCenterX = leftOffset + model.mIcon.getWidth() * 0.5f;
            matrixCenterY = topOffset + model.mIcon.getHeight() * 0.5f;
        }

        // Title translate position
        final float titleTranslate = -model.mIcon.getHeight() + topTitleOffset - mTitleMargin * 0.5f;

        // Translate icon to model center
        model.mIconMatrix.setTranslate(leftOffset,
                (mIsTitled && mTitleMode == TitleMode.ALL) ? titleTranslate : topOffset);

        // Get interpolated fraction for left last and current models
        final float interpolation = mResizeInterpolator.getResizeInterpolation(mFraction, true);
        final float lastInterpolation = mResizeInterpolator.getResizeInterpolation(mFraction, false);

        // Scale value relative to interpolation
        final float matrixScale = model.mActiveIconScaleBy * interpolation;
        final float matrixLastScale = model.mActiveIconScaleBy * lastInterpolation;

        // Get title alpha relative to interpolation
        final int titleAlpha = (int) (MAX_ALPHA * interpolation);
        final int titleLastAlpha = MAX_ALPHA - (int) (MAX_ALPHA * lastInterpolation);
        // Get title scale relative to interpolation
        final float titleScale = MAX_FRACTION + (interpolation * TITLE_ACTIVE_SCALE_BY);
        final float titleLastScale = (MAX_FRACTION + TITLE_ACTIVE_SCALE_BY)
                - (lastInterpolation * TITLE_ACTIVE_SCALE_BY);

        // Check if we handle models from touch on NTP or from ViewPager
        // There is a strange logic of ViewPager onPageScrolled method, so it is
        if (mIsSetIndexFromTabBar) {
            if (mIndex == i) {
                updateCurrentModel(model, leftOffset, topOffset, titleTranslate, interpolation, matrixCenterX,
                        matrixCenterY, matrixScale, titleScale, titleAlpha);
            } else if (mLastIndex == i) {
                updateLastModel(model, leftOffset, topOffset, titleTranslate, lastInterpolation, matrixCenterX,
                        matrixCenterY, matrixLastScale, titleLastScale, titleLastAlpha);
            } else {
                updateInactiveModel(model, leftOffset, topOffset, matrixCenterX, matrixCenterY);
            }
        } else {
            if (i != mIndex && i != mIndex + 1) {
                updateInactiveModel(model, leftOffset, topOffset, matrixCenterX, matrixCenterY);
            } else if (i == mIndex + 1) {
                updateCurrentModel(model, leftOffset, topOffset, titleTranslate, interpolation, matrixCenterX,
                        matrixCenterY, matrixScale, titleScale, titleAlpha);
            } else if (i == mIndex) {
                updateLastModel(model, leftOffset, topOffset, titleTranslate, lastInterpolation, matrixCenterX,
                        matrixCenterY, matrixLastScale, titleLastScale, titleLastAlpha);
            }
        }

        // Draw model icon
        mIconsCanvas.drawBitmap(model.mIcon, model.mIconMatrix, mIconPaint);
        if (mIsTitled) {
            mIconsCanvas.drawText(isInEditMode() ? PREVIEW_TITLE : model.getTitle(), leftTitleOffset,
                    topTitleOffset, mModelTitlePaint);
        }
    }

    // Draw pointer with active color to wrap out active icon
    if (mCornersRadius == 0) {
        mIconsCanvas.drawRect(mPointerBounds, mIconPointerPaint);
    } else {
        mIconsCanvas.drawRoundRect(mPointerBounds, mCornersRadius, mCornersRadius, mIconPointerPaint);
    }

    // Draw general bitmap
    canvas.drawBitmap(mBitmap, 0.0f, 0.0f, null);
    // Draw icons bitmap on top
    canvas.drawBitmap(mIconsBitmap, 0.0f, pointerBadgeMargin, null);

    // If is not badged, exit
    if (!mIsBadged)
        return;

    // Model badge margin and offset relative to gravity mode
    final float modelBadgeMargin = mBadgeGravity == BadgeGravity.TOP ? mBadgeMargin : mBounds.height();
    final float modelBadgeOffset = mBadgeGravity == BadgeGravity.TOP ? 0.0f : mBounds.height() - mBadgeMargin;

    for (int i = 0; i < mModels.size(); i++) {
        final Model model = mModels.get(i);

        // Set preview badge title
        if (isInEditMode() || TextUtils.isEmpty(model.getBadgeTitle())) {
            model.setBadgeTitle(PREVIEW_BADGE);
        }

        // Set badge title bounds
        mBadgePaint.setTextSize(mBadgeTitleSize * model.mBadgeFraction);
        mBadgePaint.getTextBounds(model.getBadgeTitle(), 0, model.getBadgeTitle().length(), mBadgeBounds);

        // Get horizontal and vertical padding for bg
        final float horizontalPadding = mBadgeTitleSize * BADGE_HORIZONTAL_FRACTION;
        final float verticalPadding = horizontalPadding * BADGE_VERTICAL_FRACTION;

        // Set horizontal badge offset
        final float badgeBoundsHorizontalOffset = (mModelSize * i)
                + (mModelSize * mBadgePosition.mPositionFraction);

        // If is badge title only one char, so create circle else round rect
        if (model.getBadgeTitle().length() == 1) {
            final float badgeMargin = mBadgeMargin * model.mBadgeFraction;
            mBgBadgeBounds.set(badgeBoundsHorizontalOffset - badgeMargin, modelBadgeMargin - badgeMargin,
                    badgeBoundsHorizontalOffset + badgeMargin, modelBadgeMargin + badgeMargin);
        } else {
            mBgBadgeBounds.set(badgeBoundsHorizontalOffset - mBadgeBounds.centerX() - horizontalPadding,
                    modelBadgeMargin - (mBadgeMargin * model.mBadgeFraction),
                    badgeBoundsHorizontalOffset + mBadgeBounds.centerX() + horizontalPadding,
                    modelBadgeOffset + (verticalPadding * 2.0f) + mBadgeBounds.height());
        }

        // Set color and alpha for badge bg
        if (model.mBadgeFraction == MIN_FRACTION) {
            mBadgePaint.setColor(Color.TRANSPARENT);
        } else {
            mBadgePaint.setColor(mActiveColor);
        }
        mBadgePaint.setAlpha((int) (MAX_ALPHA * model.mBadgeFraction));

        // Set corners to round rect for badge bg and draw
        final float cornerRadius = mBgBadgeBounds.height() * 0.5f;
        canvas.drawRoundRect(mBgBadgeBounds, cornerRadius, cornerRadius, mBadgePaint);

        // Set color and alpha for badge title
        if (model.mBadgeFraction == MIN_FRACTION) {
            mBadgePaint.setColor(Color.TRANSPARENT);
        } else {
            mBadgePaint.setColor(model.getColor());
        }
        mBadgePaint.setAlpha((int) (MAX_ALPHA * model.mBadgeFraction));

        // Set badge title center position and draw title
        final float badgeHalfHeight = mBadgeBounds.height() * 0.5f;
        float badgeVerticalOffset = (mBgBadgeBounds.height() * 0.5f) + badgeHalfHeight - mBadgeBounds.bottom
                + modelBadgeOffset;
        canvas.drawText(model.getBadgeTitle(), badgeBoundsHorizontalOffset,
                badgeVerticalOffset + mBadgeBounds.height() - (mBadgeBounds.height() * model.mBadgeFraction),
                mBadgePaint);
    }
}

From source file:com.gigamole.library.ntb.NavigationTabBar.java

@SuppressWarnings("ConstantConditions")
@Override/*from  w ww.  j av  a  2  s.co m*/
protected void onDraw(final Canvas canvas) {
    if (mBackground != null)
        canvas.drawBitmap(mBackground, 0.0F, mBadgeGravity == BadgeGravity.TOP ? getBadgeMargin() : 0.0F, null);

    if (mCanvas == null || mPointerCanvas == null || mIconsCanvas == null || mTitlesCanvas == null)
        return;

    // Reset and clear canvases
    mCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
    mPointerCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
    mIconsCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
    if (mIsTitled)
        mTitlesCanvas.drawColor(0, PorterDuff.Mode.CLEAR);

    // Get pointer badge margin for gravity
    final float pointerBadgeMargin = mBadgeGravity == BadgeGravity.TOP ? mBadgeMargin : 0.0F;

    // Draw our model colors
    for (int i = 0; i < mModels.size(); i++) {
        mPaint.setColor(mModels.get(i).getColor());

        if (mIsHorizontalOrientation) {
            final float left = mModelSize * i;
            final float right = left + mModelSize;
            mCanvas.drawRect(left, pointerBadgeMargin, right, mBounds.height() + pointerBadgeMargin, mPaint);
        } else {
            final float top = mModelSize * i;
            final float bottom = top + mModelSize;
            mCanvas.drawRect(0.0F, top, mBounds.width(), bottom, mPaint);
        }
    }

    // Set bound of pointer
    if (mIsHorizontalOrientation)
        mPointerBounds.set(mPointerLeftTop, pointerBadgeMargin, mPointerRightBottom,
                mBounds.height() + pointerBadgeMargin);
    else
        mPointerBounds.set(0.0F, mPointerLeftTop, mBounds.width(), mPointerRightBottom);

    // Draw pointer for model colors
    if (mCornersRadius == 0)
        mPointerCanvas.drawRect(mPointerBounds, mPaint);
    else
        mPointerCanvas.drawRoundRect(mPointerBounds, mCornersRadius, mCornersRadius, mPaint);

    // Draw pointer into main canvas
    mCanvas.drawBitmap(mPointerBitmap, 0.0F, 0.0F, mPointerPaint);

    // Set vars for icon when model with title or without
    final float iconMarginTitleHeight = mIconSize + mTitleMargin + mModelTitleSize;

    // Draw model icons
    for (int i = 0; i < mModels.size(); i++) {
        final Model model = mModels.get(i);

        // Variables to center our icons
        final float leftOffset;
        final float topOffset;
        final float matrixCenterX;
        final float matrixCenterY;

        // Set offset to titles
        final float leftTitleOffset = (mModelSize * i) + (mModelSize * 0.5F);
        final float topTitleOffset = mBounds.height() - (mBounds.height() - iconMarginTitleHeight) * 0.5F;

        if (mIsHorizontalOrientation) {
            leftOffset = (mModelSize * i) + (mModelSize - model.mIcon.getWidth()) * 0.5F;
            topOffset = (mBounds.height() - model.mIcon.getHeight()) * 0.5F;
        } else {
            leftOffset = (mBounds.width() - (float) model.mIcon.getWidth()) * 0.5F;
            topOffset = (mModelSize * i) + (mModelSize - (float) model.mIcon.getHeight()) * 0.5F;
        }

        matrixCenterX = leftOffset + (float) model.mIcon.getWidth() * 0.5F;
        matrixCenterY = topOffset + (float) model.mIcon.getHeight() * 0.5F;

        // Title translate position
        final float titleTranslate = topOffset - model.mIcon.getHeight() * TITLE_MARGIN_SCALE_FRACTION;

        // Translate icon to model center
        model.mIconMatrix.setTranslate(leftOffset,
                (mIsTitled && mTitleMode == TitleMode.ALL) ? titleTranslate : topOffset);

        // Get interpolated fraction for left last and current models
        final float interpolation = mResizeInterpolator.getResizeInterpolation(mFraction, true);
        final float lastInterpolation = mResizeInterpolator.getResizeInterpolation(mFraction, false);

        // Scale value relative to interpolation
        final float matrixScale = model.mActiveIconScaleBy * (mIsScaled ? interpolation : NON_SCALED_FRACTION);
        final float matrixLastScale = model.mActiveIconScaleBy
                * (mIsScaled ? lastInterpolation : (MAX_FRACTION - NON_SCALED_FRACTION));

        // Get title alpha relative to interpolation
        final int titleAlpha = (int) (MAX_ALPHA * interpolation);
        final int titleLastAlpha = MAX_ALPHA - (int) (MAX_ALPHA * lastInterpolation);
        // Get title scale relative to interpolation
        final float titleScale = MAX_FRACTION
                + ((mIsScaled ? interpolation : NON_SCALED_FRACTION) * TITLE_ACTIVE_SCALE_BY);
        final float titleLastScale = mIsScaled
                ? (MAX_FRACTION + TITLE_ACTIVE_SCALE_BY) - (lastInterpolation * TITLE_ACTIVE_SCALE_BY)
                : titleScale;

        mIconPaint.setAlpha(MAX_ALPHA);
        if (model.mSelectedIcon != null)
            mSelectedIconPaint.setAlpha(MAX_ALPHA);

        // Check if we handle models from touch on NTB or from ViewPager
        // There is a strange logic
        // of ViewPager onPageScrolled method, so it is
        if (mIsSetIndexFromTabBar) {
            if (mIndex == i)
                updateCurrentModel(model, leftOffset, topOffset, titleTranslate, interpolation, matrixCenterX,
                        matrixCenterY, matrixScale, titleScale, titleAlpha);
            else if (mLastIndex == i)
                updateLastModel(model, leftOffset, topOffset, titleTranslate, lastInterpolation, matrixCenterX,
                        matrixCenterY, matrixLastScale, titleLastScale, titleLastAlpha);
            else
                updateInactiveModel(model, leftOffset, topOffset, titleScale, matrixScale, matrixCenterX,
                        matrixCenterY);
        } else {
            if (i != mIndex && i != mIndex + 1)
                updateInactiveModel(model, leftOffset, topOffset, titleScale, matrixScale, matrixCenterX,
                        matrixCenterY);
            else if (i == mIndex + 1)
                updateCurrentModel(model, leftOffset, topOffset, titleTranslate, interpolation, matrixCenterX,
                        matrixCenterY, matrixScale, titleScale, titleAlpha);
            else if (i == mIndex)
                updateLastModel(model, leftOffset, topOffset, titleTranslate, lastInterpolation, matrixCenterX,
                        matrixCenterY, matrixLastScale, titleLastScale, titleLastAlpha);
        }

        // Draw original model icon
        if (model.mSelectedIcon == null) {
            mIconsCanvas.drawBitmap(model.mIcon, model.mIconMatrix, mIconPaint);
        } else {
            if (mIconPaint.getAlpha() != MIN_ALPHA)
                // Draw original icon when is visible
                mIconsCanvas.drawBitmap(model.mIcon, model.mIconMatrix, mIconPaint);
        }
        // Draw selected icon when exist and visible
        if (model.mSelectedIcon != null && mSelectedIconPaint.getAlpha() != MIN_ALPHA)
            mIconsCanvas.drawBitmap(model.mSelectedIcon, model.mIconMatrix, mSelectedIconPaint);

        if (mIsTitled)
            mTitlesCanvas.drawText(isInEditMode() ? PREVIEW_TITLE : model.getTitle(), leftTitleOffset,
                    topTitleOffset, mModelTitlePaint);
    }

    // Reset pointer bounds for icons and titles
    if (mIsHorizontalOrientation)
        mPointerBounds.set(mPointerLeftTop, 0.0F, mPointerRightBottom, mBounds.height());
    if (mCornersRadius == 0) {
        if (mIsTinted)
            mIconsCanvas.drawRect(mPointerBounds, mIconPointerPaint);
        if (mIsTitled)
            mTitlesCanvas.drawRect(mPointerBounds, mIconPointerPaint);
    } else {
        if (mIsTinted)
            mIconsCanvas.drawRoundRect(mPointerBounds, mCornersRadius, mCornersRadius, mIconPointerPaint);
        if (mIsTitled)
            mTitlesCanvas.drawRoundRect(mPointerBounds, mCornersRadius, mCornersRadius, mIconPointerPaint);
    }

    // Draw general bitmap
    canvas.drawBitmap(mBitmap, 0.0F, 0.0F, null);
    // Draw icons bitmap on top
    canvas.drawBitmap(mIconsBitmap, 0.0F, pointerBadgeMargin, null);
    // Draw titles bitmap on top
    if (mIsTitled)
        canvas.drawBitmap(mTitlesBitmap, 0.0F, pointerBadgeMargin, null);

    // If is not badged, exit
    if (!mIsBadged)
        return;

    // Model badge margin and offset relative to gravity mode
    final float modelBadgeMargin = mBadgeGravity == BadgeGravity.TOP ? mBadgeMargin : mBounds.height();
    final float modelBadgeOffset = mBadgeGravity == BadgeGravity.TOP ? 0.0F : mBounds.height() - mBadgeMargin;

    for (int i = 0; i < mModels.size(); i++) {
        final Model model = mModels.get(i);

        // Set preview badge title
        if (isInEditMode() || TextUtils.isEmpty(model.getBadgeTitle()))
            model.setBadgeTitle(PREVIEW_BADGE);

        // Set badge title bounds
        mBadgePaint.setTextSize(mBadgeTitleSize * model.mBadgeFraction);
        mBadgePaint.getTextBounds(model.getBadgeTitle(), 0, model.getBadgeTitle().length(), mBadgeBounds);

        // Get horizontal and vertical padding for bg
        final float horizontalPadding = mBadgeTitleSize * BADGE_HORIZONTAL_FRACTION;
        final float verticalPadding = horizontalPadding * BADGE_VERTICAL_FRACTION;

        // Set horizontal badge offset
        final float badgeBoundsHorizontalOffset = (mModelSize * i)
                + (mModelSize * mBadgePosition.mPositionFraction);

        // If is badge title only one char, so create circle else round rect
        final float badgeMargin = mBadgeMargin * model.mBadgeFraction;
        if (model.getBadgeTitle().length() == 1) {
            mBgBadgeBounds.set(badgeBoundsHorizontalOffset - badgeMargin, modelBadgeMargin - badgeMargin,
                    badgeBoundsHorizontalOffset + badgeMargin, modelBadgeMargin + badgeMargin);
        } else
            mBgBadgeBounds.set(
                    badgeBoundsHorizontalOffset
                            - Math.max(badgeMargin, mBadgeBounds.centerX() + horizontalPadding),
                    modelBadgeMargin - badgeMargin,
                    badgeBoundsHorizontalOffset
                            + Math.max(badgeMargin, mBadgeBounds.centerX() + horizontalPadding),
                    modelBadgeOffset + (verticalPadding * 2.0F) + mBadgeBounds.height());

        // Set color and alpha for badge bg
        if (model.mBadgeFraction == MIN_FRACTION)
            mBadgePaint.setColor(Color.TRANSPARENT);
        else
            mBadgePaint.setColor(mBadgeBgColor == 0 ? mActiveColor : mBadgeBgColor);
        mBadgePaint.setAlpha((int) (MAX_ALPHA * model.mBadgeFraction));

        // Set corners to round rect for badge bg and draw
        final float cornerRadius = mBgBadgeBounds.height() * 0.5F;
        canvas.drawRoundRect(mBgBadgeBounds, cornerRadius, cornerRadius, mBadgePaint);

        // Set color and alpha for badge title
        if (model.mBadgeFraction == MIN_FRACTION)
            mBadgePaint.setColor(Color.TRANSPARENT);
        else //noinspection ResourceAsColor
            mBadgePaint.setColor(mBadgeTitleColor == 0 ? model.getColor() : mBadgeTitleColor);
        mBadgePaint.setAlpha((int) (MAX_ALPHA * model.mBadgeFraction));

        // Set badge title center position and draw title
        final float badgeHalfHeight = mBadgeBounds.height() * 0.5F;
        float badgeVerticalOffset = (mBgBadgeBounds.height() * 0.5F) + badgeHalfHeight - mBadgeBounds.bottom
                + modelBadgeOffset;
        canvas.drawText(model.getBadgeTitle(), badgeBoundsHorizontalOffset,
                badgeVerticalOffset + mBadgeBounds.height() - (mBadgeBounds.height() * model.mBadgeFraction),
                mBadgePaint);
    }
}

From source file:radialdemo.RadialMenuWidget.java

@Override
protected void onDraw(Canvas c) {

    Paint paint = new Paint();
    paint.setAntiAlias(true);// w ww .j  a  v  a2  s  .c o  m
    paint.setStrokeWidth(3);

    // draws a dot at the source of the press
    if (showSource == true) {
        paint.setColor(outlineColor);
        paint.setAlpha(outlineAlpha);
        paint.setStyle(Paint.Style.STROKE);
        c.drawCircle(xSource, ySource, cRadius / 10, paint);

        paint.setColor(selectedColor);
        paint.setAlpha(selectedAlpha);
        paint.setStyle(Paint.Style.FILL);
        c.drawCircle(xSource, ySource, cRadius / 10, paint);
    }
    //inner
    for (int i = 0; i < Wedges.length; i++) {
        RadialMenuWedge f = Wedges[i];
        paint.setColor(outlineColor);
        paint.setAlpha(outlineAlpha);
        paint.setStyle(Paint.Style.STROKE);
        c.drawPath(f, paint);
        if (f == enabled && Wedge2Shown == true) {
            paint.setColor(wedge2Color);
            paint.setAlpha(wedge2Alpha);
            paint.setStyle(Paint.Style.FILL);
            c.drawPath(f, paint);
        } else if (f != enabled && Wedge2Shown == true) {
            paint.setColor(disabledColor);
            paint.setAlpha(disabledAlpha);
            paint.setStyle(Paint.Style.FILL);
            c.drawPath(f, paint);
        } else if (f == enabled && Wedge2Shown == false) {
            paint.setColor(wedge2Color);
            paint.setAlpha(wedge2Alpha);
            paint.setStyle(Paint.Style.FILL);
            c.drawPath(f, paint);
        } else if (f == selected) {
            paint.setColor(wedge2Color);
            paint.setAlpha(wedge2Alpha);
            paint.setStyle(Paint.Style.FILL);
            c.drawPath(f, paint);
        } else {
            paint.setColor(defaultColor);
            paint.setAlpha(defaultAlpha);
            paint.setStyle(Paint.Style.FILL);
            c.drawPath(f, paint);
        }
        //button content
        Rect rf = iconRect[i];

        if ((menuEntries.get(i).getIcon() != 0) && (menuEntries.get(i).getLabel() != null)) {

            // This will look for a "new line" and split into multiple lines
            String menuItemName = menuEntries.get(i).getLabel();
            String[] stringArray = menuItemName.split("\n");

            paint.setColor(textColor);
            if (f != enabled && Wedge2Shown == true) {
                paint.setAlpha(disabledAlpha);
            } else {
                paint.setAlpha(textAlpha);
            }
            paint.setStyle(Paint.Style.FILL);
            paint.setTextSize(textSize);

            Rect rect = new Rect();
            float textHeight = 0;
            for (int j = 0; j < stringArray.length; j++) {
                paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect);
                textHeight = textHeight + (rect.height() + 3);
            }

            Rect rf2 = new Rect();
            rf2.set(rf.left, rf.top - ((int) textHeight / 2), rf.right, rf.bottom - ((int) textHeight / 2));

            float textBottom = rf2.bottom;
            for (int j = 0; j < stringArray.length; j++) {
                paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect);
                float textLeft = rf.centerX() - rect.width() / 2;
                textBottom = textBottom + (rect.height() + 3);
                c.drawText(stringArray[j], textLeft - rect.left, textBottom - rect.bottom, paint);
            }

            // Puts in the Icon
            Drawable drawable = getResources().getDrawable(menuEntries.get(i).getIcon());
            drawable.setBounds(rf2);
            if (f != enabled && Wedge2Shown == true) {
                drawable.setAlpha(disabledAlpha);
            } else {
                drawable.setAlpha(pictureAlpha);
            }
            drawable.draw(c);

            // Icon Only
        } else if (menuEntries.get(i).getIcon() != 0) {
            // Puts in the Icon
            Drawable drawable = getResources().getDrawable(menuEntries.get(i).getIcon());
            drawable.setBounds(rf);
            if (f != enabled && Wedge2Shown == true) {
                drawable.setAlpha(disabledAlpha);
            } else {
                drawable.setAlpha(pictureAlpha);
            }
            drawable.draw(c);

            // Text Only
        } else {
            // Puts in the Text if no Icon
            paint.setColor(textColor);
            if (f != enabled && Wedge2Shown == true) {
                paint.setAlpha(disabledAlpha);
            } else {
                paint.setAlpha(textAlpha);
            }
            paint.setStyle(Paint.Style.FILL);
            paint.setTextSize(textSize + 10);

            // This will look for a "new line" and split into multiple lines
            String menuItemName = menuEntries.get(i).getLabel();
            String[] stringArray = menuItemName.split("\n");

            // gets total height
            Rect rect = new Rect();
            float textHeight = 0;
            for (int j = 0; j < stringArray.length; j++) {
                paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect);
                textHeight = textHeight + (rect.height() + 3);
            }

            float textBottom = rf.centerY() - (textHeight / 2);
            for (int j = 0; j < stringArray.length; j++) {
                paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect);
                float textLeft = rf.centerX() - rect.width() / 2;
                textBottom = textBottom + (rect.height() + 3);
                c.drawText(stringArray[j], textLeft - rect.left, textBottom - rect.bottom, paint);
            }
        }

    }

    // Animate the outer ring in/out
    if (animateOuterIn == true) {
        animateOuterWedges(ANIMATE_IN);
    } else if (animateOuterOut == true) {
        animateOuterWedges(ANIMATE_OUT);
    }
    //outer
    if (Wedge2Shown == true) {

        for (int i = 0; i < Wedges2.length; i++) {
            RadialMenuWedge f = Wedges2[i];
            paint.setColor(outlineColor);
            paint.setAlpha(20);
            paint.setStyle(Paint.Style.STROKE);
            c.drawPath(f, paint);
            if (f == selected2) {
                paint.setColor(selectedColor);
                paint.setAlpha(selectedAlpha);
                paint.setStyle(Paint.Style.FILL);
                c.drawPath(f, paint);
            } else {
                paint.setColor(wedge2Color);
                paint.setAlpha(wedge2Alpha);
                paint.setStyle(Paint.Style.FILL);
                c.drawPath(f, paint);
            }

            Rect rf = iconRect2[i];
            if ((wedge2Data.getChildren().get(i).getIcon() != 0)
                    && (wedge2Data.getChildren().get(i).getLabel() != null)) {

                // This will look for a "new line" and split into multiple
                // lines
                String menuItemName = wedge2Data.getChildren().get(i).getLabel();
                String[] stringArray = menuItemName.split("\n");

                paint.setColor(textColor);
                paint.setAlpha(textAlpha);
                paint.setStyle(Paint.Style.FILL);
                paint.setTextSize(animateTextSize);

                Rect rect = new Rect();
                float textHeight = 0;
                for (int j = 0; j < stringArray.length; j++) {
                    paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect);
                    textHeight = textHeight + (rect.height() + 3);
                }

                Rect rf2 = new Rect();
                rf2.set(rf.left, rf.top - ((int) textHeight / 2), rf.right, rf.bottom - ((int) textHeight / 2));

                float textBottom = rf2.bottom;
                for (int j = 0; j < stringArray.length; j++) {
                    paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect);
                    float textLeft = rf.centerX() - rect.width() / 2;
                    textBottom = textBottom + (rect.height() + 3);
                    c.drawText(stringArray[j], textLeft - rect.left, textBottom - rect.bottom, paint);
                }

                // Puts in the Icon
                Drawable drawable = getResources().getDrawable(wedge2Data.getChildren().get(i).getIcon());
                drawable.setBounds(rf2);
                drawable.setAlpha(pictureAlpha);
                drawable.draw(c);

                // Icon Only
            } else if (wedge2Data.getChildren().get(i).getIcon() != 0) {
                // Puts in the Icon
                Drawable drawable = getResources().getDrawable(wedge2Data.getChildren().get(i).getIcon());
                drawable.setBounds(rf);
                drawable.setAlpha(pictureAlpha);
                drawable.draw(c);

                // Text Only
            } else {
                // Puts in the Text if no Icon
                paint.setColor(textColor);
                paint.setAlpha(textAlpha);
                paint.setStyle(Paint.Style.FILL);
                paint.setTextSize(animateTextSize);

                // This will look for a "new line" and split into multiple
                // lines
                String menuItemName = wedge2Data.getChildren().get(i).getLabel();
                String[] stringArray = menuItemName.split("\n");

                // gets total height
                Rect rect = new Rect();
                float textHeight = 0;
                for (int j = 0; j < stringArray.length; j++) {
                    paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect);
                    textHeight = textHeight + (rect.height() + 3);
                }

                float textBottom = rf.centerY() - (textHeight / 2);
                for (int j = 0; j < stringArray.length; j++) {
                    paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect);
                    float textLeft = rf.centerX() - rect.width() / 2;
                    textBottom = textBottom + (rect.height() + 3);
                    c.drawText(stringArray[j], textLeft - rect.left, textBottom - rect.bottom, paint);
                }
            }
        }
    }

    //Check if the user has given input for centre circle
    if (centerCircle != null) {
        // Draws the Middle Circle
        paint.setColor(outlineColor);
        paint.setAlpha(outlineAlpha);
        paint.setStyle(Paint.Style.STROKE);
        c.drawCircle(xPosition, yPosition, cRadius, paint);
        if (inCircle == true) {
            paint.setColor(selectedColor);
            paint.setAlpha(selectedAlpha);
            paint.setStyle(Paint.Style.FILL);
            c.drawCircle(xPosition, yPosition, cRadius, paint);
            helper.onCloseAnimation(this, xPosition, yPosition, xSource, ySource);
        } else {
            paint.setColor(defaultColor);
            paint.setAlpha(defaultAlpha);
            paint.setStyle(Paint.Style.FILL);
            c.drawCircle(xPosition, yPosition, cRadius, paint);
        }

        // Draw the circle picture
        if ((centerCircle.getIcon() != 0) && (centerCircle.getLabel() != null)) {

            // This will look for a "new line" and split into multiple lines
            String menuItemName = centerCircle.getLabel();
            String[] stringArray = menuItemName.split("\n");

            paint.setColor(textColor);
            paint.setAlpha(textAlpha);
            paint.setStyle(Paint.Style.FILL);
            paint.setTextSize(textSize);

            Rect rectText = new Rect();
            Rect rectIcon = new Rect();
            Drawable drawable = getResources().getDrawable(centerCircle.getIcon());

            int h = getIconSize(drawable.getIntrinsicHeight(), MinIconSize, MaxIconSize);
            int w = getIconSize(drawable.getIntrinsicWidth(), MinIconSize, MaxIconSize);
            rectIcon.set(xPosition - w / 2, yPosition - h / 2, xPosition + w / 2, yPosition + h / 2);

            float textHeight = 0;
            for (int j = 0; j < stringArray.length; j++) {
                paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rectText);
                textHeight = textHeight + (rectText.height() + 3);
            }

            rectIcon.set(rectIcon.left, rectIcon.top - ((int) textHeight / 2), rectIcon.right,
                    rectIcon.bottom - ((int) textHeight / 2));

            float textBottom = rectIcon.bottom;
            for (int j = 0; j < stringArray.length; j++) {
                paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rectText);
                float textLeft = xPosition - rectText.width() / 2;
                textBottom = textBottom + (rectText.height() + 3);
                c.drawText(stringArray[j], textLeft - rectText.left, textBottom - rectText.bottom, paint);
            }

            // Puts in the Icon
            drawable.setBounds(rectIcon);
            drawable.setAlpha(pictureAlpha);
            drawable.draw(c);

            // Icon Only
        } else if (centerCircle.getIcon() != 0) {

            Rect rect = new Rect();

            Drawable drawable = getResources().getDrawable(centerCircle.getIcon());

            int h = getIconSize(drawable.getIntrinsicHeight(), MinIconSize, MaxIconSize);
            int w = getIconSize(drawable.getIntrinsicWidth(), MinIconSize, MaxIconSize);
            rect.set(xPosition - w / 2, yPosition - h / 2, xPosition + w / 2, yPosition + h / 2);

            drawable.setBounds(rect);
            drawable.setAlpha(pictureAlpha);
            drawable.draw(c);

            // Text Only
        } else {
            // Puts in the Text if no Icon
            paint.setColor(textColor);
            paint.setAlpha(textAlpha);
            paint.setStyle(Paint.Style.FILL);
            paint.setTextSize(textSize);

            // This will look for a "new line" and split into multiple lines
            String menuItemName = centerCircle.getLabel();
            String[] stringArray = menuItemName.split("\n");

            // gets total height
            Rect rect = new Rect();
            float textHeight = 0;
            for (int j = 0; j < stringArray.length; j++) {
                paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect);
                textHeight = textHeight + (rect.height() + 3);
            }

            float textBottom = yPosition - (textHeight / 2);
            for (int j = 0; j < stringArray.length; j++) {
                paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect);
                float textLeft = xPosition - rect.width() / 2;
                textBottom = textBottom + (rect.height() + 3);
                c.drawText(stringArray[j], textLeft - rect.left, textBottom - rect.bottom, paint);
            }

        }
    }

    // Draws Text in TextBox
    if (headerString != null) {

        paint.setTextSize(headerTextSize);
        paint.getTextBounds(headerString, 0, headerString.length(), this.textRect);
        if (HeaderBoxBounded == false) {
            determineHeaderBox();
            HeaderBoxBounded = true;
        }

        paint.setColor(outlineColor);
        paint.setAlpha(outlineAlpha);
        paint.setStyle(Paint.Style.STROKE);
        c.drawRoundRect(this.textBoxRect, scalePX(5), scalePX(5), paint);
        paint.setColor(headerBackgroundColor);
        paint.setAlpha(headerBackgroundAlpha);
        paint.setStyle(Paint.Style.FILL);
        c.drawRoundRect(this.textBoxRect, scalePX(5), scalePX(5), paint);

        paint.setColor(headerTextColor);
        paint.setAlpha(headerTextAlpha);
        paint.setStyle(Paint.Style.FILL);
        paint.setTextSize(headerTextSize);
        c.drawText(headerString, headerTextLeft, headerTextBottom, paint);
    }

}