public class Matrix extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Matrix.ScaleToFit
Controlls how the src rect should align into the dst rect for
setRectToRect().
|
Modifier and Type | Field and Description |
---|---|
static Matrix |
IDENTITY_MATRIX |
static int |
MPERSP_0 |
static int |
MPERSP_1 |
static int |
MPERSP_2 |
static int |
MSCALE_X |
static int |
MSCALE_Y |
static int |
MSKEW_X |
static int |
MSKEW_Y |
static int |
MTRANS_X |
static int |
MTRANS_Y |
long |
native_instance |
Constructor and Description |
---|
Matrix()
Create an identity matrix
|
Matrix(Matrix src)
Create a matrix that is a (deep) copy of src
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Returns true iff obj is a Matrix and its values equal our values.
|
protected void |
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
void |
getValues(float[] values)
Copy 9 values from the matrix into the array.
|
int |
hashCode()
Returns a hash code value for the object.
|
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 |
isAffine()
Gets whether this matrix is affine.
|
boolean |
isIdentity()
Returns true if the matrix is identity.
|
void |
mapPoints(float[] pts)
Apply this matrix to the array of 2D points, and write the transformed
points back into the array
|
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.
|
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[] vecs)
Apply this matrix to the array of 2D vectors, and write the transformed
vectors back into the array.
|
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[] 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)
Postconcats the matrix with the specified rotation.
|
boolean |
postRotate(float degrees,
float px,
float py)
Postconcats the matrix with the specified rotation.
|
boolean |
postScale(float sx,
float sy)
Postconcats the matrix with the specified scale.
|
boolean |
postScale(float sx,
float sy,
float px,
float py)
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)
Preconcats the matrix with the specified scale.
|
boolean |
preScale(float sx,
float sy,
float px,
float py)
Preconcats the matrix with the specified scale.
|
boolean |
preSkew(float kx,
float ky)
Preconcats the matrix with the specified skew.
|
boolean |
preSkew(float kx,
float ky,
float px,
float py)
Preconcats the matrix with the specified skew.
|
boolean |
preTranslate(float dx,
float dy)
Preconcats the matrix with the specified translation.
|
void |
printShortString(PrintWriter pw)
Print short string, to optimize dumping.
|
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 and
return true.
|
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,
Matrix.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)
Set the matrix to rotate by the specified sine and cosine values.
|
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 |
setSkew(float kx,
float ky)
Set the matrix to skew by sx and sy.
|
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 |
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 |
toShortString() |
void |
toShortString(StringBuilder sb) |
String |
toString()
Returns a string representation of the object.
|
public static final int MSCALE_X
public static final int MSKEW_X
public static final int MTRANS_X
public static final int MSKEW_Y
public static final int MSCALE_Y
public static final int MTRANS_Y
public static final int MPERSP_0
public static final int MPERSP_1
public static final int MPERSP_2
public static final Matrix IDENTITY_MATRIX
public long native_instance
public Matrix()
public Matrix(Matrix src)
src
- The matrix to copy into this matrixpublic boolean isIdentity()
public boolean isAffine()
public boolean rectStaysRect()
public void set(Matrix src)
public boolean equals(Object obj)
equals
in class Object
obj
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.Object.hashCode()
,
HashMap
public int hashCode()
Object
HashMap
.
The general contract of hashCode
is:
hashCode
method
must consistently return the same integer, provided no information
used in equals
comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode
method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object
does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
JavaTM programming language.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public void reset()
public void setTranslate(float dx, float dy)
public void setScale(float sx, float sy, float px, float py)
public void setScale(float sx, float sy)
public void setRotate(float degrees, float px, float py)
public void setRotate(float degrees)
public void setSinCos(float sinValue, float cosValue, float px, float py)
public void setSinCos(float sinValue, float cosValue)
public void setSkew(float kx, float ky, float px, float py)
public void setSkew(float kx, float ky)
public boolean setConcat(Matrix a, Matrix b)
Either of the two matrices may also be the target matrix, that is
matrixA.setConcat(matrixA, matrixB);
is valid.
In Build.VERSION_CODES.GINGERBREAD_MR1
and below, this
function returns true only if the result can be represented. In
Build.VERSION_CODES.HONEYCOMB
and above, it always returns true.
public boolean preTranslate(float dx, float dy)
public boolean preScale(float sx, float sy, float px, float py)
public boolean preScale(float sx, float sy)
public boolean preRotate(float degrees, float px, float py)
public boolean preRotate(float degrees)
public boolean preSkew(float kx, float ky, float px, float py)
public boolean preSkew(float kx, float ky)
public boolean preConcat(Matrix other)
public boolean postTranslate(float dx, float dy)
public boolean postScale(float sx, float sy, float px, float py)
public boolean postScale(float sx, float sy)
public boolean postRotate(float degrees, float px, float py)
public boolean postRotate(float degrees)
public boolean postSkew(float kx, float ky, float px, float py)
public boolean postSkew(float kx, float ky)
public boolean postConcat(Matrix other)
public boolean setRectToRect(RectF src, RectF dst, Matrix.ScaleToFit stf)
src
- the source rectangle to map from.dst
- the destination rectangle to map to.stf
- the ScaleToFit optionpublic boolean setPolyToPoly(float[] src, int srcIndex, float[] dst, int dstIndex, int pointCount)
src
- The array of src [x,y] pairs (points)srcIndex
- Index of the first pair of src valuesdst
- The array of dst [x,y] pairs (points)dstIndex
- Index of the first pair of dst valuespointCount
- The number of pairs/points to be used. Must be [0..4]public boolean invert(Matrix inverse)
public void mapPoints(float[] dst, int dstIndex, float[] src, int srcIndex, int pointCount)
dst
- The array of dst points (x,y pairs)dstIndex
- The index of the first [x,y] pair of dst floatssrc
- The array of src points (x,y pairs)srcIndex
- The index of the first [x,y] pair of src floatspointCount
- The number of points (x,y pairs) to transformpublic void mapVectors(float[] dst, int dstIndex, float[] src, int srcIndex, int vectorCount)
mapPoints(float[], int, float[], int, int)
if you want the translation
to be applied.dst
- The array of dst vectors (x,y pairs)dstIndex
- The index of the first [x,y] pair of dst floatssrc
- The array of src vectors (x,y pairs)srcIndex
- The index of the first [x,y] pair of src floatsvectorCount
- The number of vectors (x,y pairs) to transformpublic void mapPoints(float[] dst, float[] src)
dst
- The array of dst points (x,y pairs)src
- The array of src points (x,y pairs)public void mapVectors(float[] dst, float[] src)
mapPoints(float[], float[])
if you want the translation to be applied.dst
- The array of dst vectors (x,y pairs)src
- The array of src vectors (x,y pairs)public void mapPoints(float[] pts)
pts
- The array [x0, y0, x1, y1, ...] of points to transform.public void mapVectors(float[] vecs)
mapPoints(float[])
if you want the translation to be applied.vecs
- The array [x0, y0, x1, y1, ...] of vectors to transform.public boolean mapRect(RectF dst, RectF src)
dst
- Where the transformed rectangle is written.src
- The original rectangle to be transformed.public boolean mapRect(RectF rect)
rect
- The rectangle to transform.public float mapRadius(float radius)
public void getValues(float[] values)
public void setValues(float[] values)
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public String toShortString()
public void toShortString(StringBuilder sb)
public void printShortString(PrintWriter pw)
protected void finalize() throws Throwable
Object
finalize
method to dispose of
system resources or to perform other cleanup.
The general contract of finalize
is that it is invoked
if and when the JavaTM virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The finalize
method may take any action, including
making this object available again to other threads; the usual purpose
of finalize
, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.
The finalize
method of class Object
performs no
special action; it simply returns normally. Subclasses of
Object
may override this definition.
The Java programming language does not guarantee which thread will
invoke the finalize
method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.
After the finalize
method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.
The finalize
method is never invoked more than once by a Java
virtual machine for any given object.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.