Example usage for android.graphics Canvas save

List of usage examples for android.graphics Canvas save

Introduction

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

Prototype

public int save() 

Source Link

Document

Saves the current matrix and clip onto a private stack.

Usage

From source file:com.lt.adamlee.aagame.GameView.java

public void onDraw(Canvas c) {
    try {/*from www. j a  va  2s . c om*/
        if (mainpage == -1) {
            this.eg.exitdialog(c);
        }
        if (mainpage == 1) {
            if (bak2) {
                internalcounter2++;
                if (internalcounter2 % 10 == 0) {
                    counter1234++;
                }
                if (counter1234 >= 2) {
                    counter1234 = 0;
                    internalcounter2 = 0;
                    bak2 = false;
                }
            }
            if (bak4) {
                this.internalcounter4++;
                if (this.internalcounter4 % 10 == 0) {
                    this.counter12346++;
                }
                if (this.counter12346 >= 2) {
                    this.counter12346 = 0;
                    this.internalcounter4 = 0;
                    bak4 = false;
                }
            }
            c.drawBitmap(this.mainpageimage, 0.0f, 0.0f, null);
            c.drawBitmap(this.play, F.wf(110.0f), F.hf(175.0f), null);
            c.drawBitmap(this.moreapps, F.wf(45.0f), F.hf(340.0f), null);
            c.drawBitmap(this.help, F.wf(130.0f), F.hf(340.0f), null);
            c.drawBitmap(this.leaderboard, F.wf(215.0f), F.hf(340.0f), null);
        }
        if (mainpage == 5) {
            help(c);
        }
        if (mainpage == 6) {
            this.anim.levelanim(c);
        }
        if (mainpage == 7) {
            if (this.bakc) {
                this.internalcounterc++;
                if (this.internalcounterc % 10 == 0) {
                    this.counterc++;
                }
                if (this.counterc >= 2) {
                    this.counterc = 0;
                    this.internalcounterc = 0;
                    this.bakc = false;
                }
            }
            this.level.Level_Canvas(c);
        }
        if (mainpage == 3) {
            float[] fArr;
            if (baka) {
                this.internalcountera++;
                if (this.internalcountera % 10 == 0) {
                    this.countera++;
                }
                if (this.countera >= 2) {
                    this.countera = 0;
                    this.internalcountera = 0;
                    baka = false;
                }
            }
            view.drawRectangle(c);
            if (levelcounter % 3 == 0) {
                if (rotation[0] <= 0.0f && rotation[0] <= 0.0f) {
                    changeangle = 2.0d;
                }
                if (rotation[0] > 0.0f && rotation[0] >= 360.0f) {
                    changeangle = -2.0d;
                }
            }
            if (levelcounter % 3 == 1) {
                changeangle = 2.0d;
            }
            if (levelcounter % 3 == 2) {
                changeangle = -2.0d;
            }
            x = (int) F.wf(160.0f);
            y = (int) F.hf(159.0f);
            r = (int) F.wf(10.0f);
            int i = 0;
            while (i < blinedraw.length) {
                if (blinedraw[i]) {
                    c.save();
                    c.rotate(rotation[i], (float) (screenW / 2), F.hf(272.0f));
                    c.drawLine((float) (screenW / 2), F.hf(272.0f), (float) (screenW / 2),
                            F.hf(272.0f) - F.hf(105.0f), paint4);
                    c.drawCircle((float) x, (float) y, (float) r, paint3);
                    c.drawBitmap(this.cartoonbomb,
                            new Rect(0, 0, this.cartoonbomb.getWidth(), this.cartoonbomb.getHeight()),
                            new Rect(x - (this.cartoonbomb.getWidth() / 2),
                                    y - (this.cartoonbomb.getHeight() / 2),
                                    x + (this.cartoonbomb.getWidth() / 2),
                                    y + (this.cartoonbomb.getHeight() / 2)),
                            null);
                    if (i >= saveline) {
                        c.drawText((Circle.var - (i - saveline) + ""), (float) x, (float) ((int) F.hf(163.0f)),
                                this.innercircletext);
                    }
                    savex[i] = x;
                    savey[i] = y;
                    if (changeangle > 0.0d && rotation[i] >= 360.0f) {
                        rotation[i] = 0.0f;
                    }
                    if (changeangle < 0.0d && rotation[i] <= -360.0f) {
                        rotation[i] = 0.0f;
                    }
                    if (!(errorcircle || !GameActivity.isResume || circleblink)) {
                        fArr = rotation;
                        fArr[i] = (float) (((double) fArr[i]) + changeangle);
                    }
                    c.restore();
                    if (circleblink) {
                        holdcounter++;
                        if (holdcounter > 32000) {
                            holdcounter = 0;
                        }
                        if (holdcounter % 5 == 0) {
                            hcm++;
                        }
                        if (hcm > 32000) {
                            hcm = 0;
                        }
                        if (hcm <= 9) {
                            h = (int) F.wf(160.0f);
                            j = (int) F.hf(159.0f);
                            k = (int) F.wf(11.0f);
                            paint7.setAlpha(a1);
                            paint7.setColor(SupportMenu.CATEGORY_MASK);
                            paint7.setAntiAlias(true);
                            paint7.setFilterBitmap(true);
                            paint7.setStrokeWidth(2.0f);
                            c.drawCircle((float) h, (float) j, (float) k, paint7);
                            c.drawCircle((float) x, (float) y, (float) r, paint3);
                            if (i >= saveline) {
                                c.drawText((Circle.var - (i - saveline) + ""), (float) x,
                                        (float) ((int) F.hf(163.0f)), this.innercircletext);
                            }
                        }
                        if (hcm >= 11) {
                            circleblink = false;
                            mainpage = 6;
                            //                                GameActivity.vimapad.isBottomAdVisible(true);
                            //                                GameActivity.vimapad.isTopAdVisible(true);
                            holdcounter = 0;
                            hcm = 0;
                        }
                    }
                }
                i++;
            }
            i = 0;
            while (i < circledrawboolean.length) {
                if (circledrawboolean[i]) {
                    c.save();
                    c.rotate(rotation[i], (float) (screenW / 2), F.hf(272.0f));
                    c.drawLine((float) (screenW / 2), F.hf(272.0f), (float) (screenW / 2),
                            F.hf(272.0f) - F.hf(105.0f), paint4);
                    c.drawCircle((float) x, (float) y, (float) r, paint3);
                    if (i >= saveline) {
                        c.drawText((Circle.var - (i - saveline) + ""), (float) x, (float) ((int) F.hf(163.0f)),
                                this.innercircletext);
                    }
                    savex[i] = x;
                    savey[i] = y;
                    if (changeangle > 0.0d && rotation[i] >= 360.0f) {
                        rotation[i] = 0.0f;
                    }
                    if (changeangle < 0.0d && rotation[i] <= -360.0f) {
                        rotation[i] = 0.0f;
                    }
                    if (!(errorcircle || !GameActivity.isResume || circleblink)) {
                        fArr = rotation;
                        fArr[i] = (float) (((double) fArr[i]) + changeangle);
                    }
                    c.restore();
                    if (colcircle) {
                        this.displaycount3++;
                        textdisplayboolean = false;
                        if (this.displaycount3 <= 70
                                || (this.displaycount3 >= 80 && this.displaycount3 <= 90)) {
                            paint6.setAntiAlias(true);
                        }
                        paint6.setFilterBitmap(true);
                        paint6.setColor(ViewCompat.MEASURED_STATE_MASK);
                        c.drawCircle((float) (screenW / 2), F.hf(272.0f), F.wf(39.0f), paint6);
                        paint6.setColor(SupportMenu.CATEGORY_MASK);
                        paint6.setAntiAlias(true);
                        paint6.setFilterBitmap(true);
                        paint6.setTypeface(tf);
                        paint6.setAlpha(Circle.a);
                        paint6.setTextAlign(Paint.Align.CENTER);
                        c.drawText(String.valueOf(levelcounter), F.wf(160.0f), F.hf(278.0f), paint6);
                        paint6.setColor(getResources().getColor(R.color.common_signin_btn_default_background));
                        paint6.setAlpha(20);
                        paint6.setAntiAlias(true);
                        paint6.setFilterBitmap(true);
                        c.drawRect(0.0f, 0.0f, (float) screenW, (float) screenH, paint6);
                        if (this.displaycount3 <= 70 || this.displaycount3 >= 80) {
                        }
                        if (this.displaycount3 > 90) {
                            int j;
                            this.displaycount3 = 0;
                            colcircle = false;
                            circleblink = false;
                            bak4 = true;
                            reset();
                            levelcounter++;
                            errorcircle = false;
                            linecounter = NoOfInitialLines - 1;
                            for (j = 0; j < NoOfInitialLines; j++) {
                                blinedraw[j] = true;
                            }
                            for (j = 0; j < rotation.length; j++) {
                                rotation[j] = 0.0f;
                            }
                            for (j = 0; j < NoOfInitialLines; j++) {
                                rotation[j] = (float) ((j + 1) * (360 / NoOfInitialLines));
                                if (rotation[j] > 360.0f) {
                                    rotation[j] = rotation[j] - 360.0f;
                                }
                            }
                        }
                    }
                }
                i++;
            }
            this.paint21.setColor(-1);
            this.paint21.setTypeface(tf);
            this.paint21.setTextAlign(Paint.Align.CENTER);
            this.paint21.setAntiAlias(true);
            this.paint21.setFilterBitmap(true);
            if (textdisplayboolean) {
                c.drawText(String.valueOf(levelcounter), F.wf(160.0f), F.hf(278.0f), this.paint21);
            }
        }
    } catch (Exception e) {
    }
}

