Class GTransform

java.lang.Object
com.dkt.graphics.elements.GraphicE
com.dkt.graphics.extras.GTransform
All Implemented Interfaces:
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
Author:
Federico Vera <[email protected]>
  • Constructor Details

    • GTransform

      public GTransform(GTransform e)
      Copy constructor
      Parameters:
      e - GTransform to copy
      Throws:
      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 Details

    • 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 AffineTransform getTransform()
      Retrieves the AffineTransform used in this GTransform
      Returns:
      transform
    • invert

      Retrieves a new GTransform that reverses the effects of this one
      Returns:
      inverse transform
      Throws:
      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(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
    • clone

      public GraphicE clone()
      Specified by:
      clone in class GraphicE
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class GraphicE
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class GraphicE