FileDocCategorySizeDatePackage
Matrix_Delegate.javaAPI DocAndroid 5.1 API33948Thu Mar 12 22:22:44 GMT 2015android.graphics

Matrix_Delegate

public final class Matrix_Delegate extends Object
Delegate implementing the native methods of android.graphics.Matrix Through the layoutlib_create tool, the original native methods of Matrix have been replaced by calls to methods of the same name in this delegate class. This class behaves like the original native implementation, but in Java, keeping previously native data into its own objects and mapping them to int that are sent back and forth between it and the original Matrix class.
see
DelegateManager

Fields Summary
private static final int
MATRIX_SIZE
private static final com.android.layoutlib.bridge.impl.DelegateManager
sManager
private float[]
mValues
private static final int
kIdentity_Mask
private static final int
kTranslate_Mask
private static final int
kScale_Mask
private static final int
kAffine_Mask
private static final int
kPerspective_Mask
private static final int
kRectStaysRect_Mask
private static final int
kUnknown_Mask
private static final int
kAllMasks
private static final int
kTranslate_Shift
private static final int
kScale_Shift
private static final int
kAffine_Shift
private static final int
kPerspective_Shift
private static final int
kRectStaysRect_Shift
Constructors Summary
private Matrix_Delegate()

        reset();
    
private Matrix_Delegate(float[] values)

        System.arraycopy(values, 0, mValues, 0, MATRIX_SIZE);
    
Methods Summary
private intcomputeTypeMask()


       
        int mask = 0;

        if (mValues[6] != 0. || mValues[7] != 0. || mValues[8] != 1.) {
            mask |= kPerspective_Mask;
        }

        if (mValues[2] != 0. || mValues[5] != 0.) {
            mask |= kTranslate_Mask;
        }

        float m00 = mValues[0];
        float m01 = mValues[1];
        float m10 = mValues[3];
        float m11 = mValues[4];

        if (m01 != 0. || m10 != 0.) {
            mask |= kAffine_Mask;
        }

        if (m00 != 1. || m11 != 1.) {
            mask |= kScale_Mask;
        }

        if ((mask & kPerspective_Mask) == 0) {
            // map non-zero to 1
            int im00 = m00 != 0 ? 1 : 0;
            int im01 = m01 != 0 ? 1 : 0;
            int im10 = m10 != 0 ? 1 : 0;
            int im11 = m11 != 0 ? 1 : 0;

            // record if the (p)rimary and (s)econdary diagonals are all 0 or
            // all non-zero (answer is 0 or 1)
            int dp0 = (im00 | im11) ^ 1;  // true if both are 0
            int dp1 = im00 & im11;        // true if both are 1
            int ds0 = (im01 | im10) ^ 1;  // true if both are 0
            int ds1 = im01 & im10;        // true if both are 1

            // return 1 if primary is 1 and secondary is 0 or
            // primary is 0 and secondary is 1
            mask |= ((dp0 & ds1) | (dp1 & ds0)) << kRectStaysRect_Shift;
        }

        return mask;
    
static voidfinalizer(long native_instance)

        sManager.removeJavaReferenceFor(native_instance);
    
public java.awt.geom.AffineTransformgetAffineTransform()
Returns an {@link AffineTransform} matching the matrix.

        return getAffineTransform(mValues);
    
public static java.awt.geom.AffineTransformgetAffineTransform(Matrix m)
Returns an {@link AffineTransform} matching the given Matrix.

        Matrix_Delegate delegate = sManager.getDelegate(m.native_instance);
        if (delegate == null) {
            return null;
        }

        return delegate.getAffineTransform();
    
static java.awt.geom.AffineTransformgetAffineTransform(float[] matrix)

        // the AffineTransform constructor takes the value in a different order
        // for a matrix [ 0 1 2 ]
        //              [ 3 4 5 ]
        // the order is 0, 3, 1, 4, 2, 5...
        return new AffineTransform(
                matrix[0], matrix[3], matrix[1],
                matrix[4], matrix[2], matrix[5]);
    
public static android.graphics.Matrix_DelegategetDelegate(long native_instance)


    // ---- Public Helper methods ----

         
        return sManager.getDelegate(native_instance);
    
private static floatgetPointLength(float[] src, int index)

         return (float) Math.sqrt(src[index] * src[index] + src[index + 1] * src[index + 1]);
     