From source file:com.wb.launcher3.Page.java

@Override
protected void dispatchDraw(Canvas canvas) {
    int halfScreenSize = getViewportWidth() / 2;
    // mOverScrollX is equal to getScrollX() when we're within the normal scroll range.
    // Otherwise it is equal to the scaled overscroll position.
    int screenCenter = mOverScrollX + halfScreenSize;

    if (screenCenter != mLastScreenCenter || mForceScreenScrolled) {
        // set mForceScreenScrolled before calling screenScrolled so that screenScrolled can
        // set it for the next frame
        mForceScreenScrolled = false;//www .j  a  v a2  s .  c om
        screenScrolled(screenCenter);
        mLastScreenCenter = screenCenter;
    }

    // Find out which screens are visible; as an optimization we only call draw on them
    final int pageCount = getChildCount();
    if (pageCount > 0) {
        //*/Modified by tyd Greg 2014-03-20,for transition effect
        boolean allowed = true;
        Workspace workspace = null;
        if (this instanceof Workspace) {
            workspace = (Workspace) this;
            allowed = !workspace.isSmall();
        }
        if (TydtechConfig.TYDTECH_DEBUG_FLAG) {
            Log.d("Greg", "allowed: " + allowed);
        }
        /*/
        if(!allowed || !TydtechConfig.TRANSITION_EFFECT_ENABLED){
        getVisiblePages(mTempVisiblePagesRange);
        }else{
        getVisiblePagesExt(mTempVisiblePagesRange);
        }
        //*/
        getVisiblePages(mTempVisiblePagesRange);
        //*/
        final int leftScreen = mTempVisiblePagesRange[0];
        final int rightScreen = mTempVisiblePagesRange[1];
        if (leftScreen != -1 && rightScreen != -1) {
            final long drawingTime = getDrawingTime();
            // Clip to the bounds
            canvas.save();
            canvas.clipRect(getScrollX(), getScrollY(), getScrollX() + getRight() - getLeft(),
                    getScrollY() + getBottom() - getTop());

            // Draw all the children, leaving the drag view for last
            for (int i = pageCount - 1; i >= 0; i--) {
                final View v = getPageAt(i);
                if (v == mDragView)
                    continue;
                if (mForceDrawAllChildrenNextFrame
                        || (leftScreen <= i && i <= rightScreen && shouldDrawChild(v))) {
                    drawChild(canvas, v, drawingTime);
                }
            }
            // Draw the drag view on top (if there is one)
            if (mDragView != null) {
                drawChild(canvas, mDragView, drawingTime);
            }

            mForceDrawAllChildrenNextFrame = false;
            canvas.restore();
        }

        //*/Added by TYD Theobald_Wu on 20130223 [begin] for cycle rolling pages
        if (TydtechConfig.CYCLE_ROLL_PAGES_ENABLED && allowed) {
            canvas.save();
            int width = 0;
            final int pageW = getViewportWidth();
            View v = null;
            int scrollOffset = (pageW - getChildWidth(0)) / 2;
            if (mOverScrollX < 0) {
                int index = pageCount - 1;
                v = getPageAt(index);
                width = getViewportOffsetX() - scrollOffset - v.getWidth();
            } else if (mOverScrollX > mMaxScrollX) {
                v = getPageAt(0);
                width = getViewportOffsetX() + pageW * pageCount + scrollOffset;
            }
            if (TydtechConfig.TYDTECH_DEBUG_FLAG) {
                Log.d("Greg", "width: " + width);
                Log.d("Greg", "mOverScrollX: " + mOverScrollX);
            }
            if (v != null) {
                canvas.translate(width, v.getY());
                canvas.concat(v.getMatrix());
                final int w = v.getWidth();
                final int h = v.getHeight();
                final int sx = v.getScrollX();
                final int sy = v.getScrollY();
                Rect rect = new Rect(sx, sy, sx + w, sy + h);
                ///* zhangwuba mark this, user verison lead to screen flash 2014-5-12
                //canvas.saveLayerAlpha(sx, sy, sx + w, sy + h, (int) (v.getAlpha() * 255),
                //  Canvas.HAS_ALPHA_LAYER_SAVE_FLAG | Canvas.CLIP_TO_LAYER_SAVE_FLAG);
                //*/
                v.draw(canvas);
            }
            canvas.restore();
        }
        //*/
    }
}

From source file:com.cssweb.android.view.FTrendView.java

public void drawChart(Canvas canvas) throws JSONException {
    paint = new Paint(Paint.ANTI_ALIAS_FLAG); //
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(1);/*www .ja  v  a2 s  .c om*/
    tPaint = new Paint();
    tPaint.setStyle(Paint.Style.STROKE);
    tPaint.setTypeface(Typeface.DEFAULT_BOLD);
    tPaint.setAntiAlias(true); //
    dataPaint = new Paint(Paint.ANTI_ALIAS_FLAG); //
    dataPaint.setStyle(Paint.Style.STROKE);
    dataPaint.setStrokeWidth(3);
    tPaint.setTextSize(dTextSize);
    axisLabelHeight = Font.getFontHeight(dTextSize);
    axisLabelWidth = (int) tPaint.measureText("0.00000") + offSet;
    klineWidth = width - axisLabelWidth;
    klineHeight = height - axisLabelHeight * 2 - iSLowerScreen;
    klineX = axisLabelWidth;
    klineY = axisLabelHeight;

    SPACE = Arith.div(klineWidth, count); //klineWidth/count;
    scale = klineHeight / (highPrice - lowPrice); //
    double ratio = (highPrice - lowPrice) / rowNum; //
    rowHeight = klineHeight / rowNum;
    colWeight = klineWidth / colNum;
    tPaint.setColor(GlobalColor.colorLabelName);
    tPaint.setTextAlign(Paint.Align.LEFT);

    /**
     * 
     */
    canvas.drawText(":" + quoteData.getJSONArray(isTrackNumber).getString(0), axisLabelWidth,
            axisLabelHeight - 5, tPaint);
    canvas.drawText(":" + quoteData.getJSONArray(isTrackNumber).getDouble(3), axisLabelWidth + width / 2,
            axisLabelHeight - 5, tPaint);
    paint.setColor(GlobalColor.clrGrayLine);
    /**
     * 
     */

    tPaint.setTextAlign(Paint.Align.RIGHT);
    for (int i = 0; i <= rowNum; i++) {
        if (i == 0 || i == rowNum) {
            canvas.drawLine(klineX, klineY + rowHeight * i, klineX + klineWidth, klineY + rowHeight * i, paint);
        } else {
            Graphics.drawDashline(canvas, klineX, klineY + rowHeight * i, klineX + klineWidth,
                    klineY + rowHeight * i, paint);
        }
        if (i == 0) {
            canvas.drawText(Utils.dataFormation(highPrice, 3), klineX,
                    klineY + rowHeight * i + axisLabelHeight / 2, tPaint);
        } else if (i == rowNum) {
            canvas.drawText(Utils.dataFormation(lowPrice, 3), klineX, klineY + rowHeight * i, tPaint);
        } else {
            double AxisLabelPrice = highPrice - ratio * i;
            canvas.drawText(Utils.dataFormation(AxisLabelPrice, 3), klineX,
                    klineY + rowHeight * i + axisLabelHeight / 2, tPaint);
        }
    }
    /**
     * 
     */
    for (int i = 0; i <= colNum; i++) {
        if (i == 0) {
            canvas.drawLine(klineX, klineY, klineX, klineY + klineHeight, paint);
        } else if (i == colNum) {
            canvas.drawLine(width - 1, klineY, width - 1, klineY + klineHeight, paint);
        } else {
            Graphics.drawDashline(canvas, klineX + colWeight * i, klineY, klineX + colWeight * i,
                    klineY + klineHeight, paint);
        }
    }

    /**
     * ?
     */
    double x1 = 0;
    double y1 = 0;
    double x2 = 0;
    double y2 = 0;
    double temp = 0;
    double tHeight = 0;
    dataPaint.setColor(GlobalColor.colorStockName);
    dataPaint.setStrokeWidth(3);
    for (int i = begin; i < (begin + count); i++) {
        temp = quoteData.getJSONArray(i).getDouble(3);
        if (i - begin == 0) {
            x1 = klineX + SPACE * (i - begin);
            x2 = klineX + SPACE * (i - begin + 1);
            tHeight = (temp - lowPrice) * scale; // tHeight = ( - ) *  
            y1 = axisLabelHeight + klineHeight - tHeight; //  - tHeight 
            y2 = axisLabelHeight + klineHeight - tHeight;
        } else {
            canvas.drawLine((int) x1, (int) y1, (int) x2, (int) y2, dataPaint);
            x1 = x2;
            x2 = klineX + SPACE * (i - begin + 1);
            tHeight = (temp - lowPrice) * scale;
            y1 = y2;
            y2 = axisLabelHeight + klineHeight - tHeight;
        }
    }
    /**
     * 
     */
    tPaint.setColor(GlobalColor.colorLabelName);
    tPaint.setTextAlign(Paint.Align.LEFT);
    canvas.drawText(quoteData.getJSONArray(begin).getString(0), axisLabelWidth,
            klineHeight + axisLabelHeight * 2 - 5, tPaint);
    canvas.drawText(quoteData.getJSONArray(begin + count - 1).getString(0),
            (float) (width - tPaint.measureText(quoteData.getJSONArray(begin + count - 1).getString(0))),
            klineHeight + axisLabelHeight * 2 - 5, tPaint);

    /**
     * 
     */
    if (isTrackStatus) {
        canvas.save();
        //??
        paint.setColor(GlobalColor.colorLine);
        canvas.drawLine(trackLineV, axisLabelHeight, trackLineV, klineHeight + axisLabelHeight, paint);
        canvas.restore();
    }
}

From source file:android.support.v7.widget.RecyclerView.java

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

    final int count = mItemDecorations.size();
    for (int i = 0; i < count; i++) {
        mItemDecorations.get(i).onDrawOver(c, this);
    }/*w w w  .j av  a 2  s  . c o  m*/

    boolean needsInvalidate = false;
    if (mLeftGlow != null && !mLeftGlow.isFinished()) {
        final int restore = c.save();
        c.rotate(270);
        c.translate(-getHeight() + getPaddingTop(), 0);
        needsInvalidate = mLeftGlow != null && mLeftGlow.draw(c);
        c.restoreToCount(restore);
    }
    if (mTopGlow != null && !mTopGlow.isFinished()) {
        c.translate(getPaddingLeft(), getPaddingTop());
        needsInvalidate |= mTopGlow != null && mTopGlow.draw(c);
    }
    if (mRightGlow != null && !mRightGlow.isFinished()) {
        final int restore = c.save();
        final int width = getWidth();

        c.rotate(90);
        c.translate(-getPaddingTop(), -width);
        needsInvalidate |= mRightGlow != null && mRightGlow.draw(c);
        c.restoreToCount(restore);
    }
    if (mBottomGlow != null && !mBottomGlow.isFinished()) {
        final int restore = c.save();
        c.rotate(180);
        c.translate(-getWidth() + getPaddingLeft(), -getHeight() + getPaddingTop());
        needsInvalidate |= mBottomGlow != null && mBottomGlow.draw(c);
        c.restoreToCount(restore);
    }

    if (needsInvalidate) {
        ViewCompat.postInvalidateOnAnimation(this);
    }
}

From source file:com.example.libwidgettv.bak.AbsListView.java

@Override
public void draw(Canvas canvas) {
    super.draw(canvas);
    if (mFastScroller != null) {
        final int scrollY = getScrollY();
        if (scrollY != 0) {
            // Pin to the top/bottom during overscroll
            int restoreCount = canvas.save();
            canvas.translate(0, (float) scrollY);
            mFastScroller.draw(canvas);//  w ww . j  av a 2  s.  co  m
            canvas.restoreToCount(restoreCount);
        } else {
            mFastScroller.draw(canvas);
        }
    }
}

From source file:com.appunite.list.AbsHorizontalListView.java

@Override
protected void dispatchDraw(Canvas canvas) {
    int saveCount = 0;
    final boolean clipToPadding = mClipToPadding;
    if (clipToPadding) {
        saveCount = canvas.save();
        final int scrollX = getScrollX();
        final int scrollY = getScrollY();
        final int paddingLeft = getPaddingLeft();
        final int paddingTop = getPaddingTop();
        final int paddingRight = getPaddingRight();
        final int paddingBottom = getPaddingBottom();
        final int left = getLeft();
        final int top = getTop();
        final int right = getRight();
        final int bottom = getBottom();
        canvas.clipRect(scrollX + paddingLeft, scrollY + paddingTop, scrollX + right - left - paddingRight,
                scrollY + bottom - top - paddingBottom);
        setClipToPadding(false);//from   w w  w. ja  v a  2 s. c  o  m
    }

    final boolean drawSelectorOnTop = mDrawSelectorOnTop;
    if (!drawSelectorOnTop) {
        drawSelector(canvas);
    }

    super.dispatchDraw(canvas);

    if (drawSelectorOnTop) {
        drawSelector(canvas);
    }

    if (clipToPadding) {
        canvas.restoreToCount(saveCount);
        setClipToPadding(true);
    }
}

From source file:com.skytree.epubtest.BookViewActivity.java

@SuppressLint({ "DrawAllocation", "DrawAllocation" })
@Override/*w ww .  j a  v  a  2  s .c  om*/
protected void onDraw(Canvas canvas) {
    Paint paint = new Paint();

    float sl, sr, st, sb;
    sl = 0;
    sr = this.getWidth();
    float ah = this.arrowHeight; // arrow Height;
    if (this.isArrowDown) {
        st = 0;
        sb = this.getHeight() - ah;
    } else {
        st = ah - 10;
        sb = this.getHeight() - 10;
    }

    Path boxPath = new Path();
    boxPath.addRoundRect(new RectF(sl, st, sr, sb), 20, 20, Path.Direction.CW);

    if (arrowPosition <= arrowHeight * 1.5f) {
        arrowPosition = arrowHeight * 1.5f;
    } else if (arrowPosition >= this.getWidth() - arrowHeight * 1.5f) {
        arrowPosition = this.getWidth() - arrowHeight * 1.5f;
    }

    Path arrowPath = new Path();
    if (isArrowDown) {
        arrowPath.moveTo(arrowPosition, sb + ah);
        arrowPath.lineTo((float) (arrowPosition - ah * 0.75), sb - 10);
        arrowPath.lineTo((float) (arrowPosition + ah * 0.75), sb - 10);
        arrowPath.close();
    } else {
        arrowPath.moveTo(arrowPosition, 0);
        arrowPath.lineTo((float) (arrowPosition - ah * 0.75), ah + 10);
        arrowPath.lineTo((float) (arrowPosition + ah * 0.75), ah + 10);
        arrowPath.close();
    }

    paint.setColor(this.strokeColor);
    paint.setStyle(Paint.Style.FILL);
    boxPath.addPath(arrowPath);
    canvas.drawPath(boxPath, paint);

    paint.setColor(this.boxColor);
    paint.setStyle(Paint.Style.FILL);
    boxPath.addPath(arrowPath);
    canvas.save();
    float sf = 0.995f;
    float ox = (this.getWidth() - (this.getWidth() * sf)) / 2.0f;
    float oy = ((this.getHeight() - arrowHeight) - ((this.getHeight() - arrowHeight) * sf)) / 2.0f;

    canvas.translate(ox, oy);
    canvas.scale(sf, sf);
    canvas.drawPath(boxPath, paint);
    canvas.restore();

    if (layoutChanged) {
        this.recalcLayout();
        layoutChanged = false;
    }
}

From source file:com.appunite.list.AbsHorizontalListView.java

@Override
public void draw(Canvas canvas) {
    super.draw(canvas);
    if (mEdgeGlowLeft != null) {
        final int scrollX = getScrollX();
        boolean needsInvalidate = false;
        if (!mEdgeGlowLeft.isFinished()) {
            final int restoreCount = canvas.save();
            final int topPadding = mListPadding.top + mGlowPaddingTop;
            final int bottomPadding = mListPadding.bottom + mGlowPaddingBottom;
            final int height = getHeight() - topPadding - bottomPadding;

            int edgeX = Math.min(0, scrollX + mFirstPositionDistanceGuess);
            canvas.translate(edgeX, height + topPadding);
            canvas.rotate(-90, 0, 0);/*from www .j a  v a  2s  . c  om*/
            mEdgeGlowLeft.setSize(height, getWidth());
            if (mEdgeGlowLeft.draw(canvas)) {
                needsInvalidate = true;
            }
            canvas.restoreToCount(restoreCount);
        }
        if (!mEdgeGlowRight.isFinished()) {
            final int restoreCount = canvas.save();
            final int topPadding = mListPadding.top + mGlowPaddingTop;
            final int bottomPadding = mListPadding.bottom + mGlowPaddingBottom;
            final int height = getHeight() - topPadding - bottomPadding;
            final int width = getWidth();

            int edgeY = topPadding;
            int edgeX = Math.max(width, scrollX + mLastPositionDistanceGuess);

            canvas.translate(edgeX, edgeY);
            canvas.rotate(90, 0, 0);

            mEdgeGlowRight.setSize(height, width);
            if (mEdgeGlowRight.draw(canvas)) {
                needsInvalidate = true;
            }
            canvas.restoreToCount(restoreCount);
        }
        if (needsInvalidate) {
            invalidate();
        }
    }
}

From source file:com.aliasapps.seq.scroller.TwoWayView.java

private boolean drawEndEdge(Canvas canvas) {
    if (mEndEdge.isFinished()) {
        return false;
    }//from   w w w .j  av a2  s .c  o m

    final int restoreCount = canvas.save();
    final int width = getWidth() - getPaddingLeft() - getPaddingRight();
    final int height = getHeight() - getPaddingTop() - getPaddingBottom();

    if (mIsVertical) {
        canvas.translate(-width, height);
        canvas.rotate(180, width, 0);
    } else {
        canvas.translate(width, 0);
        canvas.rotate(90);
    }

    final boolean needsInvalidate = mEndEdge.draw(canvas);
    canvas.restoreToCount(restoreCount);
    return needsInvalidate;
}

From source file:com.aliasapps.seq.scroller.TwoWayView.java

private boolean drawStartEdge(Canvas canvas) {
    if (mStartEdge.isFinished()) {
        return false;
    }//from  w  w  w . j a v  a2  s. com

    if (mIsVertical) {
        return mStartEdge.draw(canvas);
    }

    final int restoreCount = canvas.save();
    final int height = getHeight() - getPaddingTop() - getPaddingBottom();

    canvas.translate(0, height);
    canvas.rotate(270);

    final boolean needsInvalidate = mStartEdge.draw(canvas);
    canvas.restoreToCount(restoreCount);
    return needsInvalidate;
}