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


Java Canvas.restore方法代碼示例

本文整理匯總了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();
		}
	}
}
 
開發者ID:QuixomTech,項目名稱:WeatherStream,代碼行數:24,代碼來源:CustomViewBehind.java

示例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) {

    }

}
 
開發者ID:z-chu,項目名稱:FriendBook,代碼行數:23,代碼來源:SimulationPageAnim.java

示例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();
    }
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:24,代碼來源:StickyHeaderDecoration.java

示例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) {

    }
}
 
開發者ID:ynztlxdeai,項目名稱:TextReader,代碼行數:17,代碼來源:OverlappedWidget.java

示例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();
}
 
開發者ID:Wilshion,項目名稱:HeadlineNews,代碼行數:23,代碼來源:SpanUtils.java

示例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();
}
 
開發者ID:liying2008,項目名稱:Simpler,代碼行數:12,代碼來源:VerticalImageSpan.java

示例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();
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:30,代碼來源:CropImageView.java

示例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();
    }
}
 
開發者ID:monkeywiiu,項目名稱:Discover,代碼行數:14,代碼來源:LineScalePartyIndicator.java

示例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();
    }
}
 
開發者ID:zhouphenix,項目名稱:Multi-SwipeToRefreshLayout,代碼行數:14,代碼來源:LineScaleIndicator.java

示例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();
    }
}
 
開發者ID:zhouphenix,項目名稱:Multi-SwipeToRefreshLayout,代碼行數:12,代碼來源:BallTrianglePathIndicator.java

示例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;
}
 
開發者ID:Dreamxiaoxuan,項目名稱:AndroidTvDemo,代碼行數:31,代碼來源:OpenEffectBridge.java

示例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();
    }
}
 
開發者ID:magicbaby810,項目名稱:SRecyclerView,代碼行數:16,代碼來源:LineSpinFadeLoaderIndicator.java

示例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);
        }
    }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:34,代碼來源:Slate.java

示例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();
    }
 
開發者ID:Fueled,項目名稱:snippety,代碼行數:10,代碼來源:LineDrawable.java

示例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();
}
 
開發者ID:guoxiaoxing,項目名稱:android-open-source-project-analysis,代碼行數:39,代碼來源:PageView.java


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