Example usage for android.graphics Canvas drawRect

List of usage examples for android.graphics Canvas drawRect

Introduction

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

Prototype

public void drawRect(float left, float top, float right, float bottom, @NonNull Paint paint) 

Source Link

Document

Draw the specified Rect using the specified paint.

Usage

From source file:com.hxsn.witwork.ui.ViewfinderView.java

@Override
public void onDraw(Canvas canvas) {
    // ??????CameraManager?
    if (CameraManager.get() == null) {
        return;//from   ww w  .ja va 2s  .  c  o m
    }
    Rect frame = CameraManager.get().getFramingRect();
    if (frame == null) {
        return;
    }

    // ?
    if (!isFirst) {
        isFirst = true;
        slideTop = frame.top;
        slideBottom = frame.bottom;
    }

    // ??
    int width = canvas.getWidth();
    int height = canvas.getHeight();

    paint.setColor(resultBitmap != null ? resultColor : maskColor);

    // ?????????????
    // ?????????
    canvas.drawRect(0, 0, width, frame.top + 15, paint);
    canvas.drawRect(0, frame.top + 15, frame.left + 15, frame.bottom - 14, paint);
    canvas.drawRect(frame.right - 14, frame.top + 15, width, frame.bottom - 14, paint);
    canvas.drawRect(0, frame.bottom - 14, width, height, paint);

    if (resultBitmap != null) {
        // Draw the opaque result bitmap over the scanning rectangle
        paint.setAlpha(OPAQUE);
        canvas.drawBitmap(resultBitmap, frame.left, frame.top, paint);
    } else {

        // ??8
        paint.setColor(Color.rgb(139, 193, 17));
        canvas.drawRect(frame.left, frame.top, frame.left + ScreenRate, frame.top + CORNER_WIDTH, paint);
        canvas.drawRect(frame.left, frame.top, frame.left + CORNER_WIDTH, frame.top + ScreenRate, paint);
        canvas.drawRect(frame.right - ScreenRate, frame.top, frame.right, frame.top + CORNER_WIDTH, paint);
        canvas.drawRect(frame.right - CORNER_WIDTH, frame.top, frame.right, frame.top + ScreenRate, paint);
        canvas.drawRect(frame.left, frame.bottom - CORNER_WIDTH, frame.left + ScreenRate, frame.bottom, paint);
        canvas.drawRect(frame.left, frame.bottom - ScreenRate, frame.left + CORNER_WIDTH, frame.bottom, paint);
        canvas.drawRect(frame.right - ScreenRate, frame.bottom - CORNER_WIDTH, frame.right, frame.bottom,
                paint);
        canvas.drawRect(frame.right - CORNER_WIDTH, frame.bottom - ScreenRate, frame.right, frame.bottom,
                paint);

        // ,??SPEEN_DISTANCE
        slideTop += SPEEN_DISTANCE;
        if (slideTop >= frame.bottom) {
            slideTop = frame.top;
        }
        // canvas.drawRect(frame.left + MIDDLE_LINE_PADDING, slideTop -
        // MIDDLE_LINE_WIDTH/2, frame.right - MIDDLE_LINE_PADDING,slideTop +
        // MIDDLE_LINE_WIDTH/2, paint);
        Rect lineRect = new Rect();

        lineRect.left = frame.left;
        lineRect.right = frame.right;
        lineRect.top = slideTop;
        lineRect.bottom = slideTop + 18;
        canvas.drawBitmap(((BitmapDrawable) (getResources().getDrawable(R.drawable.fgx))).getBitmap(), null,
                lineRect, paint);

        // ???
        paint.setColor(Color.WHITE);
        paint.setTextSize(TEXT_SIZE * density);
        // paint.setAlpha(0x40);
        // paint.setTypeface(Typeface.create("System", Typeface.BOLD));

        canvas.drawText("?/??????", frame.left,
                (float) (frame.bottom + (float) TEXT_PADDING_TOP * density), paint);
        canvas.drawText("??" + num + "", frame.left,
                (float) (frame.bottom + (float) TEXT_PADDING_TOP * density + 50), paint);

        int max = 7;
        if (name.size() < max) {
            max = name.size();
            for (int i = 0; i < max; i++) {
                canvas.drawText(name.get(i), frame.left,
                        (float) (frame.bottom + (float) TEXT_PADDING_TOP * density + 100 + 50 * i), paint);
            }
        } else {
            for (int i = 6; i >= 0; i--) {
                canvas.drawText(name.get((name.size() - 1) - (6 - i)), frame.left,
                        (float) (frame.bottom + (float) TEXT_PADDING_TOP * density + 100 + 50 * i), paint);
            }
        }

        paint.setStyle(Style.STROKE);
        canvas.drawRect(frame.left + 15, frame.top + 15, frame.right - 15, frame.bottom - 15, paint);
        setViewY(frame.bottom);
        paint.setStyle(Style.FILL);

        Collection<ResultPoint> currentPossible = possibleResultPoints;
        Collection<ResultPoint> currentLast = lastPossibleResultPoints;
        if (currentPossible.isEmpty()) {
            lastPossibleResultPoints = null;
        } else {
            possibleResultPoints = new HashSet<ResultPoint>(5);
            lastPossibleResultPoints = currentPossible;
            paint.setAlpha(OPAQUE);
            paint.setColor(resultPointColor);
            for (ResultPoint point : currentPossible) {
                canvas.drawCircle(frame.left + point.getX(), frame.top + point.getY(), 6.0f, paint);
            }
        }
        if (currentLast != null) {
            paint.setAlpha(OPAQUE / 2);
            paint.setColor(resultPointColor);
            for (ResultPoint point : currentLast) {
                canvas.drawCircle(frame.left + point.getX(), frame.top + point.getY(), 3.0f, paint);
            }
        }

        // ????
        postInvalidate();
        // postInvalidateDelayed(ANIMATION_DELAY, frame.left, frame.top,
        // frame.right, frame.bottom);

    }
}