static float[]getRotate(float degrees)

        double rad = Math.toRadians(degrees);
        float sin = (float)Math.sin(rad);
        float cos = (float)Math.cos(rad);

        return getRotate(sin, cos);
    
static float[]getRotate(float sin, float cos)

        return setRotate(new float[9], sin, cos);
    
static float[]getRotate(float degrees, float px, float py)

        float[] tmp = new float[9];
        float[] tmp2 = new float[9];

        // TODO: do it in one pass

        // translate so that the pivot is in 0,0
        setTranslate(tmp, -px, -py);

        // rotate into tmp2
        double rad = Math.toRadians(degrees);
        float cos = (float)Math.cos(rad);
        float sin = (float)Math.sin(rad);
        multiply(tmp2, tmp, getRotate(sin, cos));

        // translate back the pivot back into tmp
        multiply(tmp, tmp2, getTranslate(px, py));

        return tmp;
    
static float[]getScale(float sx, float sy)

        return new float[] { sx, 0, 0, 0, sy, 0, 0, 0, 1 };
    
static float[]getScale(float sx, float sy, float px, float py)
Returns a matrix that represents the given scale info.

param
sx
param
sy
param
px
param
py

        float[] tmp = new float[9];
        float[] tmp2 = new float[9];

        // TODO: do it in one pass

        // translate tmp so that the pivot is in 0,0
        setTranslate(tmp, -px, -py);

        // scale into tmp2
        multiply(tmp2, tmp, getScale(sx, sy));

        // translate back the pivot back into tmp
        multiply(tmp, tmp2, getTranslate(px, py));

        return tmp;
    
static float[]getSkew(float kx, float ky)

        return new float[] { 1, kx, 0, ky, 1, 0, 0, 0, 1 };
    
static float[]getSkew(float kx, float ky, float px, float py)

        float[] tmp = new float[9];
        float[] tmp2 = new float[9];

        // TODO: do it in one pass

        // translate so that the pivot is in 0,0
        setTranslate(tmp, -px, -py);

        // skew into tmp2
        multiply(tmp2, tmp, new float[] { 1, kx, 0, ky, 1, 0, 0, 0, 1 });
        // translate back the pivot back into tmp
        multiply(tmp, tmp2, getTranslate(px, py));

        return tmp;
    
static float[]getTranslate(float dx, float dy)
Returns a matrix that represents a given translate

param
dx
param
dy
return

        return setTranslate(new float[9], dx, dy);
    
public booleanhasPerspective()

        return (mValues[6] != 0 || mValues[7] != 0 || mValues[8] != 1);
    
public static booleanhasPerspective(Matrix m)

        Matrix_Delegate delegate = sManager.getDelegate(m.native_instance);
        if (delegate == null) {
            return false;
        }

        return delegate.hasPerspective();
    
public booleanisIdentity()
Returns whether or not the matrix is identity.

        for (int i = 0, k = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++, k++) {
                if (mValues[k] != ((i==j) ? 1 : 0)) {
                    return false;
                }
            }
        }

        return true;
    
public static android.graphics.Matrix_Delegatemake(java.awt.geom.AffineTransform matrix)

        return new Matrix_Delegate(makeValues(matrix));
    
public static float[]makeValues(java.awt.geom.AffineTransform matrix)

        float[] values = new float[MATRIX_SIZE];
        values[0] = (float) matrix.getScaleX();
        values[1] = (float) matrix.getShearX();
        values[2] = (float) matrix.getTranslateX();
        values[3] = (float) matrix.getShearY();
        values[4] = (float) matrix.getScaleY();
        values[5] = (float) matrix.getTranslateY();
        values[6] = 0.f;
        values[7] = 0.f;
        values[8] = 1.f;

        return values;
    
private voidmapPoints(float[] dst, int dstIndex, float[] src, int srcIndex, int pointCount)
Apply this matrix to the array of 2D points specified by src, and write the transformed points into the array of points specified by dst. The two arrays represent their "points" as pairs of floats [x, y].

