Class AffineTransforms

java.lang.Object
com.levigo.jadice.web.client.util.helper.AffineTransforms

public class AffineTransforms extends Object
A bunch of static utility methods useful in conjunction with AffineTransforms.
  • Method Details

    • getXAxisRotation

      public static double getXAxisRotation(AffineTransform tx)
      Determines the rotation component of the given transformation with respect to the X-axis, i.e. the rotation of any point (excluding the origin) on the X-axis with relative to the origin.
      Parameters:
      tx - the transformation
      Returns:
      the rotation angle in radians
    • getYAxisRotation

      public static double getYAxisRotation(AffineTransform tx)
      Determines the rotation component of the given transformation with respect to the Y-axis, i.e. the rotation of any point (excluding the origin) on the Y-axis with relative to the origin.
      Parameters:
      tx - the transformation
      Returns:
      the rotation angle in radians
    • getUnitRotation

      public static double getUnitRotation(AffineTransform tx)
      Determines the rotation component of the given transformation with respect to the unit point (1,1) relative to the origin.
      Parameters:
      tx - the transformation
      Returns:
      the rotation angle in radians
    • getPointRotation

      public static double getPointRotation(AffineTransform tx, Point2D p)
      Determines the rotation component of the given transformation with respect to the X-axis, i.e. the rotation of any point (excluding the origin) on the X-axis with relative to the origin.
      Parameters:
      tx - the transformation
      p - the point for which the rotation is determined
      Returns:
      the rotation angle in radians
    • getNonTranslatingTransform

      public static AffineTransform getNonTranslatingTransform(AffineTransform t)
      Return the non-translating part of the given transform.
      Parameters:
      t - The given transform
      Returns:
      A new AffineTransform excluding the transformation part
    • containsTranslation

      public static boolean containsTranslation(AffineTransform t)
      Parameters:
      t - The given AffineTransforms
      Returns:
      True, if it contains a translation, false else
    • createTransformedShape

      public static Shape createTransformedShape(AffineTransform tx, Shape s)
      A replacement for AffineTransform.createTransformedShape(Shape) which contains optimizations for frequent cases like the transformation of Rectangle2Ds with only quadrant rotations etc.
      Parameters:
      tx - the transformation to apply
      s - the shape to transform
      Returns:
      the transformation result
    • createTransformedBounds2D

      public static Rectangle2D createTransformedBounds2D(AffineTransform tx, Shape s)
      A short-cut method for AffineTransform.createTransformedShape(Shape).getBounds2D(). Using the latter idiom leads to the creation of an additional, transient Rectangle2D, even for simple cases. Using this method not only yields the savings of createTransformedShape(AffineTransform, Shape) but also gets rid of the extra Rectangle2D instance. This method will always return a new Rectangle2D instance.
      Parameters:
      tx - the transformation to apply
      s - the shape to transform
      Returns:
      the resulting bounds
    • createTransformedBounds

      public static Rectangle createTransformedBounds(AffineTransform tx, Shape s)
      A short-cut method for AffineTransform.createTransformedShape(Shape).getBounds(). Using the latter idiom leads to the creation of an additional, transient Rectangle2D, even for simple cases. Using this method not only yields the savings of createTransformedShape(AffineTransform, Shape) but also gets rid of the extra Rectangle2D instance. This method will always return a new Rectangle instance.
      Parameters:
      tx - the transformation to apply
      s - the shape to transform
      Returns:
      the resulting bounds
    • createTransformedBounds

      public static Rectangle createTransformedBounds(AffineTransform tx, float x, float y, float w, float h)
      A short-cut method for AffineTransforms.createTransformedBounds(new Rectangle2D.Float(x,y,w,h)).

      This method will always return a new Rectangle instance.

      Parameters:
      tx - The transformation to apply
      x - The x value of the point defining the bounds
      y - The y value of the point defining the bounds
      w - The width of the bounds
      h - The height of the bounds
      Returns:
      The resulting bounds
    • createTransformedBounds2D

      public static Rectangle2D createTransformedBounds2D(AffineTransform tx, float x, float y, float w, float h)
      A short-cut method for AffineTransforms.createTransformedBounds2D(new Rectangle2D.Float(x,y,w,h)). This method will always return a new Rectangle instance.
      Parameters:
      tx - the transformation to apply
      x - The x value of the point defining the bounds
      y - The y value of the point defining the bounds
      w - The width of the bounds
      h - The height of the bounds
      Returns:
      the resulting bounds