List of usage examples for android.graphics PointF PointF
public PointF(float x, float y)
From source file:xyz.zpayh.hdimage.HDImageView.java
private void startFilingAnimation(float sCenterXEnd, float sCenterYEnd) { if (mValueAnimator != null) { mValueAnimator.cancel();// www.j a va 2 s. c o m } final int vxCenter = (getWidth() + getPaddingLeft() - getPaddingRight()) / 2; final int vyCenter = (getHeight() + getPaddingTop() - getPaddingBottom()) / 2; final PointF sourceCenter = new PointF(sCenterXEnd, sCenterYEnd); mValueAnimator = new AnimationBuilder(sourceCenter).setTarget(this).setScaleStart(mScale) .setScaleEnd(mScale).setViewFocusStart(sourceToViewCoordinate(sourceCenter)) .setViewFocusEnd(new PointF(vxCenter, vyCenter)) .setTranslateInterpolator(mTranslationAnimationInterpolator) .setScaleInterpolator(mScaleAnimationInterpolator).setDuration(mDuration) .addAnimationListener(mAnimatorListener).addAnimationListener(mAnimatorListenerCompat) .addAnimationUpdateListener(mAnimatorUpdateListener) .addAnimationUpdateListener(mAnimatorUpdateListenerCompat).build(); mValueAnimator.start(); Log.d(TAG, "startFilingAnimation"); }
From source file:com.bizcom.vc.widget.cus.SubsamplingScaleImageView.java
/** * Convert screen coordinate to source coordinate. *//*w w w . j a v a 2s . com*/ public final PointF viewToSourceCoord(float vx, float vy) { if (vTranslate == null) { return null; } float sx = (vx - vTranslate.x) / scale; float sy = (vy - vTranslate.y) / scale; return new PointF(sx, sy); }
From source file:com.bizcom.vc.widget.cus.SubsamplingScaleImageView.java
/** * Convert source coordinate to screen coordinate. *//*from w ww. j ava2 s . c o m*/ public final PointF sourceToViewCoord(float sx, float sy) { if (vTranslate == null) { return null; } float vx = (sx * scale) + vTranslate.x; float vy = (sy * scale) + vTranslate.y; return new PointF(vx, vy); }
From source file:com.bizcom.vc.widget.cus.SubsamplingScaleImageView.java
/** * Convert source rect to screen rect.//w w w .j ava 2 s. c o m */ private RectF sourceToViewRect(RectF sRect) { PointF vLT = sourceToViewCoord(new PointF(sRect.left, sRect.top)); PointF vRB = sourceToViewCoord(new PointF(sRect.right, sRect.bottom)); return new RectF(vLT.x, vLT.y, vRB.x, vRB.y); }
From source file:com.bizcom.vc.widget.cus.SubsamplingScaleImageView.java
/** * Convert screen rect to source rect.//from ww w . j ava 2 s .c om */ private RectF viewToSourceRect(RectF vRect) { PointF sLT = viewToSourceCoord(new PointF(vRect.left, vRect.top)); PointF sRB = viewToSourceCoord(new PointF(vRect.right, vRect.bottom)); return new RectF(sLT.x, sLT.y, sRB.x, sRB.y); }
From source file:me.ccrama.redditslide.Views.SubsamplingScaleImageView.java
/** * Adjusts current scale and translate values to keep scale within the allowed range and the image on screen. Minimum scale * is set so one dimension fills the view and the image is centered on the other dimension. * * @param center Whether the image should be centered in the dimension it's too small to fill. While animating this can be false to avoid changes in direction as bounds are reached. *//* ww w. j a v a 2s.c om*/ private void fitToBounds(boolean center) { boolean init = false; if (vTranslate == null) { init = true; vTranslate = new PointF(0, 0); } if (satTemp == null) { satTemp = new ScaleAndTranslate(0, new PointF(0, 0)); } satTemp.scale = scale; satTemp.vTranslate.set(vTranslate); fitToBounds(center, satTemp); setScale(satTemp.scale); vTranslate.set(satTemp.vTranslate); if (init) { vTranslate.set(vTranslateForSCenter(sWidth() / 2, sHeight() / 2, scale)); } }
From source file:com.android.systemui.qs.QSDragPanel.java
private void shiftAllTilesLeft(int startingIndex) { DragTileRecord startingTile = (DragTileRecord) mRecords.get(startingIndex); final PointF lastLocation = new PointF(startingTile.destination.x, startingTile.destination.y); PointF reallyTempLoc = new PointF(); int lastRow = startingTile.row, lastCol = startingTile.col, tempRow, tempCol, lastPage = startingTile.destinationPage, tempPage; int desiredColCount = getColumnCount(startingTile.destinationPage, startingTile.row); for (int j = startingIndex + 1; j < mRecords.size(); j++) { final DragTileRecord ti = (DragTileRecord) mRecords.get(j); mCurrentlyAnimating.add(ti);//from w w w. j a v a 2s.co m if (DEBUG_DRAG) { Log.v(TAG, "moving " + ti + " to " + lastPage + ", at coords: " + lastRow + ", col: " + lastCol); Log.i(TAG, "and will have desiredColCount: " + desiredColCount); } final int columnCountF = desiredColCount; if (ti.row != lastRow) { desiredColCount = getColumnCount(ti.destinationPage, ti.row); if (DEBUG_DRAG) { Log.e(TAG, "updating desired colum count to: " + desiredColCount); } } // save current tile's loc reallyTempLoc.x = ti.destination.x; reallyTempLoc.y = ti.destination.y; tempRow = ti.row; tempCol = ti.col; tempPage = ti.destinationPage; ti.row = lastRow; ti.col = lastCol; ti.destination.x = getLeft(lastRow, lastCol, columnCountF, lastPage == 0 && lastRow == 0 && mFirstRowLarge); ti.destination.y = getRowTop(lastRow); final boolean dual = getPage(ti.destinationPage).dualRecord(ti); if (ti.destinationPage != lastPage) { ti.destinationPage = lastPage; ti.tileView.setX(reallyTempLoc.x + getWidth()); ti.tileView.setY(reallyTempLoc.y); final QSPage originalPage = getPage(ti.page); final QSPage page = getPage(lastPage); originalPage.removeView(ti.tileView); ti.tileView.animate().withLayer().x(ti.destination.x).y(ti.destination.y) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { page.addTransientView(ti.tileView, 0); } @Override public void onAnimationCancel(Animator animation) { page.removeTransientView(ti.tileView); mCurrentlyAnimating.remove(ti); } @Override public void onAnimationEnd(Animator animation) { page.removeTransientView(ti.tileView); page.addView(ti.tileView); ti.page = page.getPageIndex(); mCurrentlyAnimating.remove(ti); requestLayout(); } }); } else { ti.tileView.animate().withLayer().x(ti.destination.x).y(ti.destination.y) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCurrentlyAnimating.remove(ti); if (ti.tileView.setDual(dual, ti.tile.hasDualTargetsDetails())) { if (DEBUG_DRAG) { Log.w(TAG, ti + " changed dual state to : " + ti.tileView.isDual()); } } requestLayout(); } }); } // update previous location lastLocation.x = reallyTempLoc.x; lastLocation.y = reallyTempLoc.y; lastRow = tempRow; lastCol = tempCol; lastPage = tempPage; } }
From source file:com.bizcom.vc.widget.cus.SubsamplingScaleImageView.java
/** * Get the translation required to place a given source coordinate at the * center of the screen. Accepts the desired scale as an argument, so this * is independent of current translate and scale. The result is fitted to * bounds, putting the image point as near to the screen center as * permitted.//from w w w .j av a 2 s.c o m */ private PointF vTranslateForSCenter(PointF sCenter, float scale) { PointF vTranslate = new PointF((getWidth() / 2) - (sCenter.x * scale), (getHeight() / 2) - (sCenter.y * scale)); ScaleAndTranslate sat = new ScaleAndTranslate(scale, vTranslate); fitToBounds(true, sat); return vTranslate; }
From source file:com.bizcom.vc.widget.cus.SubsamplingScaleImageView.java
/** * Given a requested source center and scale, calculate what the actual * center will have to be to keep the image in pan limits, keeping the * requested center as near to the middle of the screen as allowed. *///from w w w.j a v a2s . co m private PointF limitedSCenter(PointF sCenter, float scale) { PointF vTranslate = vTranslateForSCenter(sCenter, scale); int mY = getHeight() / 2; float sx = ((getWidth() / 2) - vTranslate.x) / scale; float sy = ((getHeight() / 2) - vTranslate.y) / scale; return new PointF(sx, sy); }
From source file:com.bizcom.vc.widget.cus.SubsamplingScaleImageView.java
/** * Fully zoom out and return the image to the middle of the screen. This * might be useful if you have a view pager and want images to be reset when * the user has moved to another page.//from ww w.j ava 2 s. c o m */ public final void resetScaleAndCenter() { this.anim = null; this.pendingScale = limitedScale(0); if (isImageReady()) { this.sPendingCenter = new PointF(sWidth() / 2, sHeight() / 2); } else { this.sPendingCenter = new PointF(0, 0); } invalidate(); }