param
dst The array of dst points (x,y pairs)
param
dstIndex The index of the first [x,y] pair of dst floats
param
src The array of src points (x,y pairs)
param
srcIndex The index of the first [x,y] pair of src floats
param
pointCount The number of points (x,y pairs) to transform

         final int count = pointCount * 2;

         float[] tmpDest = dst;
         boolean inPlace = dst == src;
         if (inPlace) {
             tmpDest = new float[dstIndex + count];
         }

         for (int i = 0 ; i < count ; i += 2) {
             // just in case we are doing in place, we better put this in temp vars
             float x = mValues[0] * src[i + srcIndex] +
                       mValues[1] * src[i + srcIndex + 1] +
                       mValues[2];
             float y = mValues[3] * src[i + srcIndex] +
                       mValues[4] * src[i + srcIndex + 1] +
                       mValues[5];

             tmpDest[i + dstIndex]     = x;
             tmpDest[i + dstIndex + 1] = y;
         }

         if (inPlace) {
             System.arraycopy(tmpDest, dstIndex, dst, dstIndex, count);
         }
     
private voidmapPoints(float[] pts)
Apply this matrix to the array of 2D points, and write the transformed points back into the array

param
pts The array [x0, y0, x1, y1, ...] of points to transform.

         mapPoints(pts, 0, pts, 0, pts.length >> 1);
     
public booleanmapRect(RectF dst, RectF src)

        // array with 4 corners
        float[] corners = new float[] {
                src.left, src.top,
                src.right, src.top,
                src.right, src.bottom,
                src.left, src.bottom,
        };

        // apply the transform to them.
        mapPoints(corners);

        // now put the result in the rect. We take the min/max of Xs and min/max of Ys
        dst.left = Math.min(Math.min(corners[0], corners[2]), Math.min(corners[4], corners[6]));
        dst.right = Math.max(Math.max(corners[0], corners[2]), Math.max(corners[4], corners[6]));

        dst.top = Math.min(Math.min(corners[1], corners[3]), Math.min(corners[5], corners[7]));
        dst.bottom = Math.max(Math.max(corners[1], corners[3]), Math.max(corners[5], corners[7]));


        return (computeTypeMask() & kRectStaysRect_Mask) != 0;
    
private voidmapVectors(float[] dst, int dstIndex, float[] src, int srcIndex, int ptCount)

         if (hasPerspective()) {
             // transform the (0,0) point
             float[] origin = new float[] { 0.f, 0.f};
             mapPoints(origin);

             // translate the vector data as points
             mapPoints(dst, dstIndex, src, srcIndex, ptCount);

             // then substract the transformed origin.
             final int count = ptCount * 2;
             for (int i = 0 ; i < count ; i += 2) {
                 dst[dstIndex + i] = dst[dstIndex + i] - origin[0];
                 dst[dstIndex + i + 1] = dst[dstIndex + i + 1] - origin[1];
             }
         } else {
             // make a copy of the matrix
             Matrix_Delegate copy = new Matrix_Delegate(mValues);

             // remove the translation
             setTranslate(copy.mValues, 0, 0);

             // map the content as points.
             copy.mapPoints(dst, dstIndex, src, srcIndex, ptCount);
         }
     
static voidmultiply(float[] dest, float[] a, float[] b)
multiply two matrices and store them in a 3rd.

This in effect does dest = a*b dest cannot be the same as a or b.

        // first row
        dest[0] = b[0] * a[0] + b[1] * a[3] + b[2] * a[6];
        dest[1] = b[0] * a[1] + b[1] * a[4] + b[2] * a[7];
        dest[2] = b[0] * a[2] + b[1] * a[5] + b[2] * a[8];

        // 2nd row
        dest[3] = b[3] * a[0] + b[4] * a[3] + b[5] * a[6];
        dest[4] = b[3] * a[1] + b[4] * a[4] + b[5] * a[7];
        dest[5] = b[3] * a[2] + b[4] * a[5] + b[5] * a[8];

        // 3rd row
        dest[6] = b[6] * a[0] + b[7] * a[3] + b[8] * a[6];
        dest[7] = b[6] * a[1] + b[7] * a[4] + b[8] * a[7];
        dest[8] = b[6] * a[2] + b[7] * a[5] + b[8] * a[8];
    
static longnative_create(long native_src_or_zero)

        // create the delegate
        Matrix_Delegate newDelegate = new Matrix_Delegate();

        // copy from values if needed.
        if (native_src_or_zero > 0) {
            Matrix_Delegate oldDelegate = sManager.getDelegate(native_src_or_zero);
            if (oldDelegate != null) {
                System.arraycopy(
                        oldDelegate.mValues, 0,
                        newDelegate.mValues, 0,
                        MATRIX_SIZE);
            }
        }

        return sManager.addNewDelegate(newDelegate);
    
