當前位置: 首頁>>代碼示例>>Java>>正文


Java Canvas.restoreToCount方法代碼示例

本文整理匯總了Java中android.graphics.Canvas.restoreToCount方法的典型用法代碼示例。如果您正苦於以下問題:Java Canvas.restoreToCount方法的具體用法?Java Canvas.restoreToCount怎麽用?Java Canvas.restoreToCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.Canvas的用法示例。


在下文中一共展示了Canvas.restoreToCount方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void draw(Canvas canvas, Rect bounds) {
    int saveCount = canvas.save();
    RectF arcBounds = mCurrentBounds;
    arcBounds.set(bounds);

    mPaint.setColor(mBottomColor);
    canvas.drawPath(mCurrentBottomWaitPath, mPaint);

    mPaint.setColor(mMiddleColor);
    canvas.drawPath(mCurrentMiddleWaitPath, mPaint);

    mPaint.setColor(mTopColor);
    canvas.drawPath(mCurrentTopWaitPath, mPaint);

    canvas.restoreToCount(saveCount);
}
 
開發者ID:ZhuoKeTeam,項目名稱:JueDiQiuSheng,代碼行數:18,代碼來源:CoolWaitLoadingRenderer.java

示例2: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
    mHasDrawn = true;
    boolean crossFade = mCrossFadeProgress > 0 && mCrossFadeBitmap != null;
    if (crossFade) {
        int alpha = crossFade ? (int) (255 * (1 - mCrossFadeProgress)) : 255;
        mPaint.setAlpha(alpha);
    }
    canvas.drawBitmap(mBitmap, 0.0f, 0.0f, mPaint);
    if (crossFade) {
        mPaint.setAlpha((int) (255 * mCrossFadeProgress));
        final int saveCount = canvas.save(Canvas.MATRIX_SAVE_FLAG);
        float sX = (mBitmap.getWidth() * 1.0f) / mCrossFadeBitmap.getWidth();
        float sY = (mBitmap.getHeight() * 1.0f) / mCrossFadeBitmap.getHeight();
        canvas.scale(sX, sY);
        canvas.drawBitmap(mCrossFadeBitmap, 0.0f, 0.0f, mPaint);
        canvas.restoreToCount(saveCount);
    }
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:20,代碼來源:DragView.java

示例3: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
  int saveCount = canvas.save();
  canvas.concat(mZoomableController.getTransform());
  try {
    super.onDraw(canvas);
  } catch (Exception e) {
    DraweeController controller = getController();
    if (controller != null && controller instanceof AbstractDraweeController) {
      Object callerContext = ((AbstractDraweeController) controller).getCallerContext();
      if (callerContext != null) {
        throw new RuntimeException(
            String.format("Exception in onDraw, callerContext=%s", callerContext.toString()),
            e);
      }
    }
    throw e;
  }
  canvas.restoreToCount(saveCount);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:ZoomableDraweeView.java

示例4: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
public void draw(Canvas canvas) {
    super.draw(canvas);
    boolean needsInvalidate = false;
    int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == 0 || (overScrollMode == 1 && this.mAdapter != null && this.mAdapter.getCount() > 1)) {
        int restoreCount;
        int height;
        int width;
        if (!this.mLeftEdge.isFinished()) {
            restoreCount = canvas.save();
            height = (getHeight() - getPaddingTop()) - getPaddingBottom();
            width = getWidth();
            canvas.rotate(270.0f);
            canvas.translate((float) ((-height) + getPaddingTop()), this.mFirstOffset * ((float) width));
            this.mLeftEdge.setSize(height, width);
            needsInvalidate = false | this.mLeftEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
        if (!this.mRightEdge.isFinished()) {
            restoreCount = canvas.save();
            width = getWidth();
            height = (getHeight() - getPaddingTop()) - getPaddingBottom();
            canvas.rotate(90.0f);
            canvas.translate((float) (-getPaddingTop()), (-(this.mLastOffset + 1.0f)) * ((float) width));
            this.mRightEdge.setSize(height, width);
            needsInvalidate |= this.mRightEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
    } else {
        this.mLeftEdge.finish();
        this.mRightEdge.finish();
    }
    if (needsInvalidate) {
        ViewCompat.postInvalidateOnAnimation(this);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:37,代碼來源:ViewPager.java

示例5: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
public void draw(Canvas canvas) {
    super.draw(canvas);

    int width = getWidth();
    int height = getHeight();
    if (mInsets != null && mInsetForeground != null) {
        int sc = canvas.save();
        canvas.translate(getScrollX(), getScrollY());

        // Top
        mTempRect.set(0, 0, width, mInsets.top);
        mInsetForeground.setBounds(mTempRect);
        mInsetForeground.draw(canvas);

        // Bottom
        mTempRect.set(0, height - mInsets.bottom, width, height);
        mInsetForeground.setBounds(mTempRect);
        mInsetForeground.draw(canvas);

        // Left
        mTempRect.set(0, mInsets.top, mInsets.left, height - mInsets.bottom);
        mInsetForeground.setBounds(mTempRect);
        mInsetForeground.draw(canvas);

        // Right
        mTempRect.set(width - mInsets.right, mInsets.top, width, height - mInsets.bottom);
        mInsetForeground.setBounds(mTempRect);
        mInsetForeground.draw(canvas);

        canvas.restoreToCount(sc);
    }
}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:34,代碼來源:ScrimInsetsFrameLayout.java

示例6: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
public void draw(Canvas canvas) {
    super.draw(canvas);

    int restorePoint = canvas.save();
    if (mForceShowHint && mForceHint != null)
        canvas.drawText(mForceHint, 0, mForceHint.length(), mTextX, mTextY - mTextPaint.ascent(), this.mTextPaint);

    canvas.restoreToCount(restorePoint);
}
 
開發者ID:MCMrARM,項目名稱:revolution-irc,代碼行數:11,代碼來源:StaticLabelTextInputLayout.java

示例7: getRoundedCornerBitmap

import android.graphics.Canvas; //導入方法依賴的package包/類
public static Bitmap getRoundedCornerBitmap(Context context, @DrawableRes int drawable, int width, int height,
                                                @DrawableRes int backgroundDrawable, float roundPx) {
        Bitmap output = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(output);

        //繪製背景
        Drawable bgDrawable = context.getResources().getDrawable(backgroundDrawable);
        bgDrawable.setBounds(0, 0, width, height);
        bgDrawable.draw(canvas);

        //在背景的上麵繪製圓角圖片
        int offset = (int) (context.getResources().getDisplayMetrics().density * 10);

        final int color = 0xff424242;
        final Paint paint = new Paint();
        final Rect rect = new Rect(offset, offset, width - offset, width - offset);
        final RectF rectF = new RectF(rect);

        paint.setAntiAlias(true);
        int layer = canvas.saveLayer(0, 0, width, height, null, Canvas.ALL_SAVE_FLAG);
        canvas.drawARGB(0, 0, 0, 0);
        paint.setColor(color);
        canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
//        第二個參數為null,表示繪製整個目標圖片
        canvas.drawBitmap(getBitmap(context.getResources().getDrawable(drawable)), null, rect, paint);
        canvas.restoreToCount(layer);

        return output;
    }
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:32,代碼來源:BmpUtil.java

示例8: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
public void draw(Canvas canvas) {
    int width = Util.getScreenWidth(mContext);
    int height = Util.getScreenHeight(mContext);
    mLeft = (width - mCropWidth) / 2;
    mTop = (height - mCropHeight) / 2;
    mRight = (width + mCropWidth) / 2;
    mBottom = (height + mCropHeight) / 2;
    Rect rect = new Rect(mLeft, mTop, mRight, mBottom);
    canvas.drawRect(rect, mLinePaint);
    //左上
    canvas.drawLine(mLeft, mTop, mLeft, mTop + 50, mCornerPaint);
    canvas.drawLine(mLeft - 4, mTop, mLeft + 50, mTop, mCornerPaint);

    //右上
    canvas.drawLine(mRight, mTop, mRight, mTop + 50, mCornerPaint);
    canvas.drawLine(mRight - 50, mTop, mRight + 4, mTop, mCornerPaint);

    //左下
    canvas.drawLine(mLeft, mBottom, mLeft + 50, mBottom, mCornerPaint);
    canvas.drawLine(mLeft, mBottom - 50, mLeft, mBottom + 4, mCornerPaint);

    //右下
    canvas.drawLine(mRight, mBottom, mRight, mBottom - 50, mCornerPaint);
    canvas.drawLine(mRight - 50, mBottom, mRight + 4, mBottom, mCornerPaint);

    int index = canvas.save();
    canvas.clipRect(rect);
    //畫九宮格
    int vAvg = mCropWidth / 3;
    int hAvg = mCropHeight / 3;
    canvas.drawLine(mLeft + vAvg, mTop, mLeft + vAvg, mBottom, mNineLinePaint);
    canvas.drawLine(mLeft + vAvg * 2, mTop, mLeft + vAvg * 2, mBottom, mNineLinePaint);

    canvas.drawLine(mLeft, mTop + hAvg, mRight, mTop + hAvg, mNineLinePaint);
    canvas.drawLine(mLeft, mTop + hAvg * 2, mRight, mTop + hAvg * 2, mNineLinePaint);

    canvas.restoreToCount(index);
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:40,代碼來源:CropDrawable.java

示例9: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void draw(Canvas canvas, Rect bounds) {
    int saveCount = canvas.save();
    RectF arcBounds = mTempBounds;
    arcBounds.set(bounds);

    mPaint.setColor(mColor);

    //calculate fish clip bounds
    //clip the width of the fish need to increase mPathDottedLineSize * 1.2f
    RectF fishRectF = new RectF(mFishHeadPos[0] - mFishWidth / 2.0f - mPathDottedLineSize * 1.2f, mFishHeadPos[1] - mFishHeight / 2.0f,
            mFishHeadPos[0] + mFishWidth / 2.0f + mPathDottedLineSize * 1.2f, mFishHeadPos[1] + mFishHeight / 2.0f);
    Matrix matrix = new Matrix();
    matrix.postRotate(mFishRotateDegrees, fishRectF.centerX(), fishRectF.centerY());
    matrix.mapRect(fishRectF);

    //draw river
    int riverSaveCount = canvas.save();
    mPaint.setStyle(Paint.Style.STROKE);
    canvas.clipRect(fishRectF, Region.Op.DIFFERENCE);
    canvas.drawPath(createRiverPath(arcBounds), mPaint);
    canvas.restoreToCount(riverSaveCount);

    //draw fish
    int fishSaveCount = canvas.save();
    mPaint.setStyle(Paint.Style.FILL);
    canvas.rotate(mFishRotateDegrees, mFishHeadPos[0], mFishHeadPos[1]);
    canvas.clipPath(createFishEyePath(mFishHeadPos[0], mFishHeadPos[1] - mFishHeight * 0.06f), Region.Op.DIFFERENCE);
    canvas.drawPath(createFishPath(mFishHeadPos[0], mFishHeadPos[1]), mPaint);
    canvas.restoreToCount(fishSaveCount);

    canvas.restoreToCount(saveCount);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:34,代碼來源:FishLoadingRenderer.java

示例10: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
public void draw(Canvas canvas) {
    int saveCount = canvas.save();
    if (this.mTextToDraw != null && this.mDrawTitle) {
        boolean drawTexture;
        float ascent;
        float x = this.mCurrentDrawX;
        float y = this.mCurrentDrawY;
        if (!this.mUseTexture || this.mExpandedTitleTexture == null) {
            drawTexture = false;
        } else {
            drawTexture = true;
        }
        float descent;
        if (drawTexture) {
            ascent = this.mTextureAscent * this.mScale;
            descent = this.mTextureDescent * this.mScale;
        } else {
            ascent = this.mTextPaint.ascent() * this.mScale;
            descent = this.mTextPaint.descent() * this.mScale;
        }
        if (drawTexture) {
            y += ascent;
        }
        if (this.mScale != 1.0f) {
            canvas.scale(this.mScale, this.mScale, x, y);
        }
        if (drawTexture) {
            canvas.drawBitmap(this.mExpandedTitleTexture, x, y, this.mTexturePaint);
        } else {
            canvas.drawText(this.mTextToDraw, 0, this.mTextToDraw.length(), x, y, this.mTextPaint);
        }
    }
    canvas.restoreToCount(saveCount);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:35,代碼來源:CollapsingTextHelper.java

示例11: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
public void draw(Canvas canvas) {
    int num = (int) (System.currentTimeMillis() / 50 % 11);
    final int saveCount = canvas.save();
    canvas.translate(0, mOffset);
    Bitmap bitmap = bitmaps.get(num);
    canvas.drawBitmap(bitmap, null, rectF, null);
    canvas.restoreToCount(saveCount);
}
 
開發者ID:838030195,項目名稱:DaiGo,代碼行數:10,代碼來源:PlaneLoadDrawable.java

示例12: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
    if (!mIsAnimatorCancel) {
        final Rect bounds = getBounds();
        final int saveCount = canvas.save();
        canvas.rotate(mRotation * 360, bounds.exactCenterX(), bounds.exactCenterY());
        drawRing(canvas, bounds);
        canvas.restoreToCount(saveCount);
    } else {
        canvas.restore();
    }
}
 
開發者ID:zwmlibs,項目名稱:BookReader-master,代碼行數:13,代碼來源:LoadingView.java

示例13: drawShadow

import android.graphics.Canvas; //導入方法依賴的package包/類
private void drawShadow(Canvas canvas) {
    final float edgeShadowTop = -mCornerRadius - mShadowSize;
    final float inset = mCornerRadius + mInsetShadow + mRawShadowSize / 2;
    final boolean drawHorizontalEdges = mCardBounds.width() - 2 * inset > 0;
    final boolean drawVerticalEdges = mCardBounds.height() - 2 * inset > 0;
    // LT
    int saved = canvas.save();
    canvas.translate(mCardBounds.left + inset, mCardBounds.top + inset);
    canvas.drawPath(mCornerShadowPath, mCornerShadowPaint);
    if (drawHorizontalEdges) {
        canvas.drawRect(0, edgeShadowTop,
                mCardBounds.width() - 2 * inset, -mCornerRadius,
                mEdgeShadowPaint);
    }
    canvas.restoreToCount(saved);
    // RB
    saved = canvas.save();
    canvas.translate(mCardBounds.right - inset, mCardBounds.bottom - inset);
    canvas.rotate(180f);
    canvas.drawPath(mCornerShadowPath, mCornerShadowPaint);
    if (drawHorizontalEdges) {
        canvas.drawRect(0, edgeShadowTop,
                mCardBounds.width() - 2 * inset, -mCornerRadius + mShadowSize,
                mEdgeShadowPaint);
    }
    canvas.restoreToCount(saved);
    // LB
    saved = canvas.save();
    canvas.translate(mCardBounds.left + inset, mCardBounds.bottom - inset);
    canvas.rotate(270f);
    canvas.drawPath(mCornerShadowPath, mCornerShadowPaint);
    if (drawVerticalEdges) {
        canvas.drawRect(0, edgeShadowTop,
                mCardBounds.height() - 2 * inset, -mCornerRadius, mEdgeShadowPaint);
    }
    canvas.restoreToCount(saved);
    // RT
    saved = canvas.save();
    canvas.translate(mCardBounds.right - inset, mCardBounds.top + inset);
    canvas.rotate(90f);
    canvas.drawPath(mCornerShadowPath, mCornerShadowPaint);
    if (drawVerticalEdges) {
        canvas.drawRect(0, edgeShadowTop,
                mCardBounds.height() - 2 * inset, -mCornerRadius, mEdgeShadowPaint);
    }
    canvas.restoreToCount(saved);
}
 
開發者ID:MikaGuraN,項目名稱:HL4A,代碼行數:48,代碼來源:RoundRectDrawableWithShadow.java

示例14: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    final int store = canvas.save();
    //參數修正
    int w = getMeasuredWidth();
    int h = getMeasuredHeight();




    //圓心
    int x = w/2;
    int y = h/2;
    //半徑
    int radius = (Math.min(w,h)-2*padding)/2-internalStrokeWidth/2;//半徑
    //線冒的範圍,默認在roate 為0的位置,之後通過旋轉擺正
    recthead = new RectF(x+radius-internalStrokeWidth/2,y-internalStrokeWidth/2,
            x+radius+internalStrokeWidth/2,y+internalStrokeWidth/2);

    calculatePercentEndColor(pre);
    sweepGradient = new SweepGradient(x,y,colors,dur);
    //旋轉sweepGradient的角度
    Matrix gradientMatrix = new Matrix();
    gradientMatrix.preRotate(roate, x, y);
    sweepGradient.setLocalMatrix(gradientMatrix);

    outpaint.setShader(sweepGradient);


    //繪製背景
    canvas.drawCircle(x,y,radius+internalStrokeWidth/2+padding,bgpaint);

    //繪製外部單元格
    canvas.drawCircle(x,y,radius,outpaint);

    //如果是非dash樣式,線冒會被染色為終點顏色.例如紅色,這裏需要一個半圓蓋著
    if(!dash){
        //為保證旋轉不畫布其他元素生效
        if(pre>0&&pre<1) {
            canvas.save();
            // 繪製開頭的半圓,線冒
            canvas.rotate(roate, x, y);
            canvas.drawArc(recthead, 180, 180, true, startPaint);
            canvas.restore();
        }
        // 繪製結束的半圓,線冒
        if (pre>0&&pre <= 1) {
            //為保證旋轉不畫布其他元素生效
            canvas.save();
            endPaint.setColor(percentEndColor);
            //-1個角度,因為計算後有一定的精度損失
            canvas.rotate(roate+360*pre-1, x, y);
            canvas.drawArc(recthead, 0f, 180f, true, endPaint);
            canvas.restore();
        }


    }

    canvas.restoreToCount(store);

}
 
開發者ID:jiongjiongxia,項目名稱:DashProgress,代碼行數:64,代碼來源:DashProgressCircle.java

示例15: drawShadow

import android.graphics.Canvas; //導入方法依賴的package包/類
private void drawShadow(Canvas canvas) {
    boolean drawHorizontalEdges;
    boolean drawVerticalEdges;
    float edgeShadowTop = (-this.mCornerRadius) - this.mShadowSize;
    float inset = (this.mCornerRadius + ((float) this.mInsetShadow)) + (this.mRawShadowSize / 2.0f);
    if (this.mCardBounds.width() - (2.0f * inset) > 0.0f) {
        drawHorizontalEdges = true;
    } else {
        drawHorizontalEdges = false;
    }
    if (this.mCardBounds.height() - (2.0f * inset) > 0.0f) {
        drawVerticalEdges = true;
    } else {
        drawVerticalEdges = false;
    }
    int saved = canvas.save();
    canvas.translate(this.mCardBounds.left + inset, this.mCardBounds.top + inset);
    canvas.drawPath(this.mCornerShadowPath, this.mCornerShadowPaint);
    if (drawHorizontalEdges) {
        canvas.drawRect(0.0f, edgeShadowTop, this.mCardBounds.width() - (2.0f * inset), -this.mCornerRadius, this.mEdgeShadowPaint);
    }
    canvas.restoreToCount(saved);
    saved = canvas.save();
    canvas.translate(this.mCardBounds.right - inset, this.mCardBounds.bottom - inset);
    canvas.rotate(180.0f);
    canvas.drawPath(this.mCornerShadowPath, this.mCornerShadowPaint);
    if (drawHorizontalEdges) {
        Canvas canvas2 = canvas;
        canvas2.drawRect(0.0f, edgeShadowTop, this.mCardBounds.width() - (2.0f * inset), this.mShadowSize + (-this.mCornerRadius), this.mEdgeShadowPaint);
    }
    canvas.restoreToCount(saved);
    saved = canvas.save();
    canvas.translate(this.mCardBounds.left + inset, this.mCardBounds.bottom - inset);
    canvas.rotate(270.0f);
    canvas.drawPath(this.mCornerShadowPath, this.mCornerShadowPaint);
    if (drawVerticalEdges) {
        canvas.drawRect(0.0f, edgeShadowTop, this.mCardBounds.height() - (2.0f * inset), -this.mCornerRadius, this.mEdgeShadowPaint);
    }
    canvas.restoreToCount(saved);
    saved = canvas.save();
    canvas.translate(this.mCardBounds.right - inset, this.mCardBounds.top + inset);
    canvas.rotate(90.0f);
    canvas.drawPath(this.mCornerShadowPath, this.mCornerShadowPaint);
    if (drawVerticalEdges) {
        canvas.drawRect(0.0f, edgeShadowTop, this.mCardBounds.height() - (2.0f * inset), -this.mCornerRadius, this.mEdgeShadowPaint);
    }
    canvas.restoreToCount(saved);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:49,代碼來源:RoundRectDrawableWithShadow.java


注:本文中的android.graphics.Canvas.restoreToCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。