Class AffineTransforms
java.lang.Object
com.levigo.jadice.web.client.util.helper.AffineTransforms
A bunch of static utility methods useful in conjunction with
AffineTransform
s.-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
static Rectangle
createTransformedBounds
(AffineTransform tx, float x, float y, float w, float h) A short-cut method forAffineTransforms.createTransformedBounds(new Rectangle2D.Float(x,y,w,h))
.static Rectangle
A short-cut method for
.AffineTransform.createTransformedShape(Shape)
.getBounds()static Rectangle2D
createTransformedBounds2D
(AffineTransform tx, float x, float y, float w, float h) A short-cut method forAffineTransforms.createTransformedBounds2D(new Rectangle2D.Float(x,y,w,h))
.static Rectangle2D
A short-cut method for
.AffineTransform.createTransformedShape(Shape)
.getBounds2D()static Shape
A replacement forAffineTransform.createTransformedShape(Shape)
which contains optimizations for frequent cases like the transformation ofRectangle2D
s with only quadrant rotations etc.static AffineTransform
Return the non-translating part of the given transform.static double
Determines the rotation component of the given transformation with respect to the X-axis, i.e.static double
Determines the rotation component of the given transformation with respect to the unit point (1,1) relative to the origin.static double
Determines the rotation component of the given transformation with respect to the X-axis, i.e.static double
Determines the rotation component of the given transformation with respect to the Y-axis, i.e.
-
Method Details
-
getXAxisRotation
Determines the rotation component of the given transformation with respect to the X-axis, i.e. the rotation of any point (excluding the origin) on the X-axis with relative to the origin.- Parameters:
tx
- the transformation- Returns:
- the rotation angle in radians
-
getYAxisRotation
Determines the rotation component of the given transformation with respect to the Y-axis, i.e. the rotation of any point (excluding the origin) on the Y-axis with relative to the origin.- Parameters:
tx
- the transformation- Returns:
- the rotation angle in radians
-
getUnitRotation
Determines the rotation component of the given transformation with respect to the unit point (1,1) relative to the origin.- Parameters:
tx
- the transformation- Returns:
- the rotation angle in radians
-
getPointRotation
Determines the rotation component of the given transformation with respect to the X-axis, i.e. the rotation of any point (excluding the origin) on the X-axis with relative to the origin.- Parameters:
tx
- the transformationp
- the point for which the rotation is determined- Returns:
- the rotation angle in radians
-
getNonTranslatingTransform
Return the non-translating part of the given transform.- Parameters:
t
- The given transform- Returns:
- A new AffineTransform excluding the transformation part
-
containsTranslation
- Parameters:
t
- The givenAffineTransforms
- Returns:
- True, if it contains a translation, false else
-
createTransformedShape
A replacement forAffineTransform.createTransformedShape(Shape)
which contains optimizations for frequent cases like the transformation ofRectangle2D
s with only quadrant rotations etc.- Parameters:
tx
- the transformation to applys
- the shape to transform- Returns:
- the transformation result
-
createTransformedBounds2D
A short-cut method for
. 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 ofAffineTransform.createTransformedShape(Shape)
.getBounds2D()createTransformedShape(AffineTransform, Shape)
but also gets rid of the extra Rectangle2D instance. This method will always return a newRectangle2D
instance.- Parameters:
tx
- the transformation to applys
- the shape to transform- Returns:
- the resulting bounds
-
createTransformedBounds
A short-cut method for
. 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 ofAffineTransform.createTransformedShape(Shape)
.getBounds()createTransformedShape(AffineTransform, Shape)
but also gets rid of the extra Rectangle2D instance. This method will always return a newRectangle
instance.- Parameters:
tx
- the transformation to applys
- the shape to transform- Returns:
- the resulting bounds
-
createTransformedBounds
public static Rectangle createTransformedBounds(AffineTransform tx, float x, float y, float w, float h) A short-cut method forAffineTransforms.createTransformedBounds(new Rectangle2D.Float(x,y,w,h))
.This method will always return a new
Rectangle
instance.- Parameters:
tx
- The transformation to applyx
- The x value of the point defining the boundsy
- The y value of the point defining the boundsw
- The width of the boundsh
- The height of the bounds- Returns:
- The resulting bounds
-
createTransformedBounds2D
public static Rectangle2D createTransformedBounds2D(AffineTransform tx, float x, float y, float w, float h) A short-cut method forAffineTransforms.createTransformedBounds2D(new Rectangle2D.Float(x,y,w,h))
. This method will always return a newRectangle
instance.- Parameters:
tx
- the transformation to applyx
- The x value of the point defining the boundsy
- The y value of the point defining the boundsw
- The width of the boundsh
- The height of the bounds- Returns:
- the resulting bounds
-