static booleannative_equals(long native_a, long native_b)

        Matrix_Delegate a = sManager.getDelegate(native_a);
        if (a == null) {
            return false;
        }

        Matrix_Delegate b = sManager.getDelegate(native_b);
        if (b == null) {
            return false;
        }

        for (int i = 0 ; i < MATRIX_SIZE ; i++) {
            if (a.mValues[i] != b.mValues[i]) {
                return false;
            }
        }

        return true;
    
static voidnative_getValues(long native_object, float[] values)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return;
        }

        System.arraycopy(d.mValues, 0, d.mValues, 0, MATRIX_SIZE);
    
static booleannative_invert(long native_object, long inverse)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return false;
        }

        Matrix_Delegate inv_mtx = sManager.getDelegate(inverse);
        if (inv_mtx == null) {
            return false;
        }

        try {
            AffineTransform affineTransform = d.getAffineTransform();
            AffineTransform inverseTransform = affineTransform.createInverse();
            inv_mtx.mValues[0] = (float)inverseTransform.getScaleX();
            inv_mtx.mValues[1] = (float)inverseTransform.getShearX();
            inv_mtx.mValues[2] = (float)inverseTransform.getTranslateX();
            inv_mtx.mValues[3] = (float)inverseTransform.getScaleX();
            inv_mtx.mValues[4] = (float)inverseTransform.getShearY();
            inv_mtx.mValues[5] = (float)inverseTransform.getTranslateY();

            return true;
        } catch (NoninvertibleTransformException e) {
            return false;
        }
    
static booleannative_isAffine(long native_object)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return true;
        }

        return (d.computeTypeMask() & kPerspective_Mask) == 0;
    
static booleannative_isIdentity(long native_object)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return false;
        }

        return d.isIdentity();
    
static voidnative_mapPoints(long native_object, float[] dst, int dstIndex, float[] src, int srcIndex, int ptCount, boolean isPts)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return;
        }

        if (isPts) {
            d.mapPoints(dst, dstIndex, src, srcIndex, ptCount);
        } else {
            d.mapVectors(dst, dstIndex, src, srcIndex, ptCount);
        }
    
static floatnative_mapRadius(long native_object, float radius)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return 0.f;
        }

        float[] src = new float[] { radius, 0.f, 0.f, radius };
        d.mapVectors(src, 0, src, 0, 2);

        float l1 = getPointLength(src, 0);
        float l2 = getPointLength(src, 2);

        return (float) Math.sqrt(l1 * l2);
    
static booleannative_mapRect(long native_object, RectF dst, RectF src)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return false;
        }

        return d.mapRect(dst, src);
    
static voidnative_postConcat(long native_object, long other_matrix)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        Matrix_Delegate other = sManager.getDelegate(other_matrix);
        if (d != null && other != null) {
            d.postTransform(other.mValues);
        }
    
static voidnative_postRotate(long native_object, float degrees, float px, float py)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d != null) {
            d.postTransform(getRotate(degrees, px, py));
        }
    
static voidnative_postRotate(long native_object, float degrees)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d != null) {
            d.postTransform(getRotate(degrees));
        }
    
static voidnative_postScale(long native_object, float sx, float sy, float px, float py)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d != null) {
            d.postTransform(getScale(sx, sy, px, py));
        }
    
static voidnative_postScale(long native_object, float sx, float sy)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d != null) {
            d.postTransform(getScale(sx, sy));
        }
    
static voidnative_postSkew(long native_object, float kx, float ky, float px, float py)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d != null) {
            d.postTransform(getSkew(kx, ky, px, py));
        }
    
static voidnative_postSkew(long native_object, float kx, float ky)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d != null) {
            d.postTransform(getSkew(kx, ky));
        }
    
static voidnative_postTranslate(long native_object, float dx, float dy)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d != null) {
            d.postTransform(getTranslate(dx, dy));
        }
    
static voidnative_preConcat(long native_object, long other_matrix)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        Matrix_Delegate other = sManager.getDelegate(other_matrix);
        if (d != null && other != null) {
            d.preTransform(other.mValues);
        }
    
