Class GTransform

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class GTransform
    extends GraphicE
    This class wraps a AffineTransform in a GraphicE, in order to give a bit more "flexibility" to Graphic objects
    • Field Summary

    • Constructor Summary

      Constructors 
      Constructor Description
      GTransform​(double sx, double sy)
      Create a scaling GTransform
      GTransform​(int x, int y, double phi)
      Create a rotating GTransform
      GTransform​(GTransform e)
      Copy constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      GraphicE clone()  
      void draw​(java.awt.Graphics2D g)
      Draws the component on the given graphics
      boolean equals​(java.lang.Object obj)  
      java.awt.geom.AffineTransform getTransform()
      Retrieves the AffineTransform used in this GTransform
      int hashCode()  
      GTransform invert()
      Retrieves a new GTransform that reverses the effects of this one
      void rotate​(double phi)
      Rotates the graphics around the origin of coordinates a given angle
      void rotate​(int x, int y, double phi)
      Rotates the graphics around the point (x, y) a given angle
      void scale​(double sx, double sy)
      Scales the graphics
      void traslate​(int x, int y)
      Traslates this element on X and Y
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GTransform

        public GTransform​(GTransform e)
        Copy constructor
        Parameters:
        e - GTransform to copy
        Throws:
        java.lang.IllegalArgumentException - if e is null
      • GTransform

        public GTransform​(double sx,
                          double sy)
        Create a scaling GTransform
        Parameters:
        sx - horizontal scale
        sy - vertical scale
      • GTransform

        public GTransform​(int x,
                          int y,
                          double phi)
        Create a rotating GTransform
        Parameters:
        x - x coordinate of the pivot point
        y - y coordinate of the pivot point
        phi - angle in degrees
    • Method Detail

      • scale

        public void scale​(double sx,
                          double sy)
        Scales the graphics
        Parameters:
        sx - horizontal scale
        sy - vertical scale
      • rotate

        public void rotate​(int x,
                           int y,
                           double phi)
        Rotates the graphics around the point (x, y) a given angle
        Parameters:
        x - x coordinate of the pivot point
        y - y coordinate of the pivot point
        phi - angle in degrees
      • rotate

        public void rotate​(double phi)
        Rotates the graphics around the origin of coordinates a given angle
        Parameters:
        phi - angle in degrees
      • getTransform

        public java.awt.geom.AffineTransform getTransform()
        Retrieves the AffineTransform used in this GTransform
        Returns:
        transform
      • invert

        public GTransform invert()
                          throws java.awt.geom.NoninvertibleTransformException
        Retrieves a new GTransform that reverses the effects of this one
        Returns:
        inverse transform
        Throws:
        java.awt.geom.NoninvertibleTransformException - if the transform is not invertible, this usually happens when using sheer, so it's very unlikely here
      • traslate

        public void traslate​(int x,
                             int y)
        Description copied from class: GraphicE
        Traslates this element on X and Y
        Specified by:
        traslate in class GraphicE
        Parameters:
        x - size in px of the horizontal translation
        y - size in px of the vertical translation
      • draw

        public void draw​(java.awt.Graphics2D g)
        Description copied from class: GraphicE
        Draws the component on the given graphics
        Specified by:
        draw in class GraphicE
        Parameters:
        g - where to draw
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class GraphicE