Package com.storedobject.svg
Class TransformMatrix<N extends Node>
java.lang.Object
com.storedobject.svg.TransformMatrix<N>
- Type Parameters:
N- The type ofNodethis transformation matrix is associated with.
- All Implemented Interfaces:
Serializable
Represents a transformation matrix for a
Node.
This class provides various transformation operations like translation, scaling, rotation, and flipping.
Transformations are applied to the node's coordinate system.- Author:
- Syam
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTransformMatrix(N node) Constructs a new TransformMatrix for the specified node. -
Method Summary
Modifier and TypeMethodDescriptionFlips the transformation matrix horizontally around the node's center.Flips the transformation matrix horizontally around the origin.Flips the transformation matrix vertically around the node's center.Flips the transformation matrix vertically around the origin.get()Returns the node associated with this transformation matrix.Returns the bounding coordinates of the node after applying the transformation matrix.moveTo(double x, double y) Moves the top-left corner of the node to the specified (x, y) coordinate.Moves the top-left corner of the node to the specifiedPoint.reset()Resets the transformation matrix to the identity matrix.rotate(double degrees) Rotates the transformation matrix by a given angle around the origin.rotateAround(double angleDegrees, double x, double y) Rotates the transformation matrix by a given angle around a specified point (x, y).rotateAround(double angleDegrees, Point point) Rotates the transformation matrix by a given angle around a specifiedPoint.rotateAroundCenter(double angleDegrees) Rotates the transformation matrix by a given angle around the node's center.scale(double scale) Scales the transformation matrix uniformly by the given factor.scale(double sx, double sy) Scales the transformation matrix by the given factors sx and sy.scaleHeightTo(double targetHeight) Scales the node's height to the specified target height.scaleTo(double targetWidth, double targetHeight) Scales the node to the specified target width and height.scaleWidthTo(double targetWidth) Scales the node's width to the specified target width.shear(double kx, double ky) Applies a shear transformation to the transformation matrix.toString()Returns a string representation of the transformation matrix as an SVG transform attribute.translate(double tx, double ty) Translates the transformation matrix by a given offset (tx, ty).Translates the transformation matrix by a given offset specified as aPoint.
-
Constructor Details
-
TransformMatrix
Constructs a new TransformMatrix for the specified node.- Parameters:
node- The node to be transformed.
-
-
Method Details
-
get
-
translate
Translates the transformation matrix by a given offset specified as aPoint.- Parameters:
point- The offset point for translation.- Returns:
- This transformation matrix for chaining.
-
translate
Translates the transformation matrix by a given offset (tx, ty).- Parameters:
tx- The distance to translate along the x-axis.ty- The distance to translate along the y-axis.- Returns:
- This transformation matrix for chaining.
-
moveTo
Moves the top-left corner of the node to the specifiedPoint.- Parameters:
point- The destination point.- Returns:
- This transformation matrix for chaining.
-
moveTo
Moves the top-left corner of the node to the specified (x, y) coordinate.- Parameters:
x- The destination x-coordinate.y- The destination y-coordinate.- Returns:
- This transformation matrix for chaining.
-
scaleTo
Scales the node to the specified target width and height.- Parameters:
targetWidth- The target width.targetHeight- The target height.- Returns:
- This transformation matrix for chaining.
-
scaleWidthTo
Scales the node's width to the specified target width.- Parameters:
targetWidth- The target width.- Returns:
- This transformation matrix for chaining.
-
scaleHeightTo
Scales the node's height to the specified target height.- Parameters:
targetHeight- The target height.- Returns:
- This transformation matrix for chaining.
-
scale
Scales the transformation matrix by the given factors sx and sy.- Parameters:
sx- The scaling factor along the x-axis.sy- The scaling factor along the y-axis.- Returns:
- This transformation matrix for chaining.
-
scale
Scales the transformation matrix uniformly by the given factor.- Parameters:
scale- The scaling factor.- Returns:
- This transformation matrix for chaining.
-
rotate
Rotates the transformation matrix by a given angle around the origin.- Parameters:
degrees- The clockwise angle of rotation in degrees.- Returns:
- This transformation matrix for chaining.
-
rotateAround
Rotates the transformation matrix by a given angle around a specified point (x, y).- Parameters:
angleDegrees- clockwise The angle of rotation in degrees.x- The x-coordinate of the rotation center.y- The y-coordinate of the rotation center.- Returns:
- This transformation matrix for chaining.
-
rotateAround
Rotates the transformation matrix by a given angle around a specifiedPoint.- Parameters:
angleDegrees- The clockwise angle of rotation in degrees.point- The point around which to rotate.- Returns:
- This transformation matrix for chaining.
-
rotateAroundCenter
Rotates the transformation matrix by a given angle around the node's center.- Parameters:
angleDegrees- The clockwise angle of rotation in degrees.- Returns:
- This transformation matrix for chaining.
-
flipVerticallyAroundOrigin
Flips the transformation matrix vertically around the origin.- Returns:
- This transformation matrix for chaining.
-
flipVertically
Flips the transformation matrix vertically around the node's center.- Returns:
- This transformation matrix for chaining.
-
flipHorizontallyAroundOrigin
Flips the transformation matrix horizontally around the origin.- Returns:
- This transformation matrix for chaining.
-
flipHorizontally
Flips the transformation matrix horizontally around the node's center.- Returns:
- This transformation matrix for chaining.
-
getCoordinates
Returns the bounding coordinates of the node after applying the transformation matrix.- Returns:
- The bounding
Coordinates.
-
shear
Applies a shear transformation to the transformation matrix.- Parameters:
kx- The shear factor along the x-axis.ky- The shear factor along the y-axis.- Returns:
- This transformation matrix for chaining.
-
toString
-
reset
Resets the transformation matrix to the identity matrix.- Returns:
- This transformation matrix for chaining.
-