static voidnative_preRotate(long native_object, float degrees, float px, float py)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d != null) {
            d.preTransform(getRotate(degrees, px, py));
        }
    
static voidnative_preRotate(long native_object, float degrees)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d != null) {

            double rad = Math.toRadians(degrees);
            float sin = (float) Math.sin(rad);
            float cos = (float) Math.cos(rad);

            d.preTransform(getRotate(sin, cos));
        }
    
static voidnative_preScale(long native_object, float sx, float sy, float px, float py)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d != null) {
            d.preTransform(getScale(sx, sy, px, py));
        }
    
static voidnative_preScale(long native_object, float sx, float sy)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d != null) {
            d.preTransform(getScale(sx, sy));
        }
    
static voidnative_preSkew(long native_object, float kx, float ky, float px, float py)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d != null) {
            d.preTransform(getSkew(kx, ky, px, py));
        }
    
static voidnative_preSkew(long native_object, float kx, float ky)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d != null) {
            d.preTransform(getSkew(kx, ky));
        }
    
static voidnative_preTranslate(long native_object, float dx, float dy)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d != null) {
            d.preTransform(getTranslate(dx, dy));
        }
    
static booleannative_rectStaysRect(long native_object)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return true;
        }

        return (d.computeTypeMask() & kRectStaysRect_Mask) != 0;
    
static voidnative_reset(long native_object)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return;
        }

        reset(d.mValues);
    
static voidnative_set(long native_object, long other)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return;
        }

        Matrix_Delegate src = sManager.getDelegate(other);
        if (src == null) {
            return;
        }

        System.arraycopy(src.mValues, 0, d.mValues, 0, MATRIX_SIZE);
    
static voidnative_setConcat(long native_object, long a, long b)

        if (a == native_object) {
            native_preConcat(native_object, b);
            return;
        } else if (b == native_object) {
            native_postConcat(native_object, a);
            return;
        }

        Matrix_Delegate d = sManager.getDelegate(native_object);
        Matrix_Delegate a_mtx = sManager.getDelegate(a);
        Matrix_Delegate b_mtx = sManager.getDelegate(b);
        if (d != null && a_mtx != null && b_mtx != null) {
            multiply(d.mValues, a_mtx.mValues, b_mtx.mValues);
        }
    
static booleannative_setPolyToPoly(long native_object, float[] src, int srcIndex, float[] dst, int dstIndex, int pointCount)

        // FIXME
        Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
                "Matrix.setPolyToPoly is not supported.",
                null, null /*data*/);
        return false;
    
static booleannative_setRectToRect(long native_object, RectF src, RectF dst, int stf)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return false;
        }

        if (src.isEmpty()) {
            reset(d.mValues);
            return false;
        }

        if (dst.isEmpty()) {
            d.mValues[0] = d.mValues[1] = d.mValues[2] = d.mValues[3] = d.mValues[4] = d.mValues[5]
               = d.mValues[6] = d.mValues[7] = 0;
            d.mValues[8] = 1;
        } else {
            float    tx, sx = dst.width() / src.width();
            float    ty, sy = dst.height() / src.height();
            boolean  xLarger = false;

            if (stf != ScaleToFit.FILL.nativeInt) {
                if (sx > sy) {
                    xLarger = true;
                    sx = sy;
                } else {
                    sy = sx;
                }
            }

            tx = dst.left - src.left * sx;
            ty = dst.top - src.top * sy;
            if (stf == ScaleToFit.CENTER.nativeInt || stf == ScaleToFit.END.nativeInt) {
                float diff;

                if (xLarger) {
                    diff = dst.width() - src.width() * sy;
                } else {
                    diff = dst.height() - src.height() * sy;
                }

                if (stf == ScaleToFit.CENTER.nativeInt) {
                    diff = diff / 2;
                }

                if (xLarger) {
                    tx += diff;
                } else {
                    ty += diff;
                }
            }

            d.mValues[0] = sx;
            d.mValues[4] = sy;
            d.mValues[2] = tx;
            d.mValues[5] = ty;
            d.mValues[1]  = d.mValues[3] = d.mValues[6] = d.mValues[7] = 0;

        }
        // shared cleanup
        d.mValues[8] = 1;
        return true;
    
