IT. Expert System.

Android Reference

Matrix


android.graphics

Class Matrix



  • public class Matrix
    extends Object
    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 Class Summary

      Nested Classes
      Modifier and Type Class and Description
      static class Matrix.ScaleToFit
      Controlls how the src rect should align into the dst rect for setRectToRect().
    • Constructor Summary

      Constructors
      Constructor and Description
      Matrix()
      Create an identity matrix
      Matrix(Matrix src)
      Create a matrix that is a (deep) copy of src
    • Method Summary

      Methods
      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()
      Invoked when the garbage collector has detected that this instance is no longer reachable.
      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[] 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, 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, 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 containing a concise, human-readable description of this object.
    • Constructor Detail

      • Matrix

        public Matrix()
        Create an identity matrix
      • Matrix

        public Matrix(Matrix src)
        Create a matrix that is a (deep) copy of src
        Parameters:
        src - The matrix to copy into this matrix
    • Method Detail

      • isIdentity

        public boolean isIdentity()
        Returns true if the matrix is identity. This maybe faster than testing if (getType() == 0)
      • rectStaysRect

        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.
      • set

        public void set(Matrix src)
        (deep) copy the src matrix into this matrix. If src is null, reset this matrix to the identity matrix.
      • equals

        public boolean equals(Object obj)
        Returns true iff obj is a Matrix and its values equal our values.
        Overrides:
        equals in class Object
        Parameters:
        obj - the object to compare this instance with.
        Returns:
        true if the specified object is equal to this Object; false otherwise.
        See Also:
        Object.hashCode()
      • reset

        public void reset()
        Set the matrix to identity
      • setTranslate

        public void setTranslate(float dx,
                        float dy)
        Set the matrix to translate by (dx, dy).
      • setScale

        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.
      • setScale

        public void setScale(float sx,
                    float sy)
        Set the matrix to scale by sx and sy.
      • setRotate

        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.
      • setRotate

        public void setRotate(float degrees)
        Set the matrix to rotate about (0,0) by the specified number of degrees.
      • setSinCos

        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.
      • setSinCos

        public void setSinCos(float sinValue,
                     float cosValue)
        Set the matrix to rotate by the specified sine and cosine values.
      • setSkew

        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.
      • setSkew

        public void setSkew(float kx,
                   float ky)
        Set the matrix to skew by sx and sy.
      • setConcat

        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
      • preTranslate

        public boolean preTranslate(float dx,
                           float dy)
        Preconcats the matrix with the specified translation. M' = M * T(dx, dy)
      • preScale

        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)
      • preScale

        public boolean preScale(float sx,
                       float sy)
        Preconcats the matrix with the specified scale. M' = M * S(sx, sy)
      • preRotate

        public boolean preRotate(float degrees,
                        float px,
                        float py)
        Preconcats the matrix with the specified rotation. M' = M * R(degrees, px, py)
      • preRotate

        public boolean preRotate(float degrees)
        Preconcats the matrix with the specified rotation. M' = M * R(degrees)
      • preSkew

        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)
      • preSkew

        public boolean preSkew(float kx,
                      float ky)
        Preconcats the matrix with the specified skew. M' = M * K(kx, ky)
      • preConcat

        public boolean preConcat(Matrix other)
        Preconcats the matrix with the specified matrix. M' = M * other
      • postTranslate

        public boolean postTranslate(float dx,
                            float dy)
        Postconcats the matrix with the specified translation. M' = T(dx, dy) * M
      • postScale

        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
      • postScale

        public boolean postScale(float sx,
                        float sy)
        Postconcats the matrix with the specified scale. M' = S(sx, sy) * M
      • postRotate

        public boolean postRotate(float degrees,
                         float px,
                         float py)
        Postconcats the matrix with the specified rotation. M' = R(degrees, px, py) * M
      • postRotate

        public boolean postRotate(float degrees)
        Postconcats the matrix with the specified rotation. M' = R(degrees) * M
      • postSkew

        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
      • postSkew

        public boolean postSkew(float kx,
                       float ky)
        Postconcats the matrix with the specified skew. M' = K(kx, ky) * M
      • postConcat

        public boolean postConcat(Matrix other)
        Postconcats the matrix with the specified matrix. M' = other * M
      • setRectToRect

        public 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.
        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.
      • setPolyToPoly

        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
      • invert

        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.
      • mapPoints

        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
      • mapVectors

        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]. Note: this method does not apply the translation associated with the matrix. Use mapPoints(float[], int, float[], int, int) if you want the translation to be applied.
        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
      • mapPoints

        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)
      • mapVectors

        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]. Note: this method does not apply the translation associated with the matrix. Use mapPoints(float[], float[]) if you want the translation to be applied.
        Parameters:
        dst - The array of dst vectors (x,y pairs)
        src - The array of src vectors (x,y pairs)
      • mapPoints

        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.
      • mapVectors

        public void mapVectors(float[] vecs)
        Apply this matrix to the array of 2D vectors, and write the transformed vectors back into the array. Note: this method does not apply the translation associated with the matrix. Use mapPoints(float[]) if you want the translation to be applied.
        Parameters:
        vecs - The array [x0, y0, x1, y1, ...] of vectors to transform.
      • mapRect

        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()
      • mapRect

        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()
      • mapRadius

        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.
      • getValues

        public void getValues(float[] values)
        Copy 9 values from the matrix into the array.
      • setValues

        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.
      • toString

        public String toString()
        Description copied from class: Object
        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 is equivalent to the following expression:
           getClass().getName() + '@' + Integer.toHexString(hashCode())

        See Writing a useful toString method if you intend implementing your own toString method.

        Overrides:
        toString in class Object
        Returns:
        a printable representation of this object.
      • toShortString

        public String toShortString()
      • printShortString

        public void printShortString(PrintWriter pw)
        Print short string, to optimize dumping.
      • finalize

        protected void finalize()
                         throws Throwable
        Description copied from class: Object
        Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.

        Note that objects that override finalize are significantly more expensive than objects that don't. Finalizers may be run a long time after the object is no longer reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup. Note also that finalizers are run on a single VM-wide finalizer thread, so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary for a class that has a native peer and needs to call a native method to destroy that peer. Even then, it's better to provide an explicit close method (and implement Closeable), and insist that callers manually dispose of instances. This works well for something like files, but less well for something like a BigInteger where typical calling code would have to deal with lots of temporaries. Unfortunately, code that creates lots of temporaries is the worst kind of code from the point of view of the single finalizer thread.

        If you must use finalizers, consider at least providing your own ReferenceQueue and having your own thread process that queue.

        Unlike constructors, finalizers are not automatically chained. You are responsible for calling super.finalize() yourself.

        Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.

        Overrides:
        finalize in class Object
        Throws:
        Throwable


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 2457 / 96488256. Delta: 0.09520 с