Package com.treemap
Class RectangularTransform
java.lang.Object
com.treemap.RectangularTransform
This is a transform that only scales and translates. It is
a subset of an
AffineTransform
, except with no
rotation/shearing.-
Constructor Summary
ConstructorsConstructorDescriptionCreates an identity transform.RectangularTransform
(double sx, double sy, double tx, double ty) Creates aRectangularTransform
.RectangularTransform
(com.macrofocus.geom.Rectangle2D oldRect, com.macrofocus.geom.Rectangle2D newRect) Creates aRectangularTransform
that transforms from one rectangle to another. -
Method Summary
Modifier and TypeMethodDescriptionstatic com.macrofocus.geom.AffineTransform
create
(com.macrofocus.geom.Rectangle2D oldRect, com.macrofocus.geom.Rectangle2D newRect) Creates anAffineTransform
that maps one argument to another.com.macrofocus.geom.AffineTransform
Converts this to anAffineTransform
.Creates a transform that is the inverse of this one.double
double
double
double
void
scale
(double sx, double sy) Scales this transform.void
setTransform
(com.macrofocus.geom.Rectangle2D oldRect, com.macrofocus.geom.Rectangle2D newRect) Defines this transform.com.macrofocus.geom.Point2D
transform
(com.macrofocus.geom.Point2D src) Transforms the source argument.com.macrofocus.geom.Rectangle2D
transform
(com.macrofocus.geom.Rectangle2D src) Transforms the source argument.void
translate
(double tx, double ty) Translates this transform.
-
Constructor Details
-
RectangularTransform
public RectangularTransform()Creates an identity transform. -
RectangularTransform
public RectangularTransform(com.macrofocus.geom.Rectangle2D oldRect, com.macrofocus.geom.Rectangle2D newRect) Creates aRectangularTransform
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 aRectangularTransform
.- Parameters:
sx
- the scaleX factorsy
- the scaleY factortx
- the x-translationty
- the y-translation
-
-
Method Details
-
transform
public com.macrofocus.geom.Rectangle2D transform(com.macrofocus.geom.Rectangle2D src) Transforms the source argument.- Parameters:
src
- the initial rectangle.- Returns:
- the Rectangle2D to store the results in.
-
transform
public com.macrofocus.geom.Point2D transform(com.macrofocus.geom.Point2D src) Transforms the source argument.- Parameters:
src
- the initial point.- Returns:
- the Point2D to store the results in.
-
create
public static com.macrofocus.geom.AffineTransform create(com.macrofocus.geom.Rectangle2D oldRect, com.macrofocus.geom.Rectangle2D newRect) Creates anAffineTransform
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(com.macrofocus.geom.Rectangle2D oldRect, com.macrofocus.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 com.macrofocus.geom.AffineTransform createAffineTransform()Converts this to anAffineTransform
. -
createInverse
Creates a transform that is the inverse of this one.
-