public class AffineTransforms extends Object
AffineTransform
s.Modifier and Type | Method and Description |
---|---|
static boolean |
containsTranslation(AffineTransform t) |
static Rectangle |
createTransformedBounds(AffineTransform tx,
float x,
float y,
float w,
float h)
A short-cut method for
AffineTransforms.createTransformedBounds(new Rectangle2D.Float(x,y,w,h)) . |
static Rectangle |
createTransformedBounds(AffineTransform tx,
Shape s)
A short-cut method for
. |
static Rectangle2D |
createTransformedBounds2D(AffineTransform tx,
float x,
float y,
float w,
float h)
A short-cut method for
AffineTransforms.createTransformedBounds2D(new Rectangle2D.Float(x,y,w,h)) . |
static Rectangle2D |
createTransformedBounds2D(AffineTransform tx,
Shape s)
A short-cut method for
. |
static Shape |
createTransformedShape(AffineTransform tx,
Shape s)
A replacement for
AffineTransform.createTransformedShape(Shape) which contains
optimizations for frequent cases like the transformation of Rectangle2D s with only
quadrant rotations etc. |
static AffineTransform |
getHorizontalFlip(double height)
Creates an
AffineTransform which performs a horizontal flipping with the following
operations:
Translate by the given height
Horizontal flipping
Typically, this can be used to switch from Cartesian to Screen coordinates or vice versa. |
static AffineTransform |
getNonTranslatingTransform(AffineTransform t)
Return the non-translating part of the given transform.
|
static double |
getPointRotation(AffineTransform tx,
Point2D p)
Determines the rotation component of the given transformation with respect to the X-axis, i.e.
|
static double |
getUnitRotation(AffineTransform tx)
Determines the rotation component of the given transformation with respect to the unit point
(1,1) relative to the origin.
|
static double |
getXAxisRotation(AffineTransform tx)
Determines the rotation component of the given transformation with respect to the X-axis, i.e.
|
static double |
getYAxisRotation(AffineTransform tx)
Determines the rotation component of the given transformation with respect to the Y-axis, i.e.
|
static AffineTransform |
immutableTransform(AffineTransform tx)
Create an immutable incarnation of the given transform.
|
static boolean |
isInvertible(AffineTransform affineTransform)
Determine whether or not a given transformation is invertible.
|
static boolean |
isNeighbor(AffineTransform tx1,
AffineTransform tx2,
double epsilon)
Determine whether or not two given transformations are equal within a certain range epsilon.
|
public static double getXAxisRotation(AffineTransform tx)
tx
- the transformationpublic static double getYAxisRotation(AffineTransform tx)
tx
- the transformationpublic static double getUnitRotation(AffineTransform tx)
tx
- the transformationpublic static double getPointRotation(AffineTransform tx, Point2D p)
tx
- the transformationp
- the point for which the rotation is determined.public static AffineTransform getNonTranslatingTransform(AffineTransform t)
t
- public static boolean containsTranslation(AffineTransform t)
t
- the transformationpublic static Shape createTransformedShape(AffineTransform tx, Shape s)
AffineTransform.createTransformedShape(Shape)
which contains
optimizations for frequent cases like the transformation of Rectangle2D
s with only
quadrant rotations etc.tx
- the transformation to applys
- the shape to transformpublic static Rectangle2D createTransformedBounds2D(AffineTransform tx, Shape s)
AffineTransform.createTransformedShape(Shape)
.getBounds2D()
. Using the
latter idiom leads to the creation of an additional, transient Rectangle2D, even for simple
cases. Using this method not only yields the savings of
createTransformedShape(AffineTransform, Shape)
but also gets rid of the extra
Rectangle2D instance.
This method will always return a new Rectangle2D
instance.tx
- the transformation to applys
- the shape to transformpublic static Rectangle createTransformedBounds(AffineTransform tx, Shape s)
AffineTransform.createTransformedShape(Shape)
.getBounds()
. Using the latter
idiom leads to the creation of an additional, transient Rectangle2D, even for simple cases. Using
this method not only yields the savings of
createTransformedShape(AffineTransform, Shape)
but also gets rid of the extra
Rectangle2D instance.
This method will always return a new Rectangle
instance.tx
- the transformation to applys
- the shape to transformpublic static Rectangle createTransformedBounds(AffineTransform tx, float x, float y, float w, float h)
AffineTransforms.createTransformedBounds(new Rectangle2D.Float(x,y,w,h))
.
This method will always return a new Rectangle
instance.tx
- the transformation to applypublic static Rectangle2D createTransformedBounds2D(AffineTransform tx, float x, float y, float w, float h)
AffineTransforms.createTransformedBounds2D(new Rectangle2D.Float(x,y,w,h))
.
This method will always return a new Rectangle
instance.tx
- the transformation to applypublic static AffineTransform immutableTransform(AffineTransform tx)
UnsupportedOperationException
. Changes to the source transform
made after the call to this method will not be reflected in the returned transform.
Please note: the immutable transform returns mutable versions of itself upon calling
AffineTransform.clone()
. Therefore the following code is perfectly OK:
AffineTransform tx = ...;
AffineTransform immutableTx = AffineTransforms.immutableTransform(tx);
immutableTx.clone().scale(something, something);
tx
- the input transformpublic static AffineTransform getHorizontalFlip(double height)
AffineTransform
which performs a horizontal flipping with the following
operations:
height
- height of the area to be flippedAffineTransform
to perform the flippingpublic static boolean isInvertible(AffineTransform affineTransform)
AffineTransform.createInverse()
.affineTransform
- the transformation to be consideredtrue
if the given transformation is invertible, false
otherwise.public static boolean isNeighbor(AffineTransform tx1, AffineTransform tx2, double epsilon)
tx1
- the first transformation to be consideredtx2
- the second transformation to be consideredepsilon
- the maximum tolerated difference for considering the two doubles in the transform
equaltrue
if the AffineTransform
s are considered equal,
false
otherwise.Copyright © 2024 levigo holding gmbh. All rights reserved.