Package com.itextpdf.svg.utils
Class TransformUtils
- java.lang.Object
-
- com.itextpdf.svg.utils.TransformUtils
-
public final class TransformUtils extends java.lang.Object
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
Fields Modifier and Type Field Description private static java.lang.String
MATRIX
Keyword for matrix transformations.private static java.lang.String
ROTATE
Keyword for rotation transformation.private static java.lang.String
SCALE
Keyword for scale transformation.private static java.lang.String
SKEWX
Keyword for skewX transformation.private static java.lang.String
SKEWY
Keyword for skewY transformation.private static java.lang.String
TRANSLATE
Keyword for translate transformation.
-
Constructor Summary
Constructors Modifier Constructor Description private
TransformUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static AffineTransform
createMatrixTransformation(java.util.List<java.lang.String> values)
Creates a matrix transformation.private static AffineTransform
createRotationTransformation(java.util.List<java.lang.String> values)
Creates a rotate transformation.private static AffineTransform
createScaleTransformation(java.util.List<java.lang.String> values)
Creates a scale transformation.private static AffineTransform
createSkewXTransformation(java.util.List<java.lang.String> values)
Creates a skewX transformation.private static AffineTransform
createSkewYTransformation(java.util.List<java.lang.String> values)
Creates a skewY transformation.private static AffineTransform
createTranslateTransformation(java.util.List<java.lang.String> values)
Creates a translate transformation.private static java.lang.String
getNameFromString(java.lang.String transformation)
This method extracts the transformation name given a transformation.private static java.util.List<java.lang.String>
getValuesFromTransformationString(java.lang.String transformation)
This method extracts the values from a transformation.static AffineTransform
parseTransform(java.lang.String transform)
Converts a string containing a transform declaration into an AffineTransform object.private static java.util.List<java.lang.String>
splitString(java.lang.String transform)
A transformation attribute can encompass multiple transformation operation (e.g.private static AffineTransform
transformationStringToMatrix(java.lang.String transformation)
This method decides which transformation operation the given transformation strings maps onto.
-
-
-
Field Detail
-
MATRIX
private static final java.lang.String MATRIX
Keyword for matrix transformations. Accepts 6 values.matrix(0 1 2 3 4 5)
- See Also:
- Constant Field Values
-
ROTATE
private static final java.lang.String 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:
- Constant Field Values
-
SCALE
private static final java.lang.String 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:
- Constant Field Values
-
SKEWX
private static final java.lang.String SKEWX
Keyword for skewX transformation. Accepts 1 value.skewX(angle)
- See Also:
- Constant Field Values
-
SKEWY
private static final java.lang.String SKEWY
Keyword for skewY transformation. Accepts 1 value.skewY(angle)
- See Also:
- Constant Field Values
-
TRANSLATE
private static final java.lang.String 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:
- Constant Field Values
-
-
Method Detail
-
parseTransform
public static AffineTransform parseTransform(java.lang.String transform)
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
private static java.util.List<java.lang.String> splitString(java.lang.String transform)
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
private static AffineTransform transformationStringToMatrix(java.lang.String transformation)
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
private static AffineTransform createSkewYTransformation(java.util.List<java.lang.String> values)
Creates a skewY transformation.- Parameters:
values
- values of the transformation- Returns:
- AffineTransform for the skew operation
-
createSkewXTransformation
private static AffineTransform createSkewXTransformation(java.util.List<java.lang.String> values)
Creates a skewX transformation.- Parameters:
values
- values of the transformation- Returns:
- AffineTransform for the skew operation
-
createRotationTransformation
private static AffineTransform createRotationTransformation(java.util.List<java.lang.String> values)
Creates a rotate transformation.- Parameters:
values
- values of the transformation- Returns:
- AffineTransform for the rotate operation
-
createScaleTransformation
private static AffineTransform createScaleTransformation(java.util.List<java.lang.String> values)
Creates a scale transformation.- Parameters:
values
- values of the transformation- Returns:
- AffineTransform for the scale operation
-
createTranslateTransformation
private static AffineTransform createTranslateTransformation(java.util.List<java.lang.String> values)
Creates a translate transformation.- Parameters:
values
- values of the transformation- Returns:
- AffineTransform for the translate operation
-
createMatrixTransformation
private static AffineTransform createMatrixTransformation(java.util.List<java.lang.String> values)
Creates a matrix transformation.- Parameters:
values
- values of the transformation- Returns:
- AffineTransform for the matrix keyword
-
getNameFromString
private static java.lang.String getNameFromString(java.lang.String transformation)
This method extracts the transformation name given a transformation.- Parameters:
transformation
- the transformation- Returns:
- the name of the transformation
-
getValuesFromTransformationString
private static java.util.List<java.lang.String> getValuesFromTransformationString(java.lang.String transformation)
This method extracts the values from a transformation.- Parameters:
transformation
- the transformation- Returns:
- values of the transformation
-
-