@Override public void set(@NonNull Drawable object, @NonNull PointF value) { object.copyBounds(mBounds); mBounds.offsetTo(Math.round(value.x), Math.round(value.y)); object.setBounds(mBounds); }
bounds1.offsetTo(width / 2 - bounds1.width() / 2, (int)((body.boxCenterY - bounds1.height() / 2 + bounds1.height()) * percent1) - bounds1.height()); mDrawable1.draw(canvas); bounds2.offsetTo(width / 2 - bounds2.width() / 2, (int)((body.boxCenterY - bounds2.height() / 2 + bounds2.height()) * percent2) - bounds2.height()); mDrawable2.draw(canvas); bounds3.offsetTo(width / 2 - bounds3.width() / 2, (int) ((body.boxCenterY - bounds3.height() / 2 + bounds3.height()) * percent3) - bounds3.height()); mDrawable3.draw(canvas); 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);
mCloudDrawable.getBounds().offsetTo(mCloudX1, mHeaderHeight / 3); mCloudDrawable.draw(canvas); mCloudDrawable.getBounds().offsetTo(mCloudX2, mHeaderHeight / 2); mCloudDrawable.draw(canvas); mCloudDrawable.getBounds().offsetTo(mCloudX3, mHeaderHeight * 2 / 3); mCloudDrawable.draw(canvas); canvas.rotate(5 * (float) Math.sin(mAppreciation / 2), width / 2 , mHeaderHeight / 2 - mUmbrellaDrawable.getBounds().height()); final int centerYBox = centerY + (mHeaderHeight / 2 - mBoxDrawable.getBounds().height()) - Math.min(mHeaderHeight / 2 - mBoxDrawable.getBounds().height(), DensityUtil.dp2px(mAppreciation * 100)); mBoxDrawable.getBounds().offsetTo(width / 2 - mBoxDrawable.getBounds().width() / 2, centerYBox - mBoxDrawable.getBounds().height() / 4); mBoxDrawable.draw(canvas); Rect bounds = mUmbrellaDrawable.getBounds(); final int centerYUmbrella = centerY - mHeaderHeight + Math.min(mHeaderHeight, DensityUtil.dp2px(mAppreciation * 100)); mUmbrellaDrawable.getBounds().offsetTo(width / 2 - bounds.width() / 2, centerYUmbrella - bounds.height()); mUmbrellaDrawable.draw(canvas);
@Override public Animator onDisappear(@NonNull ViewGroup sceneRoot, @NonNull View view, @Nullable TransitionValues startValues, @Nullable TransitionValues endValues) { if (startValues == null) { return null; } Rect bounds = (Rect) startValues.values.get(PROPNAME_SCREEN_BOUNDS); int viewPosX = bounds.left; int viewPosY = bounds.top; float startX = view.getTranslationX(); float startY = view.getTranslationY(); float endX = startX; float endY = startY; int[] interruptedPosition = (int[]) startValues.view.getTag(R.id.transitionPosition); if (interruptedPosition != null) { // We want to have the end position relative to the interrupted position, not // the position it was supposed to start at. endX += interruptedPosition[0] - bounds.left; endY += interruptedPosition[1] - bounds.top; bounds.offsetTo(interruptedPosition[0], interruptedPosition[1]); } calculateOut(sceneRoot, bounds, mTempLoc); endX += mTempLoc[0]; endY += mTempLoc[1]; return TranslationAnimationCreator.createAnimation(view, startValues, viewPosX, viewPosY, startX, startY, endX, endY, sAccelerate, this); }
public void draw(Canvas canvas) { if (isVisible()) { // Draw the fast scroller popup int restoreCount = canvas.save(); canvas.translate(mBgBounds.left, mBgBounds.top); mTmpRect.set(mBgBounds); mTmpRect.offsetTo(0, 0); mBackgroundPath.reset(); mBackgroundRect.set(mTmpRect); float[] radii = createRadii(); mBackgroundPath.addRoundRect(mBackgroundRect, radii, Path.Direction.CW); mBackgroundPaint.setAlpha((int) (Color.alpha(mBackgroundColor) * mAlpha)); mTextPaint.setAlpha((int) (mAlpha * 255)); canvas.drawPath(mBackgroundPath, mBackgroundPaint); canvas.drawText(mSectionName, (mBgBounds.width() - mTextBounds.width()) / 2, mBgBounds.height() - (mBgBounds.height() - mTextBounds.height()) / 2, mTextPaint); canvas.restoreToCount(restoreCount); } }
public void setPosition(int x, int y) { bounds.offsetTo(x, y); }
public void onDrag(int y) { bounds.offsetTo(bounds.left, startDragTop + y - downY); }
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; }
void layout(int x, int y, int max) { Rect rect = getBounds(); rect.offsetTo(Math.min(x - rect.width() / 2, max - rect.width() - (int)(0.2f * mHeight)), Math.max(0, y - rect.height() / 2)); setBounds(rect); }
public void drawBubble(Canvas canvas, String text, int x, int y) { Rect bounds = new Rect(); textPaint.getTextBounds(text, 0, text.length(), bounds); bounds.offsetTo(0, 0); Point point = speechBubbleDrawer.getPointLocationGivenInner(bounds); bounds.offsetTo(x - point.x, y - point.y); speechBubbleDrawer.draw(canvas, bounds.left, bounds.top, bounds.width(), bounds.height()); canvas.drawText(text, bounds.left, bounds.top - fontMetrics.ascent, textPaint); }
public void getClickableArea(Rect result, View view, String text, int x, int y) { textPaint.getTextBounds(text, 0, text.length(), result); result.offsetTo(0, 0); Point point = speechBubbleDrawer.getPointLocationGivenInner(result); result.offsetTo(x - point.x, y - point.y); speechBubbleDrawer.updateInnerRectForClickableArea(result); }
private 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; }
@Override protected void onBoundsChange(@NonNull Rect bounds) { final int width = bounds.width(); final int height = bounds.height(); paint.setTextSize(height); paint.getTextBounds(text, 0, 1, drawBounds); paint.setTextSize(Math.min(height, (int) Math.ceil( width * (height / (float) drawBounds.width())))); paint.getTextBounds(text, 0, 1, drawBounds); drawBounds.offsetTo(bounds.left + (width - drawBounds.width()) / 2, bounds.top + (height - drawBounds.height()) / 2 - drawBounds.bottom); centerX = bounds.exactCenterX(); centerY = bounds.exactCenterY(); }
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; }
@Override public Rect getBitmapSrcRec() { Rect rect = super.getBitmapSrcRec(); int left = (int)(level * getWidth()); rect.offsetTo(left, 0); return rect; }
@Override public void getHitRectRelativeToDragLayer(android.graphics.Rect outRect) { super.getHitRect(outRect); outRect.bottom += mBottomDragPadding; int[] coords = new int[2]; mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, coords); outRect.offsetTo(coords[0], coords[1]); }
@Override public void getHitRectRelativeToDragLayer(android.graphics.Rect outRect) { super.getHitRect(outRect); outRect.bottom += mBottomDragPadding; int[] coords = new int[2]; mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, coords); outRect.offsetTo(coords[0], coords[1]); }
@Override public void getHitRectRelativeToDragLayer(android.graphics.Rect outRect) { super.getHitRect(outRect); outRect.bottom += mBottomDragPadding; int[] coords = new int[2]; mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, coords); outRect.offsetTo(coords[0], coords[1]); }
@Override public void getHitRectRelativeToDragLayer(android.graphics.Rect outRect) { super.getHitRect(outRect); outRect.bottom += mBottomDragPadding; int[] coords = new int[2]; mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, coords); outRect.offsetTo(coords[0], coords[1]); }
@Override public void getHitRectRelativeToDragLayer(android.graphics.Rect outRect) { super.getHitRect(outRect); outRect.bottom += mBottomDragPadding; int[] coords = new int[2]; mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, coords); outRect.offsetTo(coords[0], coords[1]); }