static voidnative_setRotate(long native_object, float degrees, float px, float py)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return;
        }

        d.mValues = getRotate(degrees, px, py);
    
static voidnative_setRotate(long native_object, float degrees)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return;
        }

        setRotate(d.mValues, degrees);
    
static voidnative_setScale(long native_object, float sx, float sy, float px, float py)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return;
        }

        d.mValues = getScale(sx, sy, px, py);
    
static voidnative_setScale(long native_object, float sx, float sy)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return;
        }

        d.mValues[0] = sx;
        d.mValues[1] = 0;
        d.mValues[2] = 0;
        d.mValues[3] = 0;
        d.mValues[4] = sy;
        d.mValues[5] = 0;
        d.mValues[6] = 0;
        d.mValues[7] = 0;
        d.mValues[8] = 1;
    
static voidnative_setSinCos(long native_object, float sinValue, float cosValue, float px, float py)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return;
        }

        // TODO: do it in one pass

        // translate so that the pivot is in 0,0
        setTranslate(d.mValues, -px, -py);

        // scale
        d.postTransform(getRotate(sinValue, cosValue));
        // translate back the pivot
        d.postTransform(getTranslate(px, py));
    
static voidnative_setSinCos(long native_object, float sinValue, float cosValue)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return;
        }

        setRotate(d.mValues, sinValue, cosValue);
    
static voidnative_setSkew(long native_object, float kx, float ky, float px, float py)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return;
        }

        d.mValues = getSkew(kx, ky, px, py);
    
static voidnative_setSkew(long native_object, float kx, float ky)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return;
        }

        d.mValues[0] = 1;
        d.mValues[1] = kx;
        d.mValues[2] = -0;
        d.mValues[3] = ky;
        d.mValues[4] = 1;
        d.mValues[5] = 0;
        d.mValues[6] = 0;
        d.mValues[7] = 0;
        d.mValues[8] = 1;
    
static voidnative_setTranslate(long native_object, float dx, float dy)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return;
        }

        setTranslate(d.mValues, dx, dy);
    
static voidnative_setValues(long native_object, float[] values)

        Matrix_Delegate d = sManager.getDelegate(native_object);
        if (d == null) {
            return;
        }

        System.arraycopy(values, 0, d.mValues, 0, MATRIX_SIZE);
    
private voidpostTransform(float[] matrix)
Adds the given transformation to the current Matrix

This in effect does this = this*matrix

param
matrix

        float[] tmp = new float[9];
        multiply(tmp, mValues, matrix);
        mValues = tmp;
    
private voidpreTransform(float[] matrix)
Adds the given transformation to the current Matrix

This in effect does this = matrix*this

param
matrix

        float[] tmp = new float[9];
        multiply(tmp, matrix, mValues);
        mValues = tmp;
    
private static voidreset(float[] mtx)
Reset a matrix to the identity

        for (int i = 0, k = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++, k++) {
                mtx[k] = ((i==j) ? 1 : 0);
            }
        }
    
public voidreset()
Resets the matrix to be the identity matrix.

        reset(mValues);
    
public voidset(android.graphics.Matrix_Delegate matrix)
Sets the content of the matrix with the content of another matrix.

        System.arraycopy(matrix.mValues, 0, mValues, 0, MATRIX_SIZE);
    
public voidset(float[] values)
Sets the content of the matrix with the content of another matrix represented as an array of values.

        System.arraycopy(values, 0, mValues, 0, MATRIX_SIZE);
    
static float[]setRotate(float[] dest, float degrees)

        double rad = Math.toRadians(degrees);
        float sin = (float)Math.sin(rad);
        float cos = (float)Math.cos(rad);

        return setRotate(dest, sin, cos);
    
static float[]setRotate(float[] dest, float sin, float cos)

        dest[0] = cos;
        dest[1] = -sin;
        dest[2] = 0;
        dest[3] = sin;
        dest[4] = cos;
        dest[5] = 0;
        dest[6] = 0;
        dest[7] = 0;
        dest[8] = 1;
        return dest;
    
static float[]setTranslate(float[] dest, float dx, float dy)

        dest[0] = 1;
        dest[1] = 0;
        dest[2] = dx;
        dest[3] = 0;
        dest[4] = 1;
        dest[5] = dy;
        dest[6] = 0;
        dest[7] = 0;
        dest[8] = 1;
        return dest;