Class RectangularTransform


  • public class RectangularTransform
    extends java.lang.Object
    This is a transform that only scales and translates. It is a subset of an AffineTransform, except with no rotation/shearing.
    • Constructor Summary

      Constructors 
      Constructor Description
      RectangularTransform()
      Creates an identity transform.
      RectangularTransform​(double sx, double sy, double tx, double ty)
      Creates a RectangularTransform.
      RectangularTransform​(java.awt.geom.Rectangle2D oldRect, java.awt.geom.Rectangle2D newRect)
      Creates a RectangularTransform that transforms from one rectangle to another.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.awt.geom.AffineTransform create​(java.awt.geom.Rectangle2D oldRect, java.awt.geom.Rectangle2D newRect)
      Creates an AffineTransform that maps one argument to another.
      java.awt.geom.AffineTransform createAffineTransform()
      Converts this to an AffineTransform.
      RectangularTransform createInverse()
      Creates a transform that is the inverse of this one.
      double getScaleX()  
      double getScaleY()  
      double getTranslateX()  
      double getTranslateY()  
      void scale​(double sx, double sy)
      Scales this transform.
      void setTransform​(java.awt.geom.Rectangle2D oldRect, java.awt.geom.Rectangle2D newRect)
      Defines this transform.
      java.awt.geom.Point2D transform​(java.awt.geom.Point2D src, java.awt.geom.Point2D dst)
      Transforms the source argument.
      java.awt.geom.Rectangle2D transform​(java.awt.geom.Rectangle2D src)
      Transforms the source argument.
      java.awt.geom.Rectangle2D transform​(java.awt.geom.Rectangle2D src, java.awt.geom.Rectangle2D dst)
      Transforms the source argument.
      void translate​(double tx, double ty)
      Translates this transform.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RectangularTransform

        public RectangularTransform()
        Creates an identity transform.
      • RectangularTransform

        public RectangularTransform​(java.awt.geom.Rectangle2D oldRect,
                                    java.awt.geom.Rectangle2D newRect)
        Creates a RectangularTransform that transforms from one rectangle to another.
        Parameters:
        oldRect - the initial rectangle.
        newRect - the final (transformed) rectangle.
      • RectangularTransform

        public RectangularTransform​(double sx,
                                    double sy,
                                    double tx,
                                    double ty)
        Creates a RectangularTransform.
        Parameters:
        sx - the scaleX factor
        sy - the scaleY factor
        tx - the x-translation
        ty - the y-translation
    • Method Detail

      • transform

        public java.awt.geom.Rectangle2D transform​(java.awt.geom.Rectangle2D src)
        Transforms the source argument.
      • transform

        public java.awt.geom.Rectangle2D transform​(java.awt.geom.Rectangle2D src,
                                                   java.awt.geom.Rectangle2D dst)
        Transforms the source argument.
        Parameters:
        src - the initial rectangle.
        dst - the Rectangle2D to store the results in.
      • transform

        public java.awt.geom.Point2D transform​(java.awt.geom.Point2D src,
                                               java.awt.geom.Point2D dst)
        Transforms the source argument.
        Parameters:
        src - the initial point.
        dst - the Point2D to store the results in.
      • create

        public static java.awt.geom.AffineTransform create​(java.awt.geom.Rectangle2D oldRect,
                                                           java.awt.geom.Rectangle2D newRect)
        Creates an AffineTransform that maps one argument to another.
        Parameters:
        oldRect - the initial rectangle.
        newRect - the final (transformed) rectangle.
        Returns:
        an AffineTransform that maps from the old to the new rectangle.
      • setTransform

        public void setTransform​(java.awt.geom.Rectangle2D oldRect,
                                 java.awt.geom.Rectangle2D newRect)
        Defines this transform.
        Parameters:
        oldRect - the initial rect.
        newRect - what this transform should turn the initial rectangle into.
      • translate

        public void translate​(double tx,
                              double ty)
        Translates this transform.
        Parameters:
        tx - the x-translation.
        ty - the y-translation.
      • getScaleX

        public double getScaleX()
      • getScaleY

        public double getScaleY()
      • getTranslateX

        public double getTranslateX()
      • getTranslateY

        public double getTranslateY()
      • scale

        public void scale​(double sx,
                          double sy)
        Scales this transform.
        Parameters:
        sx - the factor to scale X-values by.
        sy - the factor to scale Y-values by.
      • createAffineTransform

        public java.awt.geom.AffineTransform createAffineTransform()
        Converts this to an AffineTransform.
      • createInverse

        public RectangularTransform createInverse()
        Creates a transform that is the inverse of this one.