Reference:Android.graphics.Matrix
From Triled Wiki
android.graphics
public class android.graphics.Matrix
| java.lang.Object | ||
| android.graphics.Matrix | ||
[edit] Nested Classes
| Matrix.ScaleToFit | Controlls how the src rect should align into the dst rect for setRectToRect(). |
[edit] Summary
[edit] Constants
| Value | ||||
|---|---|---|---|---|
| int | MPERSP_0 | 6 | 0x00000006 | |
| int | MPERSP_1 | 7 | 0x00000007 | |
| int | MPERSP_2 | 8 | 0x00000008 | |
| int | MSCALE_X | 0 | 0x00000000 | |
| int | MSCALE_Y | 4 | 0x00000004 | |
| int | MSKEW_X | 1 | 0x00000001 | |
| int | MSKEW_Y | 3 | 0x00000003 | |
| int | MTRANS_X | 2 | 0x00000002 | |
| int | MTRANS_Y | 5 | 0x00000005 |
[edit] Public Constructors
| Matrix () | |||||
| Create an identity matrix | |||||
| Matrix (Matrix src) | |||||
| Create a matrix that is a (deep) copy of src | |||||
[edit] Public Methods
| boolean | equals (Object obj) | ||||
| Returns true iff obj is a Matrix and its values equal our values. | |||||
| void | getValues (float[] values) | ||||
| Copy 9 values from the matrix into the array. | |||||
| boolean | invert (Matrix inverse) | ||||
| If this matrix can be inverted, return true and if inverse is not null, set inverse to be the inverse of this matrix. | |||||
| boolean | isIdentity () | ||||
| Returns true if the matrix is identity. | |||||
| void | mapPoints (float[] dst, float[] src) | ||||
| 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. | |||||
| void | mapPoints (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. | |||||
| void | mapPoints (float[] pts) | ||||
| Apply this matrix to the array of 2D points, and write the transformed points back into the array | |||||
| float | mapRadius (float radius) | ||||
| Return the mean radius of a circle after it has been mapped by this matrix. | |||||
| boolean | mapRect (RectF rect) | ||||
| Apply this matrix to the rectangle, and write the transformed rectangle back into it. | |||||
| boolean | mapRect (RectF dst, RectF src) | ||||
| Apply this matrix to the src rectangle, and write the transformed rectangle into dst. | |||||
| void | mapVectors (float[] dst, float[] src) | ||||
| Apply this matrix to the array of 2D vectors specified by src, and write the transformed vectors into the array of vectors specified by dst. | |||||
| void | mapVectors (float[] vecs) | ||||
| Apply this matrix to the array of 2D vectors, and write the transformed vectors back into the array. | |||||
| void | mapVectors (float[] dst, int dstIndex, float[] src, int srcIndex, int vectorCount) | ||||
| Apply this matrix to the array of 2D vectors specified by src, and write the transformed vectors into the array of vectors specified by dst. | |||||
| boolean | postConcat (Matrix other) | ||||
| Postconcats the matrix with the specified matrix. | |||||
| boolean | postRotate (float degrees, float px, float py) | ||||
| Postconcats the matrix with the specified rotation. | |||||
| boolean | postRotate (float degrees) | ||||
| Postconcats the matrix with the specified rotation. | |||||
| boolean | postScale (float sx, float sy, float px, float py) | ||||
| Postconcats the matrix with the specified scale. | |||||
| boolean | postScale (float sx, float sy) | ||||
| Postconcats the matrix with the specified scale. | |||||
| boolean | postSkew (float kx, float ky) | ||||
| Postconcats the matrix with the specified skew. | |||||
| boolean | postSkew (float kx, float ky, float px, float py) | ||||
| Postconcats the matrix with the specified skew. | |||||
| boolean | postTranslate (float dx, float dy) | ||||
| Postconcats the matrix with the specified translation. | |||||
| boolean | preConcat (Matrix other) | ||||
| Preconcats the matrix with the specified matrix. | |||||
| boolean | preRotate (float degrees) | ||||
| Preconcats the matrix with the specified rotation. | |||||
| boolean | preRotate (float degrees, float px, float py) | ||||
| Preconcats the matrix with the specified rotation. | |||||
| boolean | preScale (float sx, float sy, float px, float py) | ||||
| Preconcats the matrix with the specified scale. | |||||
| boolean | preScale (float sx, float sy) | ||||
| Preconcats the matrix with the specified scale. | |||||
| boolean | preSkew (float kx, float ky, float px, float py) | ||||
| Preconcats the matrix with the specified skew. | |||||
| boolean | preSkew (float kx, float ky) | ||||
| Preconcats the matrix with the specified skew. | |||||
| boolean | preTranslate (float dx, float dy) | ||||
| Preconcats the matrix with the specified translation. | |||||
| boolean | rectStaysRect () | ||||
| Returns true if will map a rectangle to another rectangle. | |||||
| void | reset () | ||||
| Set the matrix to identity | |||||
| void | set (Matrix src) | ||||
| (deep) copy the src matrix into this matrix | |||||
| boolean | setConcat (Matrix a, Matrix b) | ||||
| Set the matrix to the concatenation of the two specified matrices, returning true if the the result can be represented. | |||||
| boolean | setPolyToPoly (float[] src, int srcIndex, float[] dst, int dstIndex, int pointCount) | ||||
| Set the matrix such that the specified src points would map to the specified dst points. | |||||
| boolean | setRectToRect (RectF src, RectF dst, ScaleToFit stf) | ||||
| Set the matrix to the scale and translate values that map the source rectangle to the destination rectangle, returning true if the the result can be represented. | |||||
| void | setRotate (float degrees) | ||||
| Set the matrix to rotate about (0,0) by the specified number of degrees. | |||||
| void | setRotate (float degrees, float px, float py) | ||||
| Set the matrix to rotate by the specified number of degrees, with a pivot point at (px, py). | |||||
| void | setScale (float sx, float sy) | ||||
| Set the matrix to scale by sx and sy. | |||||
| void | setScale (float sx, float sy, float px, float py) | ||||
| Set the matrix to scale by sx and sy, with a pivot point at (px, py). | |||||
| void | setSinCos (float sinValue, float cosValue, float px, float py) | ||||
| Set the matrix to rotate by the specified sine and cosine values, with a pivot point at (px, py). | |||||
| void | setSinCos (float sinValue, float cosValue) | ||||
| Set the matrix to rotate by the specified sine and cosine values. | |||||
| void | setSkew (float kx, float ky, float px, float py) | ||||
| Set the matrix to skew by sx and sy, with a pivot point at (px, py). | |||||
| void | setSkew (float kx, float ky) | ||||
| Set the matrix to skew by sx and sy. | |||||
| void | setTranslate (float dx, float dy) | ||||
| Set the matrix to translate by (dx, dy). | |||||
| void | setValues (float[] values) | ||||
| Copy 9 values from the array into the matrix. | |||||
| String | toString () | ||||
| Answers a string containing a concise, human-readable description of the receiver. | |||||
[edit] Protected Methods
| void | finalize () | ||||
| Called by the virtual machine when there are no longer any (non-weak) references to the receiver. | |||||
[edit] Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
[edit] Details
[edit] Constants
[edit] public static final int MPERSP_0
Constant Value: 6 (0x00000006)
[edit] public static final int MPERSP_1
Constant Value: 7 (0x00000007)
[edit] public static final int MPERSP_2
Constant Value: 8 (0x00000008)
[edit] public static final int MSCALE_X
Constant Value: 0 (0x00000000)
[edit] public static final int MSCALE_Y
Constant Value: 4 (0x00000004)
[edit] public static final int MSKEW_X
Constant Value: 1 (0x00000001)
[edit] public static final int MSKEW_Y
Constant Value: 3 (0x00000003)
[edit] public static final int MTRANS_X
Constant Value: 2 (0x00000002)
[edit] public static final int MTRANS_Y
Constant Value: 5 (0x00000005)
[edit] Public Constructors
[edit] public Matrix()
Create an identity matrix
[edit] public Matrix(Matrix src)
Create a matrix that is a (deep) copy of src
Parameters
| src | The matrix to copy into this matrix |
|---|
[edit] Public Methods
[edit] public boolean equals(Object obj)
Returns true iff obj is a Matrix and its values equal our values.
Parameters
| obj | Object the object to compare with this object. |
|---|
[edit] public void getValues(float[] values)
Copy 9 values from the matrix into the array.
[edit] public boolean invert(Matrix inverse)
If this matrix can be inverted, return true and if inverse is not null, set inverse to be the inverse of this matrix. If this matrix cannot be inverted, ignore inverse and return false.
[edit] public boolean isIdentity()
Returns true if the matrix is identity. This maybe faster than testing if (getType() == 0)
[edit] public void mapPoints(float[] dst, float[] src)
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].
Parameters
| dst | The array of dst points (x,y pairs) |
|---|---|
| src | The array of src points (x,y pairs) |
[edit] public void mapPoints(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].
Parameters
| dst | The array of dst points (x,y pairs) |
|---|---|
| dstIndex | The index of the first [x,y] pair of dst floats |
| src | The array of src points (x,y pairs) |
| srcIndex | The index of the first [x,y] pair of src floats |
| pointCount | The number of points (x,y pairs) to transform |
[edit] public void mapPoints(float[] pts)
Apply this matrix to the array of 2D points, and write the transformed points back into the array
Parameters
| pts | The array [x0, y0, x1, y1, ...] of points to transform. |
|---|
[edit] public float mapRadius(float radius)
Return the mean radius of a circle after it has been mapped by this matrix. NOTE: in perspective this value assumes the circle has its center at the origin.
[edit] public boolean mapRect(RectF rect)
Apply this matrix to the rectangle, and write the transformed rectangle back into it. This is accomplished by transforming the 4 corners of rect, and then setting it to the bounds of those points
Parameters
| rect | The rectangle to transform. |
|---|
Returns
- the result of calling rectStaysRect()
[edit] public boolean mapRect(RectF dst, RectF src)
Apply this matrix to the src rectangle, and write the transformed rectangle into dst. This is accomplished by transforming the 4 corners of src, and then setting dst to the bounds of those points.
Parameters
| dst | Where the transformed rectangle is written. |
|---|---|
| src | The original rectangle to be transformed. |
Returns
- the result of calling rectStaysRect()
[edit] public void mapVectors(float[] dst, float[] src)
Apply this matrix to the array of 2D vectors specified by src, and write the transformed vectors into the array of vectors specified by dst. The two arrays represent their "vectors" as pairs of floats [x, y].
Parameters
| dst | The array of dst vectors (x,y pairs) |
|---|---|
| src | The array of src vectors (x,y pairs) |
[edit] public void mapVectors(float[] vecs)
Apply this matrix to the array of 2D vectors, and write the transformed vectors back into the array.
Parameters
| vecs | The array [x0, y0, x1, y1, ...] of vectors to transform. |
|---|
[edit] public void mapVectors(float[] dst, int dstIndex, float[] src, int srcIndex, int vectorCount)
Apply this matrix to the array of 2D vectors specified by src, and write the transformed vectors into the array of vectors specified by dst. The two arrays represent their "vectors" as pairs of floats [x, y].
Parameters
| dst | The array of dst vectors (x,y pairs) |
|---|---|
| dstIndex | The index of the first [x,y] pair of dst floats |
| src | The array of src vectors (x,y pairs) |
| srcIndex | The index of the first [x,y] pair of src floats |
| vectorCount | The number of vectors (x,y pairs) to transform |
[edit] public boolean postConcat(Matrix other)
Postconcats the matrix with the specified matrix. M' = other * M
[edit] public boolean postRotate(float degrees, float px, float py)
Postconcats the matrix with the specified rotation. M' = R(degrees, px, py) * M
[edit] public boolean postRotate(float degrees)
Postconcats the matrix with the specified rotation. M' = R(degrees) * M
[edit] public boolean postScale(float sx, float sy, float px, float py)
Postconcats the matrix with the specified scale. M' = S(sx, sy, px, py) * M
[edit] public boolean postScale(float sx, float sy)
Postconcats the matrix with the specified scale. M' = S(sx, sy) * M
[edit] public boolean postSkew(float kx, float ky)
Postconcats the matrix with the specified skew. M' = K(kx, ky) * M
[edit] public boolean postSkew(float kx, float ky, float px, float py)
Postconcats the matrix with the specified skew. M' = K(kx, ky, px, py) * M
[edit] public boolean postTranslate(float dx, float dy)
Postconcats the matrix with the specified translation. M' = T(dx, dy) * M
[edit] public boolean preConcat(Matrix other)
Preconcats the matrix with the specified matrix. M' = M * other
[edit] public boolean preRotate(float degrees)
Preconcats the matrix with the specified rotation. M' = M * R(degrees)
[edit] public boolean preRotate(float degrees, float px, float py)
Preconcats the matrix with the specified rotation. M' = M * R(degrees, px, py)
[edit] public boolean preScale(float sx, float sy, float px, float py)
Preconcats the matrix with the specified scale. M' = M * S(sx, sy, px, py)
[edit] public boolean preScale(float sx, float sy)
Preconcats the matrix with the specified scale. M' = M * S(sx, sy)
[edit] public boolean preSkew(float kx, float ky, float px, float py)
Preconcats the matrix with the specified skew. M' = M * K(kx, ky, px, py)
[edit] public boolean preSkew(float kx, float ky)
Preconcats the matrix with the specified skew. M' = M * K(kx, ky)
[edit] public boolean preTranslate(float dx, float dy)
Preconcats the matrix with the specified translation. M' = M * T(dx, dy)
[edit] public boolean rectStaysRect()
Returns true if will map a rectangle to another rectangle. This can be true if the matrix is identity, scale-only, or rotates a multiple of 90 degrees.
[edit] public void reset()
Set the matrix to identity
[edit] public void set(Matrix src)
(deep) copy the src matrix into this matrix
[edit] public boolean setConcat(Matrix a, Matrix b)
Set the matrix to the concatenation of the two specified matrices, returning true if the the result can be represented. Either of the two matrices may also be the target matrix. this = a * b
[edit] public boolean setPolyToPoly(float[] src, int srcIndex, float[] dst, int dstIndex, int pointCount)
Set the matrix such that the specified src points would map to the specified dst points. The "points" are represented as an array of floats, order [x0, y0, x1, y1, ...], where each "point" is 2 float values.
Parameters
| src | The array of src [x,y] pairs (points) |
|---|---|
| srcIndex | Index of the first pair of src values |
| dst | The array of dst [x,y] pairs (points) |
| dstIndex | Index of the first pair of dst values |
| pointCount | The number of pairs/points to be used. Must be [0..4] |
Returns
- true if the matrix was set to the specified transformation
[edit] public boolean setRectToRect(RectF src, RectF dst, ScaleToFit stf)
Set the matrix to the scale and translate values that map the source rectangle to the destination rectangle, returning true if the the result can be represented.
Parameters
| src | the source rectangle to map from. |
|---|---|
| dst | the destination rectangle to map to. |
| stf | the ScaleToFit option |
Returns
- true if the matrix can be represented by the rectangle mapping.
[edit] public void setRotate(float degrees)
Set the matrix to rotate about (0,0) by the specified number of degrees.
[edit] public void setRotate(float degrees, float px, float py)
Set the matrix to rotate by the specified number of degrees, with a pivot point at (px, py). The pivot point is the coordinate that should remain unchanged by the specified transformation.
[edit] public void setScale(float sx, float sy)
Set the matrix to scale by sx and sy.
[edit] public void setScale(float sx, float sy, float px, float py)
Set the matrix to scale by sx and sy, with a pivot point at (px, py). The pivot point is the coordinate that should remain unchanged by the specified transformation.
[edit] public void setSinCos(float sinValue, float cosValue, float px, float py)
Set the matrix to rotate by the specified sine and cosine values, with a pivot point at (px, py). The pivot point is the coordinate that should remain unchanged by the specified transformation.
[edit] public void setSinCos(float sinValue, float cosValue)
Set the matrix to rotate by the specified sine and cosine values.
[edit] public void setSkew(float kx, float ky, float px, float py)
Set the matrix to skew by sx and sy, with a pivot point at (px, py). The pivot point is the coordinate that should remain unchanged by the specified transformation.
[edit] public void setSkew(float kx, float ky)
Set the matrix to skew by sx and sy.
[edit] public void setTranslate(float dx, float dy)
Set the matrix to translate by (dx, dy).
[edit] public void setValues(float[] values)
Copy 9 values from the array into the matrix. Depending on the implementation of Matrix, these may be transformed into 16.16 integers in the Matrix, such that a subsequent call to getValues() will not yield exactly the same values.
[edit] public String toString()
Answers a string containing a concise, human-readable description of the receiver.
[edit] Protected Methods
[edit] protected void finalize()
Called by the virtual machine when there are no longer any (non-weak) references to the receiver. Subclasses can use this facility to guarantee that any associated resources are cleaned up before the receiver is garbage collected. Uncaught exceptions which are thrown during the running of the method cause it to terminate immediately, but are otherwise ignored.
Note: The virtual machine assumes that the implementation in class Object is empty.
Throws
| Throwable |
|---|
[edit] References
- Original documentation page for Android SDK build m5-rc15e - 14 apr 2008 17:27
