Class UnitProcessor

  • Direct Known Subclasses:
    UnitProcessor

    public abstract class UnitProcessor
    extends java.lang.Object
    This class provides methods to convert SVG length and coordinate to float in user units.
    • Field Detail

      • HORIZONTAL_LENGTH

        public static final short HORIZONTAL_LENGTH
        This constant represents horizontal lengths.
        See Also:
        Constant Field Values
      • VERTICAL_LENGTH

        public static final short VERTICAL_LENGTH
        This constant represents vertical lengths.
        See Also:
        Constant Field Values
      • OTHER_LENGTH

        public static final short OTHER_LENGTH
        This constant represents other lengths.
        See Also:
        Constant Field Values
    • Constructor Detail

      • UnitProcessor

        protected UnitProcessor()
        No instance of this class is required.
    • Method Detail

      • svgToObjectBoundingBox

        public static float svgToObjectBoundingBox​(java.lang.String s,
                                                   java.lang.String attr,
                                                   short d,
                                                   UnitProcessor.Context ctx)
                                            throws ParseException
        Returns the specified value with the specified direction in objectBoundingBox units.
        Parameters:
        s - the value
        attr - the attribute name that represents the value
        d - the direction of the value
        ctx - 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 value
        type - the type of the value
        d - the direction of the value
        ctx - the context used to resolve relative value
      • svgToUserSpace

        public static float svgToUserSpace​(java.lang.String s,
                                           java.lang.String attr,
                                           short d,
                                           UnitProcessor.Context ctx)
                                    throws ParseException
        Returns the specified coordinate with the specified direction in user units.
        Parameters:
        s - the 'other' coordinate
        attr - the attribute name that represents the length
        d - the direction of the coordinate
        ctx - the context used to resolve relative value
        Throws:
        ParseException
      • svgToUserSpace

        public 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.
        Parameters:
        v - the value to convert
        type - the type of the value
        d - HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTH
        ctx - the context used to resolve relative value
      • userSpaceToSVG

        public 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.
        Parameters:
        v - the value to convert
        type - the type of the value
        d - HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTH
        ctx - the context used to resolve relative value
      • percentagesToPixels

        protected static float percentagesToPixels​(float v,
                                                   short d,
                                                   UnitProcessor.Context ctx)
        Converts percentages to user units.
        Parameters:
        v - the percentage to convert
        d - HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTH
        ctx - the context
      • pixelsToPercentages

        protected static float pixelsToPercentages​(float v,
                                                   short d,
                                                   UnitProcessor.Context ctx)
        Converts user units to percentages relative to the viewport.
        Parameters:
        v - the value to convert
        d - HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTH
        ctx - the context
      • pixelsToEms

        protected static float pixelsToEms​(float v,
                                           short d,
                                           UnitProcessor.Context ctx)
        Converts user units to ems units.
        Parameters:
        v - the value to convert
        d - HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTH
        ctx - the context
      • emsToPixels

        protected static float emsToPixels​(float v,
                                           short d,
                                           UnitProcessor.Context ctx)
        Converts ems units to user units.
        Parameters:
        v - the value to convert
        d - HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTH
        ctx - the context
      • pixelsToExs

        protected static float pixelsToExs​(float v,
                                           short d,
                                           UnitProcessor.Context ctx)
        Converts user units to exs units.
        Parameters:
        v - the value to convert
        d - HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTH
        ctx - the context
      • exsToPixels

        protected static float exsToPixels​(float v,
                                           short d,
                                           UnitProcessor.Context ctx)
        Converts exs units to user units.
        Parameters:
        v - the value to convert
        d - HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTH
        ctx - the context