java.lang.Object | |
↳ | android.graphics.Matrix |
The Matrix class holds a 3x3 matrix for transforming coordinates. Matrix does not have a constructor, so it must be explicitly initialized using either reset() - to construct an identity matrix, or one of the set..() functions (e.g. setTranslate, setRotate, etc.).
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Matrix.ScaleToFit | Controlls how the src rect should align into the dst rect for setRectToRect(). |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | MPERSP_0 | ||||||||||
int | MPERSP_1 | ||||||||||
int | MPERSP_2 | ||||||||||
int | MSCALE_X | ||||||||||
int | MSCALE_Y | ||||||||||
int | MSKEW_X | ||||||||||
int | MSKEW_Y | ||||||||||
int | MTRANS_X | ||||||||||
int | MTRANS_Y |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create an identity matrix
| |||||||||||
Create a matrix that is a (deep) copy of src
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns true iff obj is a Matrix and its values equal our values.
| |||||||||||
Copy 9 values from the matrix into the array.
| |||||||||||
If this matrix can be inverted, return true and if inverse is not null,
set inverse to be the inverse of this matrix.
| |||||||||||
Returns true if the matrix is identity.
| |||||||||||
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.
| |||||||||||
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.
| |||||||||||
Apply this matrix to the array of 2D points, and write the transformed
points back into the array
| |||||||||||
Return the mean radius of a circle after it has been mapped by
this matrix.
| |||||||||||
Apply this matrix to the rectangle, and write the transformed rectangle
back into it.
| |||||||||||
Apply this matrix to the src rectangle, and write the transformed
rectangle into dst.
| |||||||||||
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.
| |||||||||||
Apply this matrix to the array of 2D vectors, and write the transformed
vectors back into the array.
| |||||||||||
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.
| |||||||||||
Postconcats the matrix with the specified matrix.
| |||||||||||
Postconcats the matrix with the specified rotation.
| |||||||||||
Postconcats the matrix with the specified rotation.
| |||||||||||
Postconcats the matrix with the specified scale.
| |||||||||||
Postconcats the matrix with the specified scale.
| |||||||||||
Postconcats the matrix with the specified skew.
| |||||||||||
Postconcats the matrix with the specified skew.
| |||||||||||
Postconcats the matrix with the specified translation.
| |||||||||||
Preconcats the matrix with the specified matrix.
| |||||||||||
Preconcats the matrix with the specified rotation.
| |||||||||||
Preconcats the matrix with the specified rotation.
| |||||||||||
Preconcats the matrix with the specified scale.
| |||||||||||
Preconcats the matrix with the specified scale.
| |||||||||||
Preconcats the matrix with the specified skew.
| |||||||||||
Preconcats the matrix with the specified skew.
| |||||||||||
Preconcats the matrix with the specified translation.
| |||||||||||
Returns true if will map a rectangle to another rectangle.
| |||||||||||
Set the matrix to identity
| |||||||||||
(deep) copy the src matrix into this matrix.
| |||||||||||
Set the matrix to the concatenation of the two specified matrices,
returning true if the the result can be represented.
| |||||||||||
Set the matrix such that the specified src points would map to the
specified dst points.
| |||||||||||
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.
| |||||||||||
Set the matrix to rotate about (0,0) by the specified number of degrees.
| |||||||||||
Set the matrix to rotate by the specified number of degrees, with a pivot
point at (px, py).
| |||||||||||
Set the matrix to scale by sx and sy.
| |||||||||||
Set the matrix to scale by sx and sy, with a pivot point at (px, py).
| |||||||||||
Set the matrix to rotate by the specified sine and cosine values, with a
pivot point at (px, py).
| |||||||||||
Set the matrix to rotate by the specified sine and cosine values.
| |||||||||||
Set the matrix to skew by sx and sy, with a pivot point at (px, py).
| |||||||||||
Set the matrix to skew by sx and sy.
| |||||||||||
Set the matrix to translate by (dx, dy).
| |||||||||||
Copy 9 values from the array into the matrix.
| |||||||||||
Returns a string containing a concise, human-readable description of this
object.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Is called before the object's memory is being reclaimed by the VM.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
|
Create a matrix that is a (deep) copy of src
src | The matrix to copy into this matrix |
---|
Returns true iff obj is a Matrix and its values equal our values.
obj | the object to compare this instance with. |
---|
true
if the specified object is equal to this Object
; false
otherwise.Copy 9 values from the matrix into the array.
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.
Returns true if the matrix is identity. This maybe faster than testing if (getType() == 0)
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].
dst | The array of dst points (x,y pairs) |
---|---|
src | The array of src points (x,y pairs) |
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].
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 |
Apply this matrix to the array of 2D points, and write the transformed points back into the array
pts | The array [x0, y0, x1, y1, ...] of points to transform. |
---|
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.
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
rect | The rectangle to transform. |
---|
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.
dst | Where the transformed rectangle is written. |
---|---|
src | The original rectangle to be transformed. |
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].
dst | The array of dst vectors (x,y pairs) |
---|---|
src | The array of src vectors (x,y pairs) |
Apply this matrix to the array of 2D vectors, and write the transformed vectors back into the array.
vecs | The array [x0, y0, x1, y1, ...] of vectors to transform. |
---|
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].
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 |
Postconcats the matrix with the specified matrix. M' = other * M
Postconcats the matrix with the specified rotation. M' = R(degrees, px, py) * M
Postconcats the matrix with the specified rotation. M' = R(degrees) * M
Postconcats the matrix with the specified scale. M' = S(sx, sy, px, py) * M
Postconcats the matrix with the specified scale. M' = S(sx, sy) * M
Postconcats the matrix with the specified skew. M' = K(kx, ky) * M
Postconcats the matrix with the specified skew. M' = K(kx, ky, px, py) * M
Postconcats the matrix with the specified translation. M' = T(dx, dy) * M
Preconcats the matrix with the specified matrix. M' = M * other
Preconcats the matrix with the specified rotation. M' = M * R(degrees)
Preconcats the matrix with the specified rotation. M' = M * R(degrees, px, py)
Preconcats the matrix with the specified scale. M' = M * S(sx, sy, px, py)
Preconcats the matrix with the specified scale. M' = M * S(sx, sy)
Preconcats the matrix with the specified skew. M' = M * K(kx, ky, px, py)
Preconcats the matrix with the specified skew. M' = M * K(kx, ky)
Preconcats the matrix with the specified translation. M' = M * T(dx, dy)
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.
(deep) copy the src matrix into this matrix. If src is null, reset this matrix to the identity matrix.
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
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.
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] |
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.
src | the source rectangle to map from. |
---|---|
dst | the destination rectangle to map to. |
stf | the ScaleToFit option |
Set the matrix to rotate about (0,0) by the specified number of degrees.
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.
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.
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.
Set the matrix to rotate by the specified sine and cosine values.
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.
Set the matrix to translate by (dx, dy).
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.
Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation simply concatenates the class name, the '@' sign and a hexadecimal representation of the object's hashCode(), that is, it is equivalent to the following expression:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Is called before the object's memory is being reclaimed by the VM. This can only happen once the VM has detected, during a run of the garbage collector, that the object is no longer reachable by any thread of the running application.
The method can be used to free system resources or perform other cleanup
before the object is garbage collected. The default implementation of the
method is empty, which is also expected by the VM, but subclasses can
override finalize()
as required. Uncaught exceptions which are
thrown during the execution of this method cause it to terminate
immediately but are otherwise ignored.
Note that the VM does guarantee that finalize()
is called at most
once for any object, but it doesn't guarantee when (if at all) finalize()
will be called. For example, object B's finalize()
can delay the execution of object A's finalize()
method and
therefore it can delay the reclamation of A's memory. To be safe, use a
ReferenceQueue, because it provides more control
over the way the VM deals with references during garbage collection.
Throwable |
---|