当前位置: 首页>>代码示例>>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;未经允许,请勿转载。