Package com.itextpdf.svg.utils
Class TransformUtils
java.lang.Object
com.itextpdf.svg.utils.TransformUtils
Utility class responsible for converting Strings containing transformation declarations
into AffineTransform objects.
This class only supports the transformations as described in the SVG specification: - matrix - rotate - scale - skewX - skewY - translate
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
Keyword for matrix transformations.private static final String
Keyword for rotation transformation.private static final String
Keyword for scale transformation.private static final String
Keyword for skewX transformation.private static final String
Keyword for skewY transformation.private static final String
Keyword for translate transformation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static AffineTransform
createMatrixTransformation
(List<String> values) Creates a matrix transformation.private static AffineTransform
createRotationTransformation
(List<String> values) Creates a rotate transformation.private static AffineTransform
createScaleTransformation
(List<String> values) Creates a scale transformation.private static AffineTransform
createSkewXTransformation
(List<String> values) Creates a skewX transformation.private static AffineTransform
createSkewYTransformation
(List<String> values) Creates a skewY transformation.private static AffineTransform
createTranslateTransformation
(List<String> values) Creates a translate transformation.private static String
getNameFromString
(String transformation) This method extracts the transformation name given a transformation.getValuesFromTransformationString
(String transformation) This method extracts the values from a transformation.static AffineTransform
parseTransform
(String transform) Converts a string containing a transform declaration into an AffineTransform object.splitString
(String transform) A transformation attribute can encompass multiple transformation operation (e.g.private static AffineTransform
transformationStringToMatrix
(String transformation) This method decides which transformation operation the given transformation strings maps onto.
-
Field Details
-
MATRIX
Keyword for matrix transformations. Accepts 6 values.matrix(0 1 2 3 4 5)
- See Also:
-
ROTATE
Keyword for rotation transformation. Accepts either 1 or 3 values. In the case of 1 value, x and y are assumed to be the origin of the user space.rotate(angle x y) rotate(angle)
- See Also:
-
SCALE
Keyword for scale transformation. Accepts either 1 or 2 values. In the case of 1 value, the second value is assumed to be the same as the first one.scale(x y) scale(x)
- See Also:
-
SKEWX
Keyword for skewX transformation. Accepts 1 value.skewX(angle)
- See Also:
-
SKEWY
Keyword for skewY transformation. Accepts 1 value.skewY(angle)
- See Also:
-
TRANSLATE
Keyword for translate transformation. Accepts either 1 or 2 values. In the case of 1 value, the y value is assumed to be 0.translate(x y) translate(x)
- See Also:
-
-
Constructor Details
-
TransformUtils
private TransformUtils()
-
-
Method Details
-
parseTransform
Converts a string containing a transform declaration into an AffineTransform object. This class only supports the transformations as described in the SVG specification: - matrix - translate - skewx - skewy - rotate - scale- Parameters:
transform
- value to be parsed- Returns:
- the AffineTransform object
-
splitString
A transformation attribute can encompass multiple transformation operation (e.g. "translate(10,20) scale(30,40)". This method splits the original transformation string into multiple strings so that they can be handled separately.- Parameters:
transform
- the transformation value- Returns:
- a list containing strings describing a single transformation operation
-
transformationStringToMatrix
This method decides which transformation operation the given transformation strings maps onto.- Parameters:
transformation
- string containing a transformation operation- Returns:
- the mapped AffineTransform object
-
createSkewYTransformation
Creates a skewY transformation.- Parameters:
values
- values of the transformation- Returns:
- AffineTransform for the skew operation
-
createSkewXTransformation
Creates a skewX transformation.- Parameters:
values
- values of the transformation- Returns:
- AffineTransform for the skew operation
-
createRotationTransformation
Creates a rotate transformation.- Parameters:
values
- values of the transformation- Returns:
- AffineTransform for the rotate operation
-
createScaleTransformation
Creates a scale transformation.- Parameters:
values
- values of the transformation- Returns:
- AffineTransform for the scale operation
-
createTranslateTransformation
Creates a translate transformation.- Parameters:
values
- values of the transformation- Returns:
- AffineTransform for the translate operation
-
createMatrixTransformation
Creates a matrix transformation.- Parameters:
values
- values of the transformation- Returns:
- AffineTransform for the matrix keyword
-
getNameFromString
This method extracts the transformation name given a transformation.- Parameters:
transformation
- the transformation- Returns:
- the name of the transformation
-
getValuesFromTransformationString
This method extracts the values from a transformation.- Parameters:
transformation
- the transformation- Returns:
- values of the transformation
-