com.aspose.pdf

Interfaces

Classes

Enums

Exceptions

com.aspose.pdf

Class Matrix



  • public final class Matrix
    extends Object

    Class represents transformation matrix.

    • Constructor Summary

      Constructors 
      Constructor and Description
      Matrix()
      Constructor creates stanrard 1 to 1 matrix: [ A B C D E F ] = [ 1, 0, 0, 1, 0, 0]
      Matrix(double[] matrixArray)
      Constructor accepts a matrix with following array representation: [ A B C D E F ]
      Matrix(double a, double b, double c, double d, double e, double f)
      Initializes transformation matrix with specified coefficients.
      Matrix(float[] matrixArray)
      Constructor accepts a matrix with following array representation: [ A B C D E F ]
      Matrix(Matrix matrix)
      Constructor accepts a matrix to create a copy
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      Matrix add(Matrix other)
      Adds matrix to other matrix.
      boolean equals(Object obj)
      Compares matrix agains other object.
      double getA()
      Get A member of the transformation matrix.
      static double getAngle(int rotation)
      Transaltes rotation into angle (degrees)
      double getB()
      Get B member of the transformation matrix.
      double getC()
      Get C member of the transformation matrix.
      double getD()
      Get D member of the transformation matrix.
      double getE()
      Get E member of the transformation matrix.
      float[] getElements()
      Elements of the matrix.
      double getF()
      Get F member of the transformation matrix.
      com.aspose.pdf.engine.data.IPdfArray getMatrix(com.aspose.pdf.engine.data.ITrailerable trailer)
      Translates matrix into PDF array obect.
      int hashCode()
      Hash-code for object.
      Matrix multiply(Matrix other)
      Multiplies the matrix by other matrix.
      Matrix reverse()
      Calculates reverse matrix.
      static Matrix rotation(double alpha)
      Creates matrix for given rotation angle.
      static Matrix scale(double x, double y)
      Creates matrix for given scale.
      void setA(double value)
      Set A member of the transformation matrix.
      void setB(double value)
      Set B member of the transformation matrix.
      void setC(double value)
      Set C member of the transformation matrix.
      void setD(double value)
      Set D member of the transformation matrix.
      void setE(double value)
      Set E member of the transformation matrix.
      void setF(double value)
      Set F member of the transformation matrix.
      static Matrix skew(double alpha, double beta)
      Creates matrix for given rotation angle.
      String toString()
      Returns text representation of the matrix.
      Point transform(Point p)
      Transforms point using this matrix.
      Rectangle transform(Rectangle rect)
      Transformes rectangle.
    • Constructor Detail

      • Matrix

        public Matrix()

        Constructor creates stanrard 1 to 1 matrix: [ A B C D E F ] = [ 1, 0, 0, 1, 0, 0]


         
         
         Matrix m = new Matrix();
         
      • Matrix

        public Matrix(double[] matrixArray)

        Constructor accepts a matrix with following array representation: [ A B C D E F ]


         
         double[] c = new double[] { 1, 0, 0, 1, 10, 20 };
         Matrix m = new Matrix(c);
         
        Parameters:
        matrixArray - Matrix data array.
      • Matrix

        public Matrix(float[] matrixArray)

        Constructor accepts a matrix with following array representation: [ A B C D E F ]


         
         double[] c = new double[] { 1, 0, 0, 1, 10, 20 };
         Matrix m = new Matrix(c);
         
        Parameters:
        matrixArray - Matrix data array.
      • Matrix

        public Matrix(Matrix matrix)

        Constructor accepts a matrix to create a copy

        Parameters:
        matrix - Matrix object.
      • Matrix

        public Matrix(double a,
              double b,
              double c,
              double d,
              double e,
              double f)

        Initializes transformation matrix with specified coefficients.


         
         
         Matrix m = new Matrix(1, 0, 0, 1, 3, 3);
         
        Parameters:
        a - A matrix value.
        b - B matrix value.
        c - C matrix value.
        d - D matrix value.
        e - E matrix value.
        f - F matrix value.
    • Method Detail

      • getA

        public double getA()

        Get A member of the transformation matrix.

        Returns:
        double value
      • setA

        public void setA(double value)

        Set A member of the transformation matrix.

        Parameters:
        value - double value
      • getB

        public double getB()

        Get B member of the transformation matrix.

        Returns:
        double value
      • setB

        public void setB(double value)

        Set B member of the transformation matrix.

        Parameters:
        value - double value
      • getC

        public double getC()

        Get C member of the transformation matrix.

        Returns:
        double value
      • setC

        public void setC(double value)

        Set C member of the transformation matrix.

        Parameters:
        value - double value
      • getD

        public double getD()

        Get D member of the transformation matrix.

        Returns:
        double value
      • setD

        public void setD(double value)

        Set D member of the transformation matrix.

        Parameters:
        value - double value
      • getE

        public double getE()

        Get E member of the transformation matrix.

        Returns:
        double value
      • setE

        public void setE(double value)

        Set E member of the transformation matrix.

        Parameters:
        value - double value
      • getF

        public double getF()

        Get F member of the transformation matrix.

        Returns:
        double value
      • setF

        public void setF(double value)

        Set F member of the transformation matrix.

        Parameters:
        value - double value
      • getElements

        public float[] getElements()

        Elements of the matrix.

        Returns:
        float[] array
      • toString

        public String toString()

        Returns text representation of the matrix.

        Overrides:
        toString in class Object
        Returns:
        String representation for the matrix
      • equals

        public boolean equals(Object obj)

        Compares matrix agains other object.

        Overrides:
        equals in class Object
        Parameters:
        obj - Object to compare.
        Returns:
        Returns true is other object is Matrix and all matrix member are equal to correspondim members of the matrix
      • getMatrix

        public com.aspose.pdf.engine.data.IPdfArray getMatrix(com.aspose.pdf.engine.data.ITrailerable trailer)

        Translates matrix into PDF array obect.

        Parameters:
        trailer - Trailerable object
        Returns:
        Result of converting
      • rotation

        public static Matrix rotation(double alpha)

        Creates matrix for given rotation angle.


         
         Matrix m = Matrix.Rotation(Math.PI / 2);
         
        Parameters:
        alpha - Rotation angle in radians.
        Returns:
        Transformation matrix.
      • skew

        public static Matrix skew(double alpha,
                  double beta)
        Creates matrix for given rotation angle.
         
         Matrix m = Matrix.skew(Math.PI / 2, Math.PI / 2); 
        Parameters:
        alpha - Skew x angle in radians.
        beta - Skew y angle in radians.
        Returns:
        Transformation matrix.
      • scale

        public static Matrix scale(double x,
                   double y)

        Creates matrix for given scale.


         
         Matrix m = Matrix.scale(x, y);
         
        Parameters:
        x - Scale x.
        y - Scale y.
        Returns:
        Transformation matrix.
      • getAngle

        public static double getAngle(int rotation)

        Transaltes rotation into angle (degrees)


         
         double angle = Matrix.getAngle(Rotation.on90);
         Matrix m = Matrix.rotation(angle);
         
        Parameters:
        rotation - Rotation value.
        Returns:
        Angle value.
      • multiply

        public Matrix multiply(Matrix other)

        Multiplies the matrix by other matrix.


         
         Matrix a = new Matrix(new double[] { 1, 0, 0, 1, 10, 20 });
         Matrix b = new Matrix(new double[] { 0, -1, 1, 0, 0, 0 } );
         Matrix c= a.multiply(b);
         
        Parameters:
        other - Multiplier matrix.
        Returns:
        Result of multiplication.
      • add

        public Matrix add(Matrix other)

        Adds matrix to other matrix.

        Parameters:
        other - Matrix to be added.
        Returns:
        Result of matrix add.
      • transform

        public Point transform(Point p)

        Transforms point using this matrix.


         
         Matrix m = new Matrix(new double[] { 1, 0, 0, 1, 10, 20 } );
         Point p = new Point(5, 5);
         Point p1 = m.transform(p);
         
        Parameters:
        p - Point which will be transformed.
        Returns:
        Transformation result.
      • transform

        public Rectangle transform(Rectangle rect)

        Transformes rectangle. If angle is not 90 * N degrees then bounding rectangle is returned.


         
         Matrix m = new Matrix(new double[] { 1, 0, 0, 1, 10, 20 } );
         Rectangle r = new Rectangle(0, 0, 100, 100);
         Rectangle r1 = m.transform(r1);
         
        Parameters:
        rect - Rectangle to be transformed.
        Returns:
        Transformed rectangle.
      • reverse

        public Matrix reverse()

        Calculates reverse matrix.


         
         Matrix m = Matrix.rotation(Math.PI / 2);
         Matrix m1 = m.reverse();
         
        Returns:
        Reverse matrix.
      • hashCode

        public int hashCode()

        Hash-code for object.

        Overrides:
        hashCode in class Object
        Returns:
        Hash-code.