Class RectangularTransform



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

      • RectangularTransform

        public RectangularTransform()
        Creates an identity transform.
      • RectangularTransform

        public RectangularTransform(Rectangle2D oldRect,
                                    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 Rectangle2D transform(Rectangle2D src,
                                     Rectangle2D dst)
        Transforms the source argument.
        Parameters:
        src - the initial rectangle.
        dst - the Rectangle2D to store the results in.
      • transform

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

        public static AffineTransform create(Rectangle2D oldRect,
                                             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(Rectangle2D oldRect,
                                 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 AffineTransform createAffineTransform()
        Converts this to an AffineTransform.
      • createInverse

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