本文整理汇总了Java中android.graphics.Canvas.restore方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.restore方法的具体用法?Java Canvas.restore怎么用?Java Canvas.restore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Canvas
的用法示例。
在下文中一共展示了Canvas.restore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawSelector
import android.graphics.Canvas; //导入方法依赖的package包/类
public void drawSelector(View content, Canvas canvas, float openPercent) {
if (!mSelectorEnabled) return;
if (mSelectorDrawable != null && mSelectedView != null) {
String tag = (String) mSelectedView.getTag(R.id.selected_view);
if (tag.equals(TAG+"SelectedView")) {
canvas.save();
int left, right, offset;
offset = (int) (mSelectorDrawable.getWidth() * openPercent);
if (mMode == SlidingMenu.LEFT) {
right = content.getLeft();
left = right - offset;
canvas.clipRect(left, 0, right, getHeight());
canvas.drawBitmap(mSelectorDrawable, left, getSelectorTop(), null);
} else if (mMode == SlidingMenu.RIGHT) {
left = content.getRight();
right = left + offset;
canvas.clipRect(left, 0, right, getHeight());
canvas.drawBitmap(mSelectorDrawable, right - mSelectorDrawable.getWidth(), getSelectorTop(), null);
}
canvas.restore();
}
}
}
示例2: drawCurrentPageArea
import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawCurrentPageArea(Canvas canvas, Bitmap bitmap, Path path) {
mPath0.reset();
mPath0.moveTo(mBezierStart1.x, mBezierStart1.y);
mPath0.quadTo(mBezierControl1.x, mBezierControl1.y, mBezierEnd1.x,
mBezierEnd1.y);
mPath0.lineTo(mTouchX, mTouchY);
mPath0.lineTo(mBezierEnd2.x, mBezierEnd2.y);
mPath0.quadTo(mBezierControl2.x, mBezierControl2.y, mBezierStart2.x,
mBezierStart2.y);
mPath0.lineTo(mCornerX, mCornerY);
mPath0.close();
canvas.save();
canvas.clipPath(path, Region.Op.XOR);
canvas.drawBitmap(bitmap, 0, 0, null);
try {
canvas.restore();
} catch (Exception e) {
}
}
示例3: onDrawOver
import android.graphics.Canvas; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
final int count = parent.getChildCount();
for (int layoutPos = 0; layoutPos < count; layoutPos++) {
final View child = parent.getChildAt(translatedChildPosition(parent, layoutPos));
final int adapterPos = parent.getChildAdapterPosition(child);
if (adapterPos != RecyclerView.NO_POSITION && ((layoutPos == 0 && sticky) || hasHeader(parent, adapter, adapterPos))) {
View header = getHeader(parent, adapter, adapterPos).itemView;
c.save();
final int left = child.getLeft();
final int top = getHeaderTop(parent, child, header, adapterPos, layoutPos);
c.translate(left, top);
header.draw(c);
c.restore();
}
}
}
示例4: drawNextPageAreaAndShadow
import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void drawNextPageAreaAndShadow(Canvas canvas) {
canvas.save();
if (actiondownX > mScreenWidth >> 1) {
canvas.clipPath(mPath0);
canvas.drawBitmap(mNextPageBitmap, 0, 0, null);
} else {
canvas.clipPath(mPath0, Region.Op.XOR);
canvas.drawBitmap(mNextPageBitmap, 0, 0, null);
}
try {
canvas.restore();
} catch (Exception e) {
}
}
示例5: draw
import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(@NonNull final Canvas canvas, final CharSequence text,
final int start, final int end, final float x,
final int top, final int y, final int bottom, @NonNull final Paint paint) {
Drawable d = getCachedDrawable();
Rect rect = d.getBounds();
canvas.save();
final float fontHeight = paint.getFontMetrics().descent - paint.getFontMetrics().ascent;
int transY = bottom - rect.bottom;
if (rect.height() < fontHeight) { // this is the fucking code which I waste 3 days
if (mVerticalAlignment == ALIGN_BASELINE) {
transY -= paint.getFontMetricsInt().descent;
} else if (mVerticalAlignment == ALIGN_CENTER) {
transY -= (fontHeight - rect.height()) / 2;
} else if (mVerticalAlignment == ALIGN_TOP) {
transY -= fontHeight - rect.height();
}
}
canvas.translate(x, transY);
d.draw(canvas);
canvas.restore();
}
示例6: draw
import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end,
float x, int top, int y, int bottom, Paint paint) {
Drawable drawable = getDrawable();
canvas.save();
int transY = 0;
transY = ((bottom - top) - drawable.getBounds().bottom) / 2 + top;
canvas.translate(x, transY);
drawable.draw(canvas);
canvas.restore();
}
示例7: onDraw
import android.graphics.Canvas; //导入方法依赖的package包/类
/**
* 绘制焦点框
*/
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (Style.RECTANGLE == mStyle) {
mFocusPath.addRect(mFocusRect, Path.Direction.CCW);
canvas.save();
canvas.clipRect(0, 0, getWidth(), getHeight());
canvas.clipPath(mFocusPath, Region.Op.DIFFERENCE);
canvas.drawColor(mMaskColor);
canvas.restore();
} else if (Style.CIRCLE == mStyle) {
float radius = Math.min((mFocusRect.right - mFocusRect.left) / 2, (mFocusRect.bottom - mFocusRect.top) / 2);
mFocusPath.addCircle(mFocusMidPoint.x, mFocusMidPoint.y, radius, Path.Direction.CCW);
canvas.save();
canvas.clipRect(0, 0, getWidth(), getHeight());
canvas.clipPath(mFocusPath, Region.Op.DIFFERENCE);
canvas.drawColor(mMaskColor);
canvas.restore();
}
mBorderPaint.setColor(mBorderColor);
mBorderPaint.setStyle(Paint.Style.STROKE);
mBorderPaint.setStrokeWidth(mBorderWidth);
mBorderPaint.setAntiAlias(true);
canvas.drawPath(mFocusPath, mBorderPaint);
mFocusPath.reset();
}
示例8: draw
import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, Paint paint) {
float translateX=getWidth()/9;
float translateY=getHeight()/2;
for (int i = 0; i < 4; i++) {
canvas.save();
canvas.translate((2 + i * 2) * translateX - translateX / 2, translateY);
canvas.scale(scaleFloats[i], scaleFloats[i]);
RectF rectF=new RectF(-translateX/2,-getHeight()/2.5f,translateX/2,getHeight()/2.5f);
canvas.drawRoundRect(rectF,5,5,paint);
canvas.restore();
}
}
示例9: draw
import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, Paint paint) {
float translateX=getWidth()/11;
float translateY=getHeight()/2;
for (int i = 0; i < 5; i++) {
canvas.save();
canvas.translate((2 + i * 2) * translateX - translateX / 2, translateY);
canvas.scale(SCALE, scaleYFloats[i]);
RectF rectF=new RectF(-translateX/2,-getHeight()/2.5f,translateX/2,getHeight()/2.5f);
canvas.drawRoundRect(rectF, 5, 5, paint);
canvas.restore();
}
}
示例10: draw
import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, Paint paint) {
paint.setStrokeWidth(3);
paint.setStyle(Paint.Style.STROKE);
for (int i = 0; i < 3; i++) {
canvas.save();
canvas.translate(translateX[i], translateY[i]);
canvas.drawCircle(0, 0, getWidth() / 10, paint);
canvas.restore();
}
}
示例11: onDrawMainUpView
import android.graphics.Canvas; //导入方法依赖的package包/类
/**
* 重寫了繪製的函數.
*/
@Override
public boolean onDrawMainUpView(Canvas canvas)
{
canvas.save();
if (!isDrawUpRect)
{
// 绘制阴影.
onDrawShadow(canvas);
// 绘制最上层的边框.
onDrawUpRect(canvas);
}
// 绘制焦点子控件.
if (mFocusView != null && (!isDrawUpRect && isInDraw))
{
onDrawFocusView(canvas);
}
//
if (isDrawUpRect)
{
// 绘制阴影.
onDrawShadow(canvas);
// 绘制最上层的边框.
onDrawUpRect(canvas);
}
canvas.restore();
return true;
}
示例12: draw
import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, Paint paint) {
float radius=getWidth()/10;
for (int i = 0; i < 8; i++) {
canvas.save();
Point point=circleAt(getWidth(),getHeight(),getWidth()/2.5f-radius,i*(Math.PI/4));
canvas.translate(point.x, point.y);
canvas.scale(scaleFloats[i], scaleFloats[i]);
canvas.rotate(i*45);
paint.setAlpha(alphas[i]);
RectF rectF=new RectF(-radius,-radius/1.5f,1.5f*radius,radius/1.5f);
canvas.drawRoundRect(rectF,5,5,paint);
canvas.restore();
}
}
示例13: onDraw
import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
if (mTiledCanvas != null) {
canvas.save(Canvas.MATRIX_SAVE_FLAG);
if (mPanX != 0 || mPanY != 0 || !mZoomMatrix.isIdentity()) {
canvas.translate(mPanX, mPanY);
canvas.concat(mZoomMatrix);
canvas.drawRect(-20000, -20000, 20000, 0, mWorkspacePaint);
canvas.drawRect(-20000, 0, 0, mTiledCanvas.getHeight(), mWorkspacePaint);
canvas.drawRect(mTiledCanvas.getWidth(), 0, 20000, mTiledCanvas.getHeight(), mWorkspacePaint);
canvas.drawRect(-20000, mTiledCanvas.getHeight(), 20000, 20000, mWorkspacePaint);
}
if (!mDirtyRegion.isEmpty()) {
canvas.clipRegion(mDirtyRegion);
mDirtyRegion.setEmpty();
}
// TODO: tune this threshold based on the device density
mBlitPaint.setFilterBitmap(getScale(mZoomMatrix) < 3f);
mTiledCanvas.drawTo(canvas, 0, 0, mBlitPaint, false); // @@ set to true for dirty tile updates
if (0 != (mDebugFlags & FLAG_DEBUG_STROKES)) {
drawStrokeDebugInfo(canvas);
}
canvas.restore();
if (0 != (mDebugFlags & FLAG_DEBUG_PRESSURE)) {
mPressureCooker.drawDebug(canvas);
}
}
}
示例14: draw
import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas) {
Rect bounds = getBounds();
canvas.save();
canvas.drawLine(bounds.left, bounds.centerY(), bounds.right - bounds.left, bounds.centerY(), paint);
canvas.restore();
}
示例15: drawNextPageAreaAndShadow
import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawNextPageAreaAndShadow(Canvas canvas, Bitmap bitmap) {
mPath1.reset();
mPath1.moveTo(mBezierStart1.x, mBezierStart1.y);
mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y);
mPath1.lineTo(mBeziervertex2.x, mBeziervertex2.y);
mPath1.lineTo(mBezierStart2.x, mBezierStart2.y);
mPath1.lineTo(mCornerX, mCornerY);
mPath1.close();
mDegrees = (float) Math.toDegrees(Math.atan2(mBezierControl1.x
- mCornerX, mBezierControl2.y - mCornerY));
int leftx;
int rightx;
GradientDrawable mBackShadowDrawable;
if (mIsRTandLB) { //左下及右上
leftx = (int) (mBezierStart1.x);
rightx = (int) (mBezierStart1.x + mTouchToCornerDis / 4);
mBackShadowDrawable = mBackShadowDrawableLR;
} else {
leftx = (int) (mBezierStart1.x - mTouchToCornerDis / 4);
rightx = (int) mBezierStart1.x;
mBackShadowDrawable = mBackShadowDrawableRL;
}
canvas.save();
try {
canvas.clipPath(mPath0);
canvas.clipPath(mPath1, Region.Op.INTERSECT);
} catch (Exception e) {
}
canvas.drawBitmap(bitmap, 0, 0, null);
canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y);
mBackShadowDrawable.setBounds(leftx, (int) mBezierStart1.y, rightx,
(int) (mMaxLength + mBezierStart1.y));//左上及右下角的xy坐标值,构成一个矩形
mBackShadowDrawable.draw(canvas);
canvas.restore();
}