Package org.apache.batik.parser
Class UnitProcessor
java.lang.Object
org.apache.batik.parser.UnitProcessor
- Direct Known Subclasses:
UnitProcessor
This class provides methods to convert SVG length and coordinate to
float in user units.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Holds the informations needed to compute the units.static class
A LengthHandler that convert units. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final short
This constant represents horizontal lengths.static final short
This constant represents other lengths.static final short
This constant represents vertical lengths. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static float
emsToPixels
(float v, short d, UnitProcessor.Context ctx) Converts ems units to user units.protected static float
exsToPixels
(float v, short d, UnitProcessor.Context ctx) Converts exs units to user units.protected static float
percentagesToPixels
(float v, short d, UnitProcessor.Context ctx) Converts percentages to user units.protected static float
pixelsToEms
(float v, short d, UnitProcessor.Context ctx) Converts user units to ems units.protected static float
pixelsToExs
(float v, short d, UnitProcessor.Context ctx) Converts user units to exs units.protected static float
pixelsToPercentages
(float v, short d, UnitProcessor.Context ctx) Converts user units to percentages relative to the viewport.static float
svgToObjectBoundingBox
(float value, short type, short d, UnitProcessor.Context ctx) Returns the specified value with the specified direction in objectBoundingBox units.static float
svgToObjectBoundingBox
(String s, String attr, short d, UnitProcessor.Context ctx) Returns the specified value with the specified direction in objectBoundingBox units.static float
svgToUserSpace
(float v, short type, short d, UnitProcessor.Context ctx) Converts the specified value of the specified type and direction to user units.static float
svgToUserSpace
(String s, String attr, short d, UnitProcessor.Context ctx) Returns the specified coordinate with the specified direction in user units.static float
userSpaceToSVG
(float v, short type, short d, UnitProcessor.Context ctx) Converts the specified value of the specified type and direction to SVG units.
-
Field Details
-
HORIZONTAL_LENGTH
public static final short HORIZONTAL_LENGTHThis constant represents horizontal lengths.- See Also:
-
VERTICAL_LENGTH
public static final short VERTICAL_LENGTHThis constant represents vertical lengths.- See Also:
-
OTHER_LENGTH
public static final short OTHER_LENGTHThis constant represents other lengths.- See Also:
-
-
Constructor Details
-
UnitProcessor
protected UnitProcessor()No instance of this class is required.
-
-
Method Details
-
svgToObjectBoundingBox
public static float svgToObjectBoundingBox(String s, String attr, short d, UnitProcessor.Context ctx) throws ParseException Returns the specified value with the specified direction in objectBoundingBox units.- Parameters:
s
- the valueattr
- the attribute name that represents the valued
- the direction of the valuectx
- the context used to resolve relative value- Throws:
ParseException
-
svgToObjectBoundingBox
public static float svgToObjectBoundingBox(float value, short type, short d, UnitProcessor.Context ctx) Returns the specified value with the specified direction in objectBoundingBox units.- Parameters:
value
- the valuetype
- the type of the valued
- the direction of the valuectx
- the context used to resolve relative value
-
svgToUserSpace
public static float svgToUserSpace(String s, String attr, short d, UnitProcessor.Context ctx) throws ParseException Returns the specified coordinate with the specified direction in user units.- Parameters:
s
- the 'other' coordinateattr
- the attribute name that represents the lengthd
- the direction of the coordinatectx
- the context used to resolve relative value- Throws:
ParseException
-
svgToUserSpace
Converts the specified value of the specified type and direction to user units.- Parameters:
v
- the value to converttype
- the type of the valued
- HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTHctx
- the context used to resolve relative value
-
userSpaceToSVG
Converts the specified value of the specified type and direction to SVG units.- Parameters:
v
- the value to converttype
- the type of the valued
- HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTHctx
- the context used to resolve relative value
-
percentagesToPixels
Converts percentages to user units.- Parameters:
v
- the percentage to convertd
- HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTHctx
- the context
-
pixelsToPercentages
Converts user units to percentages relative to the viewport.- Parameters:
v
- the value to convertd
- HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTHctx
- the context
-
pixelsToEms
Converts user units to ems units.- Parameters:
v
- the value to convertd
- HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTHctx
- the context
-
emsToPixels
Converts ems units to user units.- Parameters:
v
- the value to convertd
- HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTHctx
- the context
-
pixelsToExs
Converts user units to exs units.- Parameters:
v
- the value to convertd
- HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTHctx
- the context
-
exsToPixels
Converts exs units to user units.- Parameters:
v
- the value to convertd
- HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTHctx
- the context
-