List of usage examples for android.graphics RectF height
public final float height()
From source file:org.mariotaku.twidere.fragment.AccountsDashboardFragment.java
private void onAccountSelected(AccountProfileImageViewHolder holder, @NonNull final ParcelableAccount account) { if (mSwitchAccountAnimationPlaying) return;//from w ww . j av a2s . c o m final ImageView snapshotView = mFloatingProfileImageSnapshotView; final ShapedImageView profileImageView = mAccountProfileImageView; final ShapedImageView clickedImageView = holder.getIconView(); // Reset snapshot view position snapshotView.setPivotX(0); snapshotView.setPivotY(0); snapshotView.setTranslationX(0); snapshotView.setTranslationY(0); final Matrix matrix = new Matrix(); final RectF sourceBounds = new RectF(), destBounds = new RectF(), snapshotBounds = new RectF(); getLocationOnScreen(clickedImageView, sourceBounds); getLocationOnScreen(profileImageView, destBounds); getLocationOnScreen(snapshotView, snapshotBounds); final float finalScale = destBounds.width() / sourceBounds.width(); final Bitmap snapshotBitmap = TransitionUtils.createViewBitmap(clickedImageView, matrix, new RectF(0, 0, sourceBounds.width(), sourceBounds.height())); final ViewGroup.LayoutParams lp = snapshotView.getLayoutParams(); lp.width = clickedImageView.getWidth(); lp.height = clickedImageView.getHeight(); snapshotView.setLayoutParams(lp); // Copied from MaterialNavigationDrawer: https://github.com/madcyph3r/AdvancedMaterialDrawer/ AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_X, sourceBounds.left - snapshotBounds.left, destBounds.left - snapshotBounds.left)) .with(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_Y, sourceBounds.top - snapshotBounds.top, destBounds.top - snapshotBounds.top)) .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_X, 1, finalScale)) .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_Y, 1, finalScale)) .with(ObjectAnimator.ofFloat(profileImageView, View.ALPHA, 1, 0)) .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_X, 0, 1)) .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_Y, 0, 1)); final long animationTransition = 400; set.setDuration(animationTransition); set.setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListener() { private Drawable clickedDrawable; private int[] clickedColors; @Override public void onAnimationStart(Animator animation) { snapshotView.setVisibility(View.VISIBLE); snapshotView.setImageBitmap(snapshotBitmap); final Drawable profileDrawable = profileImageView.getDrawable(); clickedDrawable = clickedImageView.getDrawable(); clickedColors = clickedImageView.getBorderColors(); final ParcelableAccount oldSelectedAccount = mAccountsAdapter.getSelectedAccount(); if (oldSelectedAccount == null) return; mMediaLoader.displayDashboardProfileImage(clickedImageView, oldSelectedAccount, profileDrawable); clickedImageView.setBorderColors(profileImageView.getBorderColors()); displayAccountBanner(account); mSwitchAccountAnimationPlaying = true; } @Override public void onAnimationEnd(Animator animation) { finishAnimation(); } @Override public void onAnimationCancel(Animator animation) { finishAnimation(); } @Override public void onAnimationRepeat(Animator animation) { } private void finishAnimation() { final Editor editor = mPreferences.edit(); editor.putString(KEY_DEFAULT_ACCOUNT_KEY, account.account_key.toString()); editor.apply(); mAccountsAdapter.setSelectedAccount(account); updateAccountActions(); displayCurrentAccount(clickedDrawable); snapshotView.setVisibility(View.INVISIBLE); snapshotView.setImageDrawable(null); profileImageView.setImageDrawable(clickedDrawable); profileImageView.setBorderColors(clickedColors); profileImageView.setAlpha(1f); clickedImageView.setScaleX(1); clickedImageView.setScaleY(1); clickedImageView.setAlpha(1f); mSwitchAccountAnimationPlaying = false; } }); set.start(); }
From source file:org.stockchart.core.Area.java
@Override protected void onBoundsChanged() { final RectF margins = this.getSideMargins(); margins.left = Math.max(fGlobalLeftMargin, margins.left); margins.right = Math.max(fGlobalRightMargin, margins.right); final RectF legendSize = this.fLegend.getSize(); final float horizontalAxisWidth = getBounds().width() - (margins.left + margins.right); final float verticalAxisHeight = getBounds().height() - (margins.top + margins.bottom); getTopAxis().setBounds(margins.left, margins.top - getTopAxis().getSize(0f), horizontalAxisWidth, getTopAxis().getSize(0f));/*from w w w . j av a 2 s.c o m*/ getBottomAxis().setBounds(margins.left, getBounds().height() - margins.bottom, horizontalAxisWidth, getBottomAxis().getSize(0f)); getLeftAxis().setBounds(margins.left - getLeftAxis().getSize(0f), margins.top, getLeftAxis().getSize(0f), verticalAxisHeight); getRightAxis().setBounds(getBounds().width() - margins.right, margins.top, getRightAxis().getSize(0f), verticalAxisHeight); fPlot.setBounds(margins.left, margins.top, horizontalAxisWidth, verticalAxisHeight); switch (fLegend.getSide()) { case LEFT: fLegend.setBounds(0, margins.top + (verticalAxisHeight - legendSize.height()) / 2f, legendSize.width(), legendSize.height()); break; case RIGHT: fLegend.setBounds(getBounds().width() - legendSize.width(), margins.top + (verticalAxisHeight - legendSize.height()) / 2f, legendSize.width(), legendSize.height()); break; case TOP: fLegend.setBounds(margins.left + (horizontalAxisWidth - legendSize.width()) / 2f, 0f, legendSize.width(), legendSize.height()); break; case BOTTOM: fLegend.setBounds(margins.left + (horizontalAxisWidth - legendSize.width()) / 2f, getBounds().height() - legendSize.height(), legendSize.width(), legendSize.height()); break; } }
From source file:com.mediatek.galleryfeature.stereo.segment.ImageShow.java
protected void constrainTranslation(Point translation, float scale) { int currentEdgeEffect = 0; if (scale <= 1) { finishEdgeEffect();// w w w . j a v a2s. co m return; } Rect originalBounds = mMasterImage.getOriginalBounds(); Matrix originalToScreen = mMasterImage.getImageToScreenMatrix(originalBounds.width(), originalBounds.height(), getWidth(), getHeight()); if (originalToScreen == null) { finishEdgeEffect(); return; } RectF screenPos = new RectF(originalBounds); originalToScreen.mapRect(screenPos); boolean rightConstraint = screenPos.right < getWidth(); boolean leftConstraint = screenPos.left > 0; boolean topConstraint = screenPos.top > 0; boolean bottomConstraint = screenPos.bottom < getHeight(); if (screenPos.width() > getWidth()) { if (rightConstraint && !leftConstraint) { float tx = screenPos.right - translation.x * scale; translation.x = (int) ((getWidth() - tx) / scale); currentEdgeEffect = EDGE_RIGHT; } else if (leftConstraint && !rightConstraint) { float tx = screenPos.left - translation.x * scale; translation.x = (int) ((-tx) / scale); currentEdgeEffect = EDGE_LEFT; } } else { float tx = screenPos.right - translation.x * scale; float dx = (getWidth() - screenPos.width()) / 2f; translation.x = (int) ((getWidth() - tx - dx) / scale); } if (screenPos.height() > getHeight()) { if (bottomConstraint && !topConstraint) { float ty = screenPos.bottom - translation.y * scale; translation.y = (int) ((getHeight() - ty) / scale); currentEdgeEffect = EDGE_BOTTOM; } else if (topConstraint && !bottomConstraint) { float ty = screenPos.top - translation.y * scale; translation.y = (int) ((-ty) / scale); currentEdgeEffect = EDGE_TOP; } } else { float ty = screenPos.bottom - translation.y * scale; float dy = (getHeight() - screenPos.height()) / 2f; translation.y = (int) ((getHeight() - ty - dy) / scale); } if (mCurrentEdgeEffect != currentEdgeEffect) { if (mCurrentEdgeEffect == 0 || currentEdgeEffect != 0) { mCurrentEdgeEffect = currentEdgeEffect; mEdgeEffect.finish(); } mEdgeEffect.setSize(getWidth(), mEdgeSize); } if (currentEdgeEffect != 0) { mEdgeEffect.onPull(mEdgeSize); } }
From source file:com.iiordanov.bVNC.RemoteCanvas.java
/** * Invalidates (to redraw) the location of the remote pointer. *///w w w .j a v a 2 s .co m public void invalidateMousePosition() { if (bitmapData != null) { bitmapData.moveCursorRect(pointer.getX(), pointer.getY()); RectF r = bitmapData.getCursorRect(); reDraw(r.left, r.top, r.width(), r.height()); } }
From source file:com.iiordanov.bVNC.RemoteCanvas.java
/** * Moves soft cursor into a particular location. * @param x/*from ww w . j a va 2 s . c om*/ * @param y */ synchronized void softCursorMove(int x, int y) { if (bitmapData.isNotInitSoftCursor()) { initializeSoftCursor(); } if (!inScrolling) { pointer.setX(x); pointer.setY(y); RectF prevR = new RectF(bitmapData.getCursorRect()); // Move the cursor. bitmapData.moveCursorRect(x, y); // Show the cursor. RectF r = bitmapData.getCursorRect(); reDraw(r.left, r.top, r.width(), r.height()); reDraw(prevR.left, prevR.top, prevR.width(), prevR.height()); } }
From source file:com.android.gallery3d.filtershow.imageshow.ImageShow.java
private void constrainTranslation(Point translation, float scale) { int currentEdgeEffect = 0; if (scale <= 1) { mCurrentEdgeEffect = 0;//from w ww .j a va 2 s .c om mEdgeEffect.finish(); return; } Matrix originalToScreen = MasterImage.getImage().originalImageToScreen(); Rect originalBounds = MasterImage.getImage().getOriginalBounds(); RectF screenPos = new RectF(originalBounds); originalToScreen.mapRect(screenPos); boolean rightConstraint = screenPos.right < getWidth() - mShadowMargin; boolean leftConstraint = screenPos.left > mShadowMargin; boolean topConstraint = screenPos.top > mShadowMargin; boolean bottomConstraint = screenPos.bottom < getHeight() - mShadowMargin; if (screenPos.width() > getWidth()) { if (rightConstraint && !leftConstraint) { float tx = screenPos.right - translation.x * scale; translation.x = (int) ((getWidth() - mShadowMargin - tx) / scale); currentEdgeEffect = EDGE_RIGHT; } else if (leftConstraint && !rightConstraint) { float tx = screenPos.left - translation.x * scale; translation.x = (int) ((mShadowMargin - tx) / scale); currentEdgeEffect = EDGE_LEFT; } } else { float tx = screenPos.right - translation.x * scale; float dx = (getWidth() - 2 * mShadowMargin - screenPos.width()) / 2f; translation.x = (int) ((getWidth() - mShadowMargin - tx - dx) / scale); } if (screenPos.height() > getHeight()) { if (bottomConstraint && !topConstraint) { float ty = screenPos.bottom - translation.y * scale; translation.y = (int) ((getHeight() - mShadowMargin - ty) / scale); currentEdgeEffect = EDGE_BOTTOM; } else if (topConstraint && !bottomConstraint) { float ty = screenPos.top - translation.y * scale; translation.y = (int) ((mShadowMargin - ty) / scale); currentEdgeEffect = EDGE_TOP; } } else { float ty = screenPos.bottom - translation.y * scale; float dy = (getHeight() - 2 * mShadowMargin - screenPos.height()) / 2f; translation.y = (int) ((getHeight() - mShadowMargin - ty - dy) / scale); } if (mCurrentEdgeEffect != currentEdgeEffect) { if (mCurrentEdgeEffect == 0 || currentEdgeEffect != 0) { mCurrentEdgeEffect = currentEdgeEffect; mEdgeEffect.finish(); } mEdgeEffect.setSize(getWidth(), mEdgeSize); } if (currentEdgeEffect != 0) { mEdgeEffect.onPull(mEdgeSize); } }
From source file:org.akop.crosswords.view.CrosswordView.java
private void bringIntoView(Crossword.Word word, int selectedCell) { if (word == null) { return;//from www . j av a 2s . co m } RectF wordRect = new RectF(); wordRect.left = word.getStartColumn() * mScaledCellSize - mContentRect.left; wordRect.top = word.getStartRow() * mScaledCellSize - mContentRect.top; if (word.getDirection() == Crossword.Word.DIR_ACROSS) { wordRect.right = wordRect.left + word.getLength() * mScaledCellSize; wordRect.bottom = wordRect.top + mScaledCellSize; } else if (word.getDirection() == Crossword.Word.DIR_DOWN) { wordRect.right = wordRect.left + mScaledCellSize; wordRect.bottom = wordRect.top + word.getLength() * mScaledCellSize; } RectF objectRect = new RectF(wordRect); RectF visibleArea = new RectF(-mBitmapOffset.x, -mBitmapOffset.y, -mBitmapOffset.x + mContentRect.width(), -mBitmapOffset.y + mContentRect.height()); if (visibleArea.contains(objectRect)) { return; // Already visible } if (objectRect.width() > visibleArea.width() || objectRect.height() > visibleArea.height()) { // Available area isn't large enough to fit the entire word // Is the selected cell visible? If not, bring it into view CellOffset co = getCellOffset(word, selectedCell); RectF cellRect = new RectF(); cellRect.left = co.mColumn * mScaledCellSize; cellRect.top = co.mRow * mScaledCellSize; cellRect.right = cellRect.left + mScaledCellSize; cellRect.bottom = cellRect.top + mScaledCellSize; if (visibleArea.contains(cellRect)) { return; // Already visible } objectRect.set(cellRect); } // Compute view that includes the object in the center PointF end = new PointF((visibleArea.width() - objectRect.width()) / 2.0f - objectRect.left, (visibleArea.height() - objectRect.height()) / 2.0f - objectRect.top); // Clamp the values clampPointF(end, mTranslationBounds); // Compute the distance to travel from current location float distanceX = end.x - mBitmapOffset.x; float distanceY = end.y - mBitmapOffset.y; // Scroll the point into view mScroller.startScroll((int) mBitmapOffset.x, (int) mBitmapOffset.y, (int) distanceX, (int) distanceY, NAVIGATION_SCROLL_DURATION_MS); }
From source file:org.akop.ararat.view.CrosswordView.java
private void bringIntoView(Selectable sel) { if (sel == null) { return;/*from ww w .jav a2s . c o m*/ } RectF wordRect = new RectF(); wordRect.left = sel.getStartColumn() * mScaledCellSize - mContentRect.left; wordRect.top = sel.getStartRow() * mScaledCellSize - mContentRect.top; if (sel.getDirection() == Crossword.Word.DIR_ACROSS) { wordRect.right = wordRect.left + sel.mWord.getLength() * mScaledCellSize; wordRect.bottom = wordRect.top + mScaledCellSize; } else if (sel.getDirection() == Crossword.Word.DIR_DOWN) { wordRect.right = wordRect.left + mScaledCellSize; wordRect.bottom = wordRect.top + sel.mWord.getLength() * mScaledCellSize; } RectF objectRect = new RectF(wordRect); RectF visibleArea = new RectF(-mBitmapOffset.x, -mBitmapOffset.y, -mBitmapOffset.x + mContentRect.width(), -mBitmapOffset.y + mContentRect.height()); if (visibleArea.contains(objectRect)) { return; // Already visible } if (objectRect.width() > visibleArea.width() || objectRect.height() > visibleArea.height()) { // Available area isn't large enough to fit the entire word // Is the selected cell visible? If not, bring it into view RectF cellRect = new RectF(); cellRect.left = sel.getColumn() * mScaledCellSize; cellRect.top = sel.getRow() * mScaledCellSize; cellRect.right = cellRect.left + mScaledCellSize; cellRect.bottom = cellRect.top + mScaledCellSize; if (visibleArea.contains(cellRect)) { return; // Already visible } objectRect.set(cellRect); } // Compute view that includes the object in the center PointF end = new PointF((visibleArea.width() - objectRect.width()) / 2.0f - objectRect.left, (visibleArea.height() - objectRect.height()) / 2.0f - objectRect.top); // Clamp the values clampPointF(end, mTranslationBounds); // Compute the distance to travel from current location float distanceX = end.x - mBitmapOffset.x; float distanceY = end.y - mBitmapOffset.y; // Scroll the point into view mScroller.startScroll((int) mBitmapOffset.x, (int) mBitmapOffset.y, (int) distanceX, (int) distanceY, NAVIGATION_SCROLL_DURATION_MS); }
From source file:com.cognizant.trumobi.PersonaLauncher.java
protected void editWidget(final View widget) { if (mWorkspace != null) { mIsWidgetEditMode = true;//w w w . j ava2 s . c om final PersonaCellLayout screen = (PersonaCellLayout) mWorkspace .getChildAt(mWorkspace.getCurrentScreen()); if (screen != null) { mlauncherAppWidgetInfo = (PersonaLauncherAppWidgetInfo) widget.getTag(); final Intent motosize = new Intent("com.motorola.blur.home.ACTION_SET_WIDGET_SIZE"); final int appWidgetId = ((AppWidgetHostView) widget).getAppWidgetId(); final AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId); if (appWidgetInfo != null) { motosize.setComponent(appWidgetInfo.provider); } motosize.putExtra("appWidgetId", appWidgetId); motosize.putExtra("com.motorola.blur.home.EXTRA_NEW_WIDGET", true); final int minw = (mWorkspace.getWidth() - screen.getLeftPadding() - screen.getRightPadding()) / screen.getCountX(); final int minh = (mWorkspace.getHeight() - screen.getBottomPadding() - screen.getTopPadding()) / screen.getCountY(); mScreensEditor = new PersonaResizeViewHandler(this); // Create a default HightlightView if we found no face in the // picture. int width = (mlauncherAppWidgetInfo.spanX * minw); int height = (mlauncherAppWidgetInfo.spanY * minh); final Rect screenRect = new Rect(0, 0, mWorkspace.getWidth() - screen.getRightPadding(), mWorkspace.getHeight() - screen.getBottomPadding()); final int x = mlauncherAppWidgetInfo.cellX * minw; final int y = mlauncherAppWidgetInfo.cellY * minh; final int[] spans = new int[] { 1, 1 }; final int[] position = new int[] { 1, 1 }; final PersonaCellLayout.LayoutParams lp = (PersonaCellLayout.LayoutParams) widget.getLayoutParams(); RectF widgetRect = new RectF(x, y, x + width, y + height); ((PersonaResizeViewHandler) mScreensEditor).setup(null, screenRect, widgetRect, false, false, minw - 10, minh - 10); mDragLayer.addView(mScreensEditor); ((PersonaResizeViewHandler) mScreensEditor) .setOnValidateSizingRect(new PersonaResizeViewHandler.OnSizeChangedListener() { @Override public void onTrigger(RectF r) { if (r != null) { final float left = Math.round(r.left / minw) * minw; final float top = Math.round(r.top / minh) * minh; final float right = left + (Math.max(Math.round(r.width() / (minw)), 1) * minw); final float bottom = top + (Math.max(Math.round(r.height() / (minh)), 1) * minh); r.set(left, top, right, bottom); } } }); final Rect checkRect = new Rect(); ((PersonaResizeViewHandler) mScreensEditor) .setOnSizeChangedListener(new PersonaResizeViewHandler.OnSizeChangedListener() { @Override public void onTrigger(RectF r) { int[] tmpspans = { Math.max(Math.round(r.width() / (minw)), 1), Math.max(Math.round(r.height() / (minh)), 1) }; int[] tmpposition = { Math.round(r.left / minw), Math.round(r.top / minh) }; checkRect.set(tmpposition[0], tmpposition[1], tmpposition[0] + tmpspans[0], tmpposition[1] + tmpspans[1]); boolean ocupada = getModel().ocuppiedArea(screen.getScreen(), appWidgetId, checkRect); if (!ocupada) { ((PersonaResizeViewHandler) mScreensEditor).setColliding(false); } else { ((PersonaResizeViewHandler) mScreensEditor).setColliding(true); } if (tmpposition[0] != position[0] || tmpposition[1] != position[1] || tmpspans[0] != spans[0] || tmpspans[1] != spans[1]) { if (!ocupada) { position[0] = tmpposition[0]; position[1] = tmpposition[1]; spans[0] = tmpspans[0]; spans[1] = tmpspans[1]; lp.cellX = position[0]; lp.cellY = position[1]; lp.cellHSpan = spans[0]; lp.cellVSpan = spans[1]; widget.setLayoutParams(lp); mlauncherAppWidgetInfo.cellX = lp.cellX; mlauncherAppWidgetInfo.cellY = lp.cellY; mlauncherAppWidgetInfo.spanX = lp.cellHSpan; mlauncherAppWidgetInfo.spanY = lp.cellVSpan; widget.setTag(mlauncherAppWidgetInfo); // send the broadcast motosize.putExtra("spanX", spans[0]); motosize.putExtra("spanY", spans[1]); PersonaLauncher.this.sendBroadcast(motosize); PersonaLog.d("RESIZEHANDLER", "sent resize broadcast"); } } } }); } } }