From source file:com.hippo.drawerlayout.DrawerLayout.java

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

    if (mWindowPaddingTop != 0 && mStatusBarColor != Color.TRANSPARENT) {
        canvas.drawRect(0, 0, getWidth(), mWindowPaddingTop, mStatusBarPaint);
    }//  w ww  .jav a  2s  .  c  om

    if (mWindowPaddingBottom != 0 && mNavigationBarColor != Color.TRANSPARENT) {
        int height = getHeight();
        canvas.drawRect(0, height - mWindowPaddingBottom, getWidth(), height, mNavigationBarPaint);
    }
}

From source file:com.android.core.view.indicator.UnderlinePageIndicator.java

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

    if (mViewPager == null) {
        return;/*from   w  ww  . ja  v a2 s  . c  o m*/
    }
    final int count = mViewPager.getAdapter().getCount();
    if (count == 0) {
        return;
    }

    if (mCurrentPage >= count) {
        setCurrentItem(count - 1);
        return;
    }

    final int paddingLeft = getPaddingLeft();
    final float pageWidth = (getWidth() - paddingLeft - getPaddingRight()) / (1f * count);

    final float left = paddingLeft + pageWidth * (mCurrentPage + mPositionOffset);
    final float right = left + pageWidth;
    final float top = getPaddingTop();
    final float bottom = getHeight() - getPaddingBottom();

    final float widthFinal = right - left;

    if (mLineWidth < widthFinal) {
        final float margin = (widthFinal - mLineWidth) / 2;

        final float leftFinal = left + margin;
        final float rightFinal = right - margin;

        canvas.drawRect(leftFinal, top, rightFinal, bottom, mPaint);
    } else {
        canvas.drawRect(left, top, right, bottom, mPaint);
    }
}

From source file:com.jjoe64.graphview.Viewport.java

/**
 * will be first called in order to draw
 * the canvas/* w  ww .  ja va  2s .  com*/
 * Used to draw the background
 *
 * @param c canvas.
 */
public void drawFirst(Canvas c) {
    // draw background
    if (mBackgroundColor != Color.TRANSPARENT) {
        mPaint.setColor(mBackgroundColor);
        c.drawRect(mGraphView.getGraphContentLeft(), mGraphView.getGraphContentTop(),
                mGraphView.getGraphContentLeft() + mGraphView.getGraphContentWidth(),
                mGraphView.getGraphContentTop() + mGraphView.getGraphContentHeight(), mPaint);
    }
    if (mDrawBorder) {
        Paint p;
        if (mBorderPaint != null) {
            p = mBorderPaint;
        } else {
            p = mPaint;
            p.setColor(getBorderColor());
        }
        c.drawLine(mGraphView.getGraphContentLeft(), mGraphView.getGraphContentTop(),
                mGraphView.getGraphContentLeft(),
                mGraphView.getGraphContentTop() + mGraphView.getGraphContentHeight(), p);
        c.drawLine(mGraphView.getGraphContentLeft(),
                mGraphView.getGraphContentTop() + mGraphView.getGraphContentHeight(),
                mGraphView.getGraphContentLeft() + mGraphView.getGraphContentWidth(),
                mGraphView.getGraphContentTop() + mGraphView.getGraphContentHeight(), p);
        // on the right side if we have second scale
        if (mGraphView.mSecondScale != null) {
            c.drawLine(mGraphView.getGraphContentLeft() + mGraphView.getGraphContentWidth(),
                    mGraphView.getGraphContentTop(),
                    mGraphView.getGraphContentLeft() + mGraphView.getGraphContentWidth(),
                    mGraphView.getGraphContentTop() + mGraphView.getGraphContentHeight(), p);
        }
    }
}

From source file:com.example.QQReader.OpenSourceWidget.astuetz.PagerSlidingTabStrip.java

@Override
protected void onDraw(Canvas canvas) {

    super.onDraw(canvas);

    if (isInEditMode() || tabCount == 0) {
        return;//from   ww  w.  java2s.  co  m
    }

    final int height = getHeight();

    // draw indicator line

    rectPaint.setColor(indicatorColor);

    // default: line below current tab
    View currentTab = tabsContainer.getChildAt(currentPosition);
    float lineLeft = currentTab.getLeft();
    float lineRight = currentTab.getRight();

    // if there is an offset, start interpolating left and right coordinates between current and next tab
    if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {

        View nextTab = tabsContainer.getChildAt(currentPosition + 1);
        final float nextTabLeft = nextTab.getLeft();
        final float nextTabRight = nextTab.getRight();

        lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
        lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
    }

    canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);

    // draw underline

    rectPaint.setColor(underlineColor);
    canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);
}

From source file:android.support.design.widget.CollapsingTextHelper.java

public void draw(Canvas canvas) {
    final int saveCount = canvas.save();

    if (mTextToDraw != null && mDrawTitle) {
        float x = mCurrentDrawX;
        float y = mCurrentDrawY;

        final boolean drawTexture = mUseTexture && mExpandedTitleTexture != null;

        final float ascent;
        final float descent;
        if (drawTexture) {
            ascent = mTextureAscent * mScale;
            descent = mTextureDescent * mScale;
        } else {//from   w  ww  .j a  v  a  2  s.com
            ascent = mTextPaint.ascent() * mScale;
            descent = mTextPaint.descent() * mScale;
        }

        if (DEBUG_DRAW) {
            // Just a debug tool, which drawn a magenta rect in the text bounds
            canvas.drawRect(mCurrentBounds.left, y + ascent, mCurrentBounds.right, y + descent,
                    DEBUG_DRAW_PAINT);
        }

        if (drawTexture) {
            y += ascent;
        }

        if (mScale != 1f) {
            canvas.scale(mScale, mScale, x, y);
        }

        if (drawTexture) {
            // If we should use a texture, draw it instead of text
            canvas.drawBitmap(mExpandedTitleTexture, x, y, mTexturePaint);
        } else {
            canvas.drawText(mTextToDraw, 0, mTextToDraw.length(), x, y, mTextPaint);
        }
    }

    canvas.restoreToCount(saveCount);
}

From source file:com.base.app.widget.indicatorview.TabPageIndicator.java

@Override
protected void onDraw(Canvas canvas) {
    // TODO Auto-generated method stub
    super.onDraw(canvas);
    if (isInEditMode() || count == 0) {
        return;//w w  w  .  j  a v  a  2 s  . c om
    }

    final int height = getHeight();
    // draw indicator line
    rectPaint.setColor(indicatorColor);

    // default: line below current tab
    View currentTab = mTabLayout.getChildAt(currentPosition);
    float lineLeft = currentTab.getLeft();
    float lineRight = currentTab.getRight();

    // if there is an offset, start interpolating left and right coordinates between current and next tab
    if (currentPositionOffset > 0f && currentPosition < count - 1) {

        View nextTab = mTabLayout.getChildAt(currentPosition + 1);
        final float nextTabLeft = nextTab.getLeft();
        final float nextTabRight = nextTab.getRight();

        lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
        lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
    }

    canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);

    // draw underline

    rectPaint.setColor(underlineColor);
    canvas.drawRect(0, height - underlineHeight, mTabLayout.getWidth(), height, rectPaint);

    // draw divider
    dividerPaint.setColor(dividerColor);
    for (int i = 0; i < count - 1; i++) {
        View tab = mTabLayout.getChildAt(i);
        canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
    }
}

From source file:com.google.android.apps.forscience.whistlepunk.RunReviewOverlay.java

public void onDraw(Canvas canvas) {
    if (mIsCropping) {
        boolean cropStartOnChart = isXScreenPointInChart(mCropStartData.screenPoint);
        boolean cropEndOnChart = isXScreenPointInChart(mCropEndData.screenPoint);

        // Draw grey overlays first, behind everything
        if (cropStartOnChart) {
            canvas.drawRect(mChartMarginLeft, mHeight - mChartHeight - mPaddingBottom,
                    mCropStartData.screenPoint.x, mHeight, mCropBackgroundPaint);
            // We can handle crop seekbar visibility in onDraw because the Seekbar Group is
            // in charge of receiving touch events, and that is always visible during cropping.
            mCropSeekbarGroup.getStartSeekBar().showThumb();
        } else {/*  w  ww .  j  av a  2s.  c om*/
            mCropSeekbarGroup.getStartSeekBar().hideThumb();
        }
        if (cropEndOnChart) {
            canvas.drawRect(mCropEndData.screenPoint.x, mHeight - mChartHeight - mPaddingBottom,
                    mWidth - mChartMarginRight, mHeight, mCropBackgroundPaint);
            mCropSeekbarGroup.getEndSeekBar().showThumb();
        } else {
            mCropSeekbarGroup.getEndSeekBar().hideThumb();
        }

        // Draw the flags themselves
        if (cropStartOnChart) {
            // Drawing the start flag sets mFlagMeasurements to have the start flag's bounding
            // box. This will allow us to place the end flag appropriately.
            drawFlag(canvas, mCropStartData, mFlagMeasurements, true);
        } else {
            // Clear flag measurements when the left hand flag is offscreen, so that
            // drawFlagAfter does not see another flag to avoid.
            // This means pushing the expected previous flag measurements, stored in
            // mFlagMeasurements, off screen by at least the amount of the flag buffer, which
            // allows the next flag to start drawing at 0.
            // In drawFlagAfter we will use mFlagMeasurements.boxEnd to determine what to
            // avoid.
            mFlagMeasurements.boxEnd = -mCropFlagBufferX;
            mCropStartData.labelRect.set(OFFSCREEN, OFFSCREEN, OFFSCREEN, OFFSCREEN);
        }
        if (cropEndOnChart) {
            drawFlagAfter(canvas, mCropEndData, mFlagMeasurements, mFlagMeasurements.boxEnd, true);
        } else {
            mCropEndData.labelRect.set(OFFSCREEN, OFFSCREEN, OFFSCREEN, OFFSCREEN);
        }

        // Neither flag can be drawn, but we might be in a region that can be cropped out
        // so the whole thing should be colored grey.
        if (!cropEndOnChart && !cropStartOnChart) {
            if (mCropStartData.timestamp > mExternalAxis.mXMax
                    || mCropEndData.timestamp < mExternalAxis.mXMin) {
                canvas.drawRect(mChartMarginLeft, mHeight - mChartHeight - mPaddingBottom,
                        mWidth - mChartMarginRight, mHeight, mCropBackgroundPaint);
            }
        }
    } else {
        boolean xOnChart = isXScreenPointInChart(mPointData.screenPoint);
        boolean yOnChart = isYScreenPointInChart(mPointData.screenPoint);
        if (xOnChart && yOnChart) {
            // We are not cropping. Draw a standard flag.
            drawFlag(canvas, mPointData, mFlagMeasurements, false);

            // Draw the vertical line from the point to the bottom of the flag
            float nudge = mDotRadius / 2;
            float cy = mHeight - mChartHeight - mPaddingBottom + mPointData.screenPoint.y
                    - 2 * mDotBackgroundRadius + nudge;
            mPath.reset();
            mPath.moveTo(mPointData.screenPoint.x, mFlagMeasurements.notchBottom);
            mPath.lineTo(mPointData.screenPoint.x, cy);
            canvas.drawPath(mPath, mLinePaint);

            // Draw the selected point
            float cySmall = cy + 1.5f * mDotBackgroundRadius;
            canvas.drawCircle(mPointData.screenPoint.x, cySmall, mDotBackgroundRadius, mDotBackgroundPaint);
            canvas.drawCircle(mPointData.screenPoint.x, cySmall, mDotRadius, mDotPaint);
        } else {
            mPointData.labelRect.set(OFFSCREEN, OFFSCREEN, OFFSCREEN, OFFSCREEN);
        }
    }
}

From source file:com.am.pagergradienttab.view.PagerGradientTabStrip.java

/**
 * Tab/*from  w w w. ja  v a2 s .co m*/
 * 
 * @param canvas
 */
private void drawTabBG(Canvas canvas) {
    if (showTabColor) {
        mTextPaint.setColor(tabColorNormal);
        canvas.save();
        canvas.translate(getPaddingLeft(), 0);
        if (tabs.size() > 0)
            for (int i = 0; i < tabs.size(); i++) {
                if (i == nextPager) {
                    mTextPaint.setColor(getColor(tabColorNormal, tabColorSelected, textSizeOffset));
                } else if (i == currectPager) {
                    mTextPaint.setColor(getColor(tabColorNormal, tabColorSelected, 1 - textSizeOffset));
                } else {
                    mTextPaint.setColor(tabColorNormal);
                }
                canvas.drawRect(0, getPaddingTop(), itemWidth, getHeight() - getPaddingBottom(), mTextPaint);
                canvas.translate(itemWidth + intervalWidth, 0);
            }
        else {
            mTextPaint.setColor(tabColorSelected);
            canvas.drawRect(0, getPaddingTop(), itemWidth + intervalWidth + getPaddingLeft(),
                    getHeight() - getPaddingBottom(), mTextPaint);
        }
        canvas.restore();
    }
}

From source file:com.example.accessibility.FeedbackClickView.java

public void onDraw(Canvas canvas) {

    int right = getWidth() - getPaddingRight();
    int bottom = getHeight() - getPaddingBottom();

    //Scroll buttons are drawn in the different scrollable areas.
    scrollableAreas = getScrollableAreas();
    for (int i = 0; i < scrollableAreas.size(); i++) {
        if (scrollableAreas.get(i) == null) {
            Log.w("prints", "LV: scrollable es null");
        }/*from w w  w .  j a  v a 2  s . c  om*/

        else {
            scrollableAreas.get(i).getBoundsInScreen(outBounds);
            if ((outBounds.right > right - 90) && (outBounds.bottom > bottom - 90)) {
                //If the scroll button is over home button, we draw it in another position.
                canvas.drawRect(outBounds.right - 80, bottom - 180, outBounds.right, bottom - 100, paintWhite);
                a.set(outBounds.right - 50, bottom - 130);
                b.set(outBounds.right - 30, bottom - 130);
                c.set(outBounds.right - 30, bottom - 150);
                d.set(outBounds.right - 10, bottom - 140);
                e.set(outBounds.right - 40, bottom - 110);
                f.set(outBounds.right - 50, bottom - 150);
                g.set(outBounds.right - 40, bottom - 170);
                h.set(outBounds.right - 70, bottom - 140);
                path1.moveTo(a.x, a.y);
                path1.lineTo(f.x, f.y);
                path1.moveTo(f.x, f.y);
                path1.lineTo(c.x, c.y);
                path1.moveTo(c.x, c.y);
                path1.lineTo(g.x, g.y);
                path1.moveTo(g.x, g.y);
                path1.lineTo(f.x, f.y);
                path1.moveTo(f.x, f.y);
                path1.lineTo(h.x, h.y);
                path1.moveTo(h.x, h.y);
                path1.lineTo(a.x, a.y);
                path1.moveTo(a.x, a.y);
                path1.lineTo(b.x, b.y);
                path1.lineTo(c.x, c.y);
                path1.lineTo(d.x, d.y);
                path1.lineTo(b.x, b.y);
                path1.lineTo(e.x, e.y);
                path1.lineTo(a.x, a.y);
                path1.close();
                canvas.drawPath(path1, paintBlack);
            } else {
                canvas.drawRect(outBounds.right - 80, outBounds.bottom - 80, outBounds.right, outBounds.bottom,
                        paintWhite);
                a.set(outBounds.right - 50, outBounds.bottom - 30);
                b.set(outBounds.right - 30, outBounds.bottom - 30);
                c.set(outBounds.right - 30, outBounds.bottom - 50);
                d.set(outBounds.right - 10, outBounds.bottom - 40);
                e.set(outBounds.right - 40, outBounds.bottom - 10);
                f.set(outBounds.right - 50, outBounds.bottom - 50);
                g.set(outBounds.right - 40, outBounds.bottom - 70);
                h.set(outBounds.right - 70, outBounds.bottom - 40);
                path1.moveTo(a.x, a.y);
                path1.lineTo(f.x, f.y);
                path1.moveTo(f.x, f.y);
                path1.lineTo(c.x, c.y);
                path1.moveTo(c.x, c.y);
                path1.lineTo(g.x, g.y);
                path1.moveTo(g.x, g.y);
                path1.lineTo(f.x, f.y);
                path1.moveTo(f.x, f.y);
                path1.lineTo(h.x, h.y);
                path1.moveTo(h.x, h.y);
                path1.lineTo(a.x, a.y);
                path1.moveTo(a.x, a.y);
                path1.lineTo(b.x, b.y);
                path1.lineTo(c.x, c.y);
                path1.lineTo(d.x, d.y);
                path1.lineTo(b.x, b.y);
                path1.lineTo(e.x, e.y);
                path1.lineTo(a.x, a.y);
                path1.close();
                canvas.drawPath(path1, paintBlack);
            }
            canvas.drawRect(outBounds.left, outBounds.top, outBounds.left + 80, outBounds.top + 80, paintWhite);
            a.set(outBounds.left + 30, outBounds.top + 50);
            b.set(outBounds.left + 50, outBounds.top + 50);
            c.set(outBounds.left + 50, outBounds.top + 30);
            d.set(outBounds.left + 70, outBounds.top + 40);
            e.set(outBounds.left + 40, outBounds.top + 70);
            f.set(outBounds.left + 30, outBounds.top + 30);
            g.set(outBounds.left + 40, outBounds.top + 10);
            h.set(outBounds.left + 10, outBounds.top + 40);
            path.moveTo(a.x, a.y);
            path.lineTo(b.x, b.y);
            path.moveTo(b.x, b.y);
            path.lineTo(c.x, c.y);
            path.moveTo(c.x, c.y);
            path.lineTo(d.x, d.y);
            path.moveTo(d.x, d.y);
            path.lineTo(b.x, b.y);
            path.moveTo(b.x, b.y);
            path.lineTo(e.x, e.y);
            path.moveTo(e.x, e.y);
            path.lineTo(a.x, a.y);
            path.moveTo(a.x, a.y);
            path.lineTo(f.x, f.y);
            path.lineTo(c.x, c.y);
            path.lineTo(g.x, g.y);
            path.lineTo(f.x, f.y);
            path.lineTo(h.x, h.y);
            path.lineTo(a.x, a.y);
            path.close();
            canvas.drawPath(path, paintBlack);

        }
    }

    //Home contexual menu
    if (getMenuContextual().equals("home")) {

        //Two yellow squares that represent menu options
        canvas.drawRect(right / 2 - 120, bottom / 2 - 260, right / 2 + 120, bottom / 2 - 20, mYellow);
        canvas.drawRect(right / 2 - 120, bottom / 2 + 20, right / 2 + 120, bottom / 2 + 260, mYellow);

        //House that represents Home option
        canvas.drawRect(right / 2 - 90, bottom / 2 - 130, right / 2 + 90, bottom / 2 - 50, mBlack);
        a.set(right / 2 - 90, bottom / 2 - 130);
        b.set(right / 2 + 90, bottom / 2 - 130);
        c.set(right / 2, bottom / 2 - 230);
        path.moveTo(a.x, a.y);
        path.lineTo(b.x, b.y);
        path.lineTo(c.x, c.y);
        path.lineTo(a.x, a.y);
        path.close();
        canvas.drawPath(path, mBlack);

        //Arrow that represents click option
        a.set(right / 2 - 90, bottom / 2 + 50);
        b.set(right / 2 - 75, bottom / 2 + 170);
        c.set(right / 2 + 30, bottom / 2 + 65);
        path.moveTo(a.x, a.y);
        path.lineTo(b.x, b.y);
        path.lineTo(c.x, c.y);
        path.lineTo(a.x, a.y);
        path.close();
        canvas.drawPath(path, mBlack);

        a.set(right / 2 - 30, bottom / 2 + 110);
        b.set(right / 2 + 90, bottom / 2 + 230);
        path.moveTo(a.x, a.y);
        path.lineTo(b.x, b.y);
        path.close();
        canvas.drawPath(path, mBlack);
    }

    //Scroll backward contextual menu
    if (getMenuContextual().equals("scrollbackward")) {
        Log.i("prints", "scroll backward contextual menu");
        //Two yellow squares that represent menu options
        canvas.drawRect(right / 2 - 120, bottom / 2 - 260, right / 2 + 120, bottom / 2 - 20, mYellow);
        canvas.drawRect(right / 2 - 120, bottom / 2 + 20, right / 2 + 120, bottom / 2 + 260, mYellow);

        //Picture that represents scroll backward option
        a.set(right / 2 - 30, bottom / 2 - 110);
        b.set(right / 2 + 30, bottom / 2 - 110);
        c.set(right / 2 + 30, bottom / 2 - 170);
        d.set(right / 2 + 90, bottom / 2 - 140);
        e.set(right / 2, bottom / 2 - 50);
        f.set(right / 2 - 30, bottom / 2 - 170);
        g.set(right / 2, bottom / 2 - 230);
        h.set(right / 2 - 90, bottom / 2 - 140);
        path.moveTo(a.x, a.y);
        path.lineTo(b.x, b.y);
        path.moveTo(b.x, b.y);
        path.lineTo(c.x, c.y);
        path.moveTo(c.x, c.y);
        path.lineTo(d.x, d.y);
        path.moveTo(d.x, d.y);
        path.lineTo(b.x, b.y);
        path.moveTo(b.x, b.y);
        path.lineTo(e.x, e.y);
        path.moveTo(e.x, e.y);
        path.lineTo(a.x, a.y);
        path.moveTo(a.x, a.y);
        path.lineTo(f.x, f.y);
        path.lineTo(c.x, c.y);
        path.lineTo(g.x, g.y);
        path.lineTo(f.x, f.y);
        path.lineTo(h.x, h.y);
        path.lineTo(a.x, a.y);
        path.close();
        canvas.drawPath(path, paintBlack);

        //Arrow that represents click option
        a.set(right / 2 - 90, bottom / 2 + 50);
        b.set(right / 2 - 75, bottom / 2 + 170);
        c.set(right / 2 + 30, bottom / 2 + 65);
        path.moveTo(a.x, a.y);
        path.lineTo(b.x, b.y);
        path.lineTo(c.x, c.y);
        path.lineTo(a.x, a.y);
        path.close();
        canvas.drawPath(path, mBlack);

        a.set(right / 2 - 30, bottom / 2 + 110);
        b.set(right / 2 + 90, bottom / 2 + 230);
        path.moveTo(a.x, a.y);
        path.lineTo(b.x, b.y);
        path.close();
        canvas.drawPath(path, mBlack);

    }
    if (getMenuContextual().equals("scrollforward")) {
        Log.i("prints", "scroll backward contextual menu");

        //Two yellow squares that represent menu options
        canvas.drawRect(right / 2 - 120, bottom / 2 - 260, right / 2 + 120, bottom / 2 - 20, mYellow);
        canvas.drawRect(right / 2 - 120, bottom / 2 + 20, right / 2 + 120, bottom / 2 + 260, mYellow);

        //Picture that represents scroll backward option
        a.set(right / 2 - 30, bottom / 2 - 110);
        b.set(right / 2 + 30, bottom / 2 - 110);
        c.set(right / 2 + 30, bottom / 2 - 170);
        d.set(right / 2 + 90, bottom / 2 - 140);
        e.set(right / 2, bottom / 2 - 50);
        f.set(right / 2 - 30, bottom / 2 - 170);
        g.set(right / 2, bottom / 2 - 230);
        h.set(right / 2 - 90, bottom / 2 - 140);
        path.moveTo(a.x, a.y);
        path.lineTo(f.x, f.y);
        path.moveTo(f.x, f.y);
        path.lineTo(c.x, c.y);
        path.moveTo(c.x, c.y);
        path.lineTo(g.x, g.y);
        path.moveTo(g.x, g.y);
        path.lineTo(f.x, f.y);
        path.moveTo(f.x, f.y);
        path.lineTo(h.x, h.y);
        path.moveTo(h.x, h.y);
        path.lineTo(a.x, a.y);
        path.moveTo(a.x, a.y);
        path.lineTo(b.x, b.y);
        path.lineTo(c.x, c.y);
        path.lineTo(d.x, d.y);
        path.lineTo(b.x, b.y);
        path.lineTo(e.x, e.y);
        path.lineTo(a.x, a.y);
        path.close();
        canvas.drawPath(path, paintBlack);

        //Arrow that represents click option
        a.set(right / 2 - 90, bottom / 2 + 50);
        b.set(right / 2 - 75, bottom / 2 + 170);
        c.set(right / 2 + 30, bottom / 2 + 65);
        path.moveTo(a.x, a.y);
        path.lineTo(b.x, b.y);
        path.lineTo(c.x, c.y);
        path.lineTo(a.x, a.y);
        path.close();
        canvas.drawPath(path, mBlack);

        a.set(right / 2 - 30, bottom / 2 + 110);
        b.set(right / 2 + 90, bottom / 2 + 230);
        path.moveTo(a.x, a.y);
        path.lineTo(b.x, b.y);
        path.close();
        canvas.drawPath(path, mBlack);

    }
    if (getMenuContextual().equals("back")) {
        Log.i("prints", "scroll backward contextual menu");

        //Two yellow squares that represent menu options
        canvas.drawRect(right / 2 - 120, bottom / 2 - 260, right / 2 + 120, bottom / 2 - 20, mYellow);
        canvas.drawRect(right / 2 - 120, bottom / 2 + 20, right / 2 + 120, bottom / 2 + 260, mYellow);
        paintBlack.setStyle(Paint.Style.STROKE);

        //Arrow that represents back option
        canvas.drawRect(right / 2 - 30, bottom / 2 - 110, right / 2 + 60, bottom / 2 - 110, paintBlack);
        oval.set(right / 2 + 30, bottom / 2 - 170, right / 2 + 90, bottom / 2 - 110);
        canvas.drawArc(oval, 270, 180, true, paintBlack);
        canvas.drawRect(right / 2 - 90, bottom / 2 - 170, right / 2 + 60, bottom / 2 - 170, paintBlack);
        a.set(right / 2 - 60, bottom / 2 - 140);
        b.set(right / 2 - 90, bottom / 2 - 170);
        c.set(right / 2 - 60, bottom / 2 - 200);
        path.moveTo(a.x, a.y);
        path.lineTo(b.x, b.y);
        path.moveTo(b.x, b.y);
        path.lineTo(c.x, c.y);
        canvas.drawPath(path, paintBlack);

        //Arrow that represents click option
        a.set(right / 2 - 90, bottom / 2 + 50);
        b.set(right / 2 - 75, bottom / 2 + 170);
        c.set(right / 2 + 30, bottom / 2 + 65);
        path.moveTo(a.x, a.y);
        path.lineTo(b.x, b.y);
        path.lineTo(c.x, c.y);
        path.lineTo(a.x, a.y);
        path.close();
        canvas.drawPath(path, mBlack);

        a.set(right / 2 - 30, bottom / 2 + 110);
        b.set(right / 2 + 90, bottom / 2 + 230);
        path.moveTo(a.x, a.y);
        path.lineTo(b.x, b.y);
        path.close();
        canvas.drawPath(path, mBlack);

    }

    else if (mButton.equals("clear")) {
        //Log.i("prints","clear");
    }

    if (posy < 100) {
        oval.set(getX() - 50, getY() + 20, getX() + 50, getY() + 120);
    } else {
        oval.set(getX() - 50, getY() - 120, getX() + 50, getY() - 20);
    }

    canvas.drawArc(oval, 270, getDegr(), true, mGreen);

}