Example usage for android.graphics Matrix MTRANS_Y

List of usage examples for android.graphics Matrix MTRANS_Y

Introduction

In this page you can find the example usage for android.graphics Matrix MTRANS_Y.

Prototype

int MTRANS_Y

To view the source code for android.graphics Matrix MTRANS_Y.

Click Source Link

Usage

From source file:com.diegocarloslima.byakugallery.TouchImageView.java

private void loadMatrixValues() {
    mMatrix.getValues(mMatrixValues);// w  ww. j a  v a 2s .  co  m
    mScale = mMatrixValues[Matrix.MSCALE_X];
    mTranslationX = mMatrixValues[Matrix.MTRANS_X];
    mTranslationY = mMatrixValues[Matrix.MTRANS_Y];
}

From source file:com.jsibbold.zoomage.ZoomageView.java

/**
 * Animate the matrix back to its original position after the user stopped interacting with it.
 *//* w w  w.j  a v  a  2  s .c  o  m*/
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./*  w  w  w.  j av a 2  s . co m*/
 * 
 * <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 animateTranslationY() {
    if (getCurrentDisplayedHeight() > getHeight()) {
        //the top edge is too far to the interior
        if (bounds.top > 0) {
            animateMatrixIndex(Matrix.MTRANS_Y, 0);
        }//from w  w w.  java 2 s  .  c om
        //the bottom edge is too far to the interior
        else if (bounds.bottom < getHeight()) {
            animateMatrixIndex(Matrix.MTRANS_Y, bounds.top + getHeight() - bounds.bottom);
        }
    } else {
        //top needs to be pulled in, and needs to be considered before the bottom edge
        if (bounds.top < 0) {
            animateMatrixIndex(Matrix.MTRANS_Y, 0);
        }
        //bottom edge needs to be pulled in
        else if (bounds.bottom > getHeight()) {
            animateMatrixIndex(Matrix.MTRANS_Y, bounds.top + getHeight() - bounds.bottom);
        }
    }
}

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 + " }");
}