Class JDFMatrix

All Implemented Interfaces:
Serializable, Cloneable, Iterable<Object>, Collection<Object>, List<Object>, RandomAccess, JDFBaseDataTypes

public class JDFMatrix extends JDFNumList
This class represents a transformation matrix consisting of 6 transformation values a, b, c, d, tx, ty all values are double values. The matrix looks like:
  [ x']   [  a  b  tx  ] [ x ]   [ m00x + m01y + m02 ]
  [ y'] = [  c  d  ty  ] [ y ] = [ m10x + m11y + m12 ]
  [ 1 ]   [  0  0  1   ] [ 1 ]   [         1         ]
 
See Also:
  • Constructor Details

    • JDFMatrix

      public JDFMatrix()
      constructs a matrix with all values set to 0.0 Double
    • JDFMatrix

      @Deprecated public JDFMatrix(Vector v) throws DataFormatException
      Deprecated.
      use typesafe constructors
      constructs a matrix with all values set via a Vector of Double objects
      Parameters:
      Vector - v - the given Vector
      Throws:
      DataFormatException - - if the Vector has not a valid format
    • JDFMatrix

      public JDFMatrix(double degrees, double x, double y)
      constructs a matrix with all values set via arotation and a shift
      Parameters:
      degrees - - the rotation in degrees
      x - the X shift
      y - the Y shift
      Throws:
      DataFormatException - - if the Vector has not a valid format
    • JDFMatrix

      public JDFMatrix(JDFElement.EnumOrientation orientation, double w, double h)
      constructs a matrix with all values set via an enumerated orientation
      Parameters:
      orientation - - the named orientation
      w - the width of the unrotated object to transform
      h - the height of the unrotated object to transform
      Throws:
      DataFormatException - - if the Vector has not a valid format
    • JDFMatrix

      public JDFMatrix(String s) throws DataFormatException
      constructs a matrix with all values set via a String
      Parameters:
      s - the given String
      Throws:
      DataFormatException - - if the String has not a valid format
    • JDFMatrix

      public JDFMatrix(JDFNumList nl) throws DataFormatException
      constructs a rectangle with all values set via a JDFNumberList
      Parameters:
      nl - the given number list
      Throws:
      DataFormatException - - if the JDFNumberList has not a valid format
    • JDFMatrix

      public JDFMatrix(JDFMatrix matrix)
      copy constructor
      Parameters:
      matrix - the given number list
    • JDFMatrix

      public JDFMatrix(JDFRectangle rect)
      constructs a rectangle with all values set via a JDFNumberList
      Parameters:
      rect - the given number list
    • JDFMatrix

      public JDFMatrix(double a, double b, double c, double d, double tx, double ty)
      constructs a new JDFMatrix with the given double values
      Parameters:
      a - position 01 of the transformation matrix
      b - position 02 of the transformation matrix
      c - position 10 of the transformation matrix
      d - position 11 of the transformation matrix
      tx - position 03 of the transformation matrix
      ty - position 13 of the transformation matrix
  • Method Details

    • getUnitMatrix

      public static JDFMatrix getUnitMatrix()
      Returns:
      a copy of the unit matrix
    • clone

      public JDFMatrix clone()
      Overrides:
      clone in class JDFNumList
      See Also:
    • createMatrix

      public static JDFMatrix createMatrix(String s)
      factory for JDFXYPair that silently returns null in case of illegal strings
      Parameters:
      s - the string to parse
      Returns:
      the JDFXYPair, null if s is not compatible
    • isValid

      public boolean isValid() throws DataFormatException
      isValid - true if the size of the vector is 6 and all instances are Double types
      Specified by:
      isValid in class JDFNumList
      Returns:
      boolean - true if all instances are Double or Integer types
      Throws:
      DataFormatException - - if the Vector has not a valid format
    • getA

      public double getA()
      getA - returns the first coordinate
      Returns:
      the first coordinate
    • setA

      public void setA(double p_a)
      setA - sets the first coordinate
      Parameters:
      p_a - the first coordinate
    • getB

      public double getB()
      getB - returns the second coordinate
      Returns:
      double - the second coordinate
    • setB

      public void setB(double p_b)
      setB - sets the second coordinate
      Parameters:
      p_b - the first coordinate
    • getC

      public double getC()
      getC - returns the third coordinate
      Returns:
      double - the third coordinate
    • setC

      public void setC(double p_c)
      setC - sets the third coordinate
      Parameters:
      p_c - the third coordinate
    • getD

      public double getD()
      getD - returns the fourth coordinate
      Returns:
      double - the fourth coordinate
    • setD

      public void setD(double p_d)
      setD - sets the fourth coordinate
      Parameters:
      p_d - the fourth coordinate
    • getTx

      public double getTx()
      getTx - returns the tx coordinate
      Returns:
      double - the tx coordinate
    • getShift

      public JDFXYPair getShift()
      Returns:
    • getOrientation

      public JDFElement.EnumOrientation getOrientation()
      Returns:
    • getAngle

      public double getAngle()
      Returns:
    • isFlip

      public boolean isFlip()
      Returns:
    • setTx

      public void setTx(double p_tx)
      setTx - sets the tx coordinate
      Parameters:
      p_tx - the tx coordinate
    • getTy

      public double getTy()
      getTy - returns the ty coordinate
      Returns:
      double - the ty coordinate
    • setTy

      public void setTy(double p_ty)
      setTy - sets the ty coordinate
      Parameters:
      p_ty - the ty coordinate
    • equals

      public boolean equals(Object other)
      equals - returns true if both JDFMatrices are equal, otherwise false
      Specified by:
      equals in interface Collection<Object>
      Specified by:
      equals in interface List<Object>
      Overrides:
      equals in class JDFNumList
      Returns:
      boolean - true if equal otherwise false
    • hashCode

      public int hashCode()
      hashCode complements equals() to fulfill the equals/hashCode contract
      Specified by:
      hashCode in interface Collection<Object>
      Specified by:
      hashCode in interface List<Object>
      Overrides:
      hashCode in class JDFNumList
    • getAffineTransform

      public AffineTransform getAffineTransform()
      getAffineTransform -
      Returns:
      AffineTransform
    • setAffineTransform

      public void setAffineTransform(AffineTransform affineTrans)
      setAffineTransform -
      Parameters:
      affineTrans - matrix to be stored
    • transform

      public JDFXYPair transform(JDFXYPair inCoordinate)
      applies this to a point
      Parameters:
      inCoordinate -
      Returns:
    • shift

      public JDFMatrix shift(double tx, double ty)
      shifts Tx and Ty by the amount specified
      Parameters:
      tx - shift in x direction
      ty - shift in y direction
      Returns:
    • rotate

      public JDFMatrix rotate(double degrees)
      rotate this by degrees degrees CouterClockwise
      Parameters:
      degrees - the degrees to rotate by in counterclockwise direction
    • concat

      public JDFMatrix concat(JDFMatrix m)
      concatinates this with m
      Parameters:
      m - the matrix to concatinate
    • invert

      public JDFMatrix invert()
      inverts this
      Parameters:
      m - the matrix to concatinate
    • shift

      public JDFMatrix shift(JDFXYPair point)
      shift this matrix by an xypair
      Parameters:
      point - the point to shift by
    • setShift

      public JDFMatrix setShift(JDFXYPair point)
      shift this matrix by an xypair
      Parameters:
      point - the point to shift by
    • transform

      public JDFRectangle transform(JDFRectangle jdfRectangle)