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


Java Rect.offsetTo方法代碼示例

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


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

示例1: drawOnCanvas

import android.graphics.Rect; //導入方法依賴的package包/類
public void drawOnCanvas(ToDraw actual, Canvas canvas) {
            //this gets the source rectangle. trust my strange calculations :P
            Rect source = new Rect(-Math.min(actual.getX(), 0), -Math.min(0, actual.getY()), actual.getWidth(), actual.getHeight());
            //this gets the destination of the rectangle
            Rect destination = new Rect(source);
            destination.offsetTo(Math.max(actual.getX(), 0), Math.max(actual.getY(), 0));

//            Picture pic = new Picture();
//            Canvas tempc = pic.beginRecording(width, height);
//            tempc.rotate(-30, destination.centerX(),destination.centerY());
//            tempc.drawBitmap(actual.getTexture(),0,0,p);
//            tempc.drawBitmap(actual.getTexture(), source, destination, p);
            //tempc.rotate(30, destination.centerX(),destination.centerY());
            //pic.endRecording();
            //pic.draw(canvas);

            canvas.drawBitmap(actual.getTexture(), source, destination, p);
        }
 
開發者ID:samsumas,項目名稱:LivingBurger,代碼行數:19,代碼來源:JumpingBurger.java

示例2: getDrawableBounds

import android.graphics.Rect; //導入方法依賴的package包/類
protected static Rect getDrawableBounds(Drawable d) {
    Rect bounds = new Rect();
    d.copyBounds(bounds);
    if (bounds.width() == 0 || bounds.height() == 0) {
        bounds.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
    } else {
        bounds.offsetTo(0, 0);
    }
    return bounds;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:11,代碼來源:DragPreviewProvider.java

示例3: scrollToPage

import android.graphics.Rect; //導入方法依賴的package包/類
public void scrollToPage(int pageNumber)
{
	//  scroll to bring the page into view

	int scrollTime = 400;

	//  get current viewport
	Rect viewport = new Rect();
	getGlobalVisibleRect(viewport);

	//  offset it based on current scroll position
	Point viewportOrigin = new Point();
	viewportOrigin.set(getScrollX(), getScrollY());
	viewport.offsetTo(viewportOrigin.x, viewportOrigin.y);

	//  get page rect from last layout
	DocPageView cv = (DocPageView) getOrCreateChild(pageNumber);
	Rect childRect = cv.getChildRect();

	//  scroll
	if ((childRect.height()) > viewport.height())
	{
		//  put the top of the page at the top and the left at 0
		smoothScrollBy(getScrollX(), getScrollY() - childRect.top, scrollTime);
	}
	else
	{
		//  if the whole page is not visible, move the center of the page at the center
		if (childRect.top < viewport.top || childRect.bottom > viewport.bottom)
		{
			if (childRect.top == 0)
				smoothScrollBy(0, getScrollY(), scrollTime);
			else
				smoothScrollBy(0, getScrollY() + viewport.height() / 2 - (childRect.bottom + childRect.top) / 2, scrollTime);
		}
	}
}
 
開發者ID:ArtifexSoftware,項目名稱:mupdf-android-viewer-nui,代碼行數:38,代碼來源:DocViewBase.java

示例4: onDraw

import android.graphics.Rect; //導入方法依賴的package包/類
@Override
    protected void onDraw(Canvas canvas) {
        Canvas c = canvas;
        if (mExternalSurface != null) {
            try {
                Rect r = new Rect();
                r = canvas.getClipBounds();
                int [] location = new int[2];
                getLocationOnScreen(location);
                r.offsetTo(location[0],location[1]);
//                 Log.d(TAG, "Spacer "+r.toString());
                c = mExternalSurface.lockCanvas(null);
                c.save();
                c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
                c.clipRect(r);
                c.translate(location[0],location[1]);
                if (mBackground != null)
                    mBackground.draw(c);
            } catch (Exception e) {
            }
        }
        super.onDraw(c);
        if (c != canvas) {
            c.restore();
            mExternalSurface.unlockCanvasAndPost(c);
        }
    }
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:28,代碼來源:SubtitleSpacerView.java

示例5: onDraw

import android.graphics.Rect; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
    if (mBitmap != null) {
        Canvas c = canvas;
        if (mExternalSurface != null) {
            try {
                Rect r = new Rect();
                r = canvas.getClipBounds();
                int [] location = new int[2];
                getLocationOnScreen(location);
                r.offsetTo(location[0],location[1]);
                c = mExternalSurface.lockCanvas(null);
                c.save();
                c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
                c.clipRect(r);
                c.translate(location[0],location[1]);
            } catch (Exception e) {
                Log.d(TAG, "Can not lock canvas!!!!");
            }
        }

        Bitmap draw = Bitmap.createScaledBitmap(mBitmap, mDrawWidth, mDrawHeight, true);
        c.drawBitmap(draw, mDrawX, 0, mPaint);
        draw.recycle();
        if (c != canvas) {
            c.restore();
            mExternalSurface.unlockCanvasAndPost(c);
        }
    }
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:31,代碼來源:SubtitleGfxView.java

示例6: drawTo

import android.graphics.Rect; //導入方法依賴的package包/類
@Override
public void drawTo(Canvas drawCanvas, float left, float top, Paint paint, boolean onlyDirty) {
    final Rect src = new Rect(0, 0, mTileSize, mTileSize);
    final Rect dst = new Rect(0, 0, mTileSize, mTileSize);
    drawCanvas.save();
    drawCanvas.translate(-left, -top);
    drawCanvas.clipRect(0, 0, mWidth, mHeight);
    for (int j=0; j<mTilesY; j++) {
        for (int i=0; i<mTilesX; i++) {
            dst.offsetTo(i*mTileSize, j*mTileSize);
            final int p = j * mTilesX + i;
            final Tile tile = mTiles[p];
            if (!onlyDirty || tile.dirty) {
                drawCanvas.drawBitmap(tile.getBitmap(), src, dst, paint);
                tile.dirty = false;
                if (mDebug) {
                    mDrawCount++;
                    dbgPaint.setColor(DEBUG_COLORS[tile.top % DEBUG_COLORS.length]);
                    //drawCanvas.drawRect(dst, (mDrawCount % 2 == 0) ? dbgPaint1 : dbgPaint2);
                    drawCanvas.drawRect(dst, dbgPaint);
                    //drawCanvas.drawRect(dst, dbgStroke);
                    drawCanvas.drawText(
                            String.format("%d,%d v%d", tile.x, tile.y, tile.top),
                            dst.left + 4, dst.bottom - 4, dbgTextPaint);
                }
            }
        }
    }
    drawCanvas.restore();
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:31,代碼來源:TiledBitmapCanvas.java

示例7: getDrawableBounds

import android.graphics.Rect; //導入方法依賴的package包/類
protected static Rect getDrawableBounds(Drawable d) {
    Rect bounds = new Rect();
    d.copyBounds(bounds);
    if (bounds.width() == 0 || bounds.height() == 0) {
        bounds.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
    } else {
        bounds.offsetTo(0, 0);
    }
    if (d instanceof PreloadIconDrawable) {
        int inset = -((PreloadIconDrawable) d).getOutset();
        bounds.inset(inset, inset);
    }
    return bounds;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:15,代碼來源:DragPreviewProvider.java

示例8: onDraw

import android.graphics.Rect; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
    final int width = getWidth();
    final int height = getHeight();

    final int sideLength = generateSideLength();
    BoxBody body = generateBoxBody(width, height, sideLength);

    mPaint.setColor(ColorUtils.setAlphaComponent(mAccentColor, 150));
    canvas.drawPath(generateBoxBodyPath(body), mPaint);

    mPaint.setColor(mAccentColor);
    canvas.drawPath(generateBoxCoverPath(body), mPaint);

    if (isInEditMode()) {
        mDropOutPercent = 2.5f;
    }
    if (mDropOutPercent > 0) {
        canvas.clipPath(generateClipPath(body, width));

        final float percent1 = Math.min(mDropOutPercent, 1);
        Rect bounds1 = mDrawable1.getBounds();
        bounds1.offsetTo(width / 2 - bounds1.width() / 2, (int)((body.boxCenterY - bounds1.height() / 2 + bounds1.height()) * percent1) - bounds1.height());
        mDrawable1.draw(canvas);

        final float percent2 = Math.min(Math.max(mDropOutPercent - 1, 0), 1);
        Rect bounds2 = mDrawable2.getBounds();
        bounds2.offsetTo(width / 2 - bounds2.width() / 2, (int)((body.boxCenterY - bounds2.height() / 2 + bounds2.height()) * percent2) - bounds2.height());
        mDrawable2.draw(canvas);

        final float percent3 = Math.min(Math.max(mDropOutPercent - 2, 0), 1);
        Rect bounds3 = mDrawable3.getBounds();
        bounds3.offsetTo(width / 2 - bounds3.width() / 2, (int) ((body.boxCenterY - bounds3.height() / 2 + bounds3.height()) * percent3) - bounds3.height());
        mDrawable3.draw(canvas);

        if (mDropOutOverFlow) {
            bounds1.offsetTo(width / 2 - bounds1.width() / 2, ((body.boxCenterY - bounds1.height() / 2)));
            mDrawable1.draw(canvas);

            bounds2.offsetTo(width / 2 - bounds2.width() / 2, ((body.boxCenterY - bounds2.height() / 2)));
            mDrawable2.draw(canvas);

            bounds3.offsetTo(width / 2 - bounds3.width() / 2, ((body.boxCenterY - bounds3.height() / 2)));
            mDrawable3.draw(canvas);
        }
    }

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:49,代碼來源:DropboxHeader.java

示例9: getRectInsideCircle

import android.graphics.Rect; //導入方法依賴的package包/類
private Rect getRectInsideCircle(Point center, float radius) {
    Rect rect = new Rect(0, 0, (int) ((radius * 2) / Math.sqrt(2)), (int) ((radius * 2) / Math.sqrt(2)));
    rect.offsetTo(center.x - rect.width() / 2, center.y - rect.width() / 2);
    return rect;
}
 
開發者ID:ovenbits,項目名稱:QuickActionView,代碼行數:6,代碼來源:ActionView.java


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