List of usage examples for android.graphics Matrix MTRANS_X
int MTRANS_X
To view the source code for android.graphics Matrix MTRANS_X.
Click Source Link
From source file:com.diegocarloslima.byakugallery.TouchImageView.java
private void loadMatrixValues() { mMatrix.getValues(mMatrixValues);/*from w w w .j a va 2 s.c o m*/ mScale = mMatrixValues[Matrix.MSCALE_X]; mTranslationX = mMatrixValues[Matrix.MTRANS_X]; mTranslationY = mMatrixValues[Matrix.MTRANS_Y]; }
From source file:com.android.volley.ui.PhotoView.java
@Override public boolean interceptMoveLeft(float origX, float origY) { if (!mTransformsEnabled) { // Allow intercept if we're not in transform mode return false; } else if (mTranslateRunnable.mRunning) { // Don't allow touch intercept until we've stopped flinging return true; } else {//from w w w . j a va2 s .c o m mMatrix.getValues(mValues); mTranslateRect.set(mTempSrc); mMatrix.mapRect(mTranslateRect); final float viewWidth = getWidth(); final float transX = mValues[Matrix.MTRANS_X]; final float drawWidth = mTranslateRect.right - mTranslateRect.left; if (!mTransformsEnabled || drawWidth <= viewWidth) { // Allow intercept if not in transform mode or the image is smaller than the view return false; } else if (transX == 0) { // We're at the left-side of the image; allow intercepting movements to the right return false; } else if (viewWidth >= drawWidth + transX) { // We're at the right-side of the image; allow intercepting movements to the left return true; } else { // We're in the middle of the image; don't allow touch intercept return true; } } }
From source file:com.android.volley.ui.PhotoView.java
@Override public boolean interceptMoveRight(float origX, float origY) { if (!mTransformsEnabled) { // Allow intercept if we're not in transform mode return false; } else if (mTranslateRunnable.mRunning) { // Don't allow touch intercept until we've stopped flinging return true; } else {// w ww .j av a2 s. c o m mMatrix.getValues(mValues); mTranslateRect.set(mTempSrc); mMatrix.mapRect(mTranslateRect); final float viewWidth = getWidth(); final float transX = mValues[Matrix.MTRANS_X]; final float drawWidth = mTranslateRect.right - mTranslateRect.left; if (!mTransformsEnabled || drawWidth <= viewWidth) { // Allow intercept if not in transform mode or the image is smaller than the view return false; } else if (transX == 0) { // We're at the left-side of the image; allow intercepting movements to the right return true; } else if (viewWidth >= drawWidth + transX) { // We're at the right-side of the image; allow intercepting movements to the left return false; } else { // We're in the middle of the image; don't allow touch intercept return true; } } }
From source file:com.jsibbold.zoomage.ZoomageView.java
/** * Animate the matrix back to its original position after the user stopped interacting with it. *///from www .j a v a2 s. com private void animateToStartMatrix() { final Matrix beginMatrix = new Matrix(getImageMatrix()); beginMatrix.getValues(mValues); //difference in current and original values final float xsdiff = startValues[Matrix.MSCALE_X] - mValues[Matrix.MSCALE_X]; final float ysdiff = startValues[Matrix.MSCALE_Y] - mValues[Matrix.MSCALE_Y]; final float xtdiff = startValues[Matrix.MTRANS_X] - mValues[Matrix.MTRANS_X]; final float ytdiff = startValues[Matrix.MTRANS_Y] - mValues[Matrix.MTRANS_Y]; ValueAnimator anim = ValueAnimator.ofFloat(0, 1f); anim.addUpdateListener(new AnimatorUpdateListener() { final Matrix activeMatrix = new Matrix(getImageMatrix()); final float[] values = new float[9]; @Override public void onAnimationUpdate(ValueAnimator animation) { float val = (Float) animation.getAnimatedValue(); activeMatrix.set(beginMatrix); activeMatrix.getValues(values); values[Matrix.MTRANS_X] = values[Matrix.MTRANS_X] + xtdiff * val; values[Matrix.MTRANS_Y] = values[Matrix.MTRANS_Y] + ytdiff * val; values[Matrix.MSCALE_X] = values[Matrix.MSCALE_X] + xsdiff * val; values[Matrix.MSCALE_Y] = values[Matrix.MSCALE_Y] + ysdiff * val; activeMatrix.setValues(values); setImageMatrix(activeMatrix); } }); anim.setDuration(RESET_DURATION); anim.start(); }
From source file:it.mb.whatshare.Utils.java
/** * Applies the transformations stored in the array of float values to the * argument list of points./*from w w w . j a v a 2 s . c om*/ * * <p> * The float array can be obtained starting from a {@link Matrix} object by * calling <blockquote> * * <pre> * Matrix myMatrix; * float[] matrixValues = new float[9]; * myMatrix.getValues(matrixValues); * </pre> * * </blockquote> * * @param matrixValues * the values to apply to all points in the list * @param points * a list of points to which the transformations in the array * will be applied */ public static void applyMatrix(float[] matrixValues, List<PointF> points) { // variable names are the same used by Skia library final float tx = matrixValues[Matrix.MTRANS_X]; final float ty = matrixValues[Matrix.MTRANS_Y]; final float mx = matrixValues[Matrix.MSCALE_X]; final float my = matrixValues[Matrix.MSCALE_Y]; final float kx = matrixValues[Matrix.MSKEW_X]; final float ky = matrixValues[Matrix.MSKEW_Y]; /* * if rotation: skia messes up with the matrix, so sx and sy actually * store cosV, rx and ry store -sinV and sinV */ for (PointF point : points) { final float originalY = point.y; point.y = point.x * ky + (point.y * my) + ty; point.x = point.x * mx + (originalY * kx) + tx; } }
From source file:com.jsibbold.zoomage.ZoomageView.java
private void animateTranslationX() { if (getCurrentDisplayedWidth() > getWidth()) { //the left edge is too far to the interior if (bounds.left > 0) { animateMatrixIndex(Matrix.MTRANS_X, 0); }//from w w w. java2 s . c om //the right edge is too far to the interior else if (bounds.right < getWidth()) { animateMatrixIndex(Matrix.MTRANS_X, bounds.left + getWidth() - bounds.right); } } else { //left edge needs to be pulled in, and should be considered before the right edge if (bounds.left < 0) { animateMatrixIndex(Matrix.MTRANS_X, 0); } //right edge needs to be pulled in else if (bounds.right > getWidth()) { animateMatrixIndex(Matrix.MTRANS_X, bounds.left + getWidth() - bounds.right); } } }
From source file:com.goka.flickableview.ImageViewTouchBase.java
public void printMatrix(Matrix matrix) { float scaleX = getValue(matrix, Matrix.MSCALE_X); float scaleY = getValue(matrix, Matrix.MSCALE_Y); float tx = getValue(matrix, Matrix.MTRANS_X); float ty = getValue(matrix, Matrix.MTRANS_Y); LogUtil.D(TAG, "matrix: { x: " + tx + ", y: " + ty + ", scaleX: " + scaleX + ", scaleY: " + scaleY + " }"); }
From source file:com.test.xujixiao.xjx.widget.view.BaseZoomableImageView.java
protected boolean isScrollOver(float distanceX) { try {/*from w ww . j av a 2 s . c o m*/ if (mDisplayMatrix != null) { float m_x = getValue(mDisplayMatrix, Matrix.MTRANS_X); //? float width = getWidth() - m_x; //width ?+? //mBitmap.getWidth() * getValue(mDisplayMatrix, Matrix.MSCALE_X) ? //width == mBitmap.getWidth() * getValue(mDisplayMatrix, Matrix.MSCALE_X) ???? == 0?? if ((m_x == 0 && distanceX <= 0) // || (width == mBitmap.getWidth() //?? * getValue(mDisplayMatrix, Matrix.MSCALE_X) && distanceX >= 0)) { System.out.println("ScrollOver"); return true; } } } catch (IllegalArgumentException e) { Log.v("Vincent", "isScrollOver"); e.printStackTrace(); } return false; }
From source file:com.afra55.commontutils.ui.imageview.BaseZoomableImageView.java
protected boolean isScrollOver(float distanceX) { try {// w w w . ja va2s. co m if (mDisplayMatrix != null) { float m_x = getValue(mDisplayMatrix, Matrix.MTRANS_X); //? float width = getWidth() - m_x; //width ?+? //mBitmap.getWidth() * getValue(mDisplayMatrix, Matrix.MSCALE_X) ? //width == mBitmap.getWidth() * getValue(mDisplayMatrix, Matrix.MSCALE_X) ???? == 0?? if ((m_x == 0 && distanceX <= 0) // || (width == mBitmap.getWidth() //?? * getValue(mDisplayMatrix, Matrix.MSCALE_X) && distanceX >= 0)) { System.out.println("ScrollOver"); return true; } } } catch (Exception e) { Log.v("MultiTouchZoom", "isScrollOver"); Log.e("MultiTouchZoom", e.toString()); } return false; }
From source file:cn.jmessage.android.uikit.pickerimage.view.BaseZoomableImageView.java
protected boolean isScrollOver(float distanceX) { try {//from www. j a va 2 s .c om if (mDisplayMatrix != null) { float m_x = getValue(mDisplayMatrix, Matrix.MTRANS_X); //? float width = getWidth() - m_x; //width ?+? //mBitmap.getWidth() * getValue(mDisplayMatrix, Matrix.MSCALE_X) ? //width == mBitmap.getWidth() * getValue(mDisplayMatrix, Matrix.MSCALE_X) ???? == 0?? if ((m_x == 0 && distanceX <= 0) // || (width == mBitmap.getWidth() //?? * getValue(mDisplayMatrix, Matrix.MSCALE_X) && distanceX >= 0)) { System.out.println("ScrollOver"); return true; } } } catch (IllegalArgumentException e) { Log.v("Vincent", "isScrollOver"); e.printStackTrace(); } return false; }