Class SVGPath

  • All Implemented Interfaces:
    SVGSyntax, CSSConstants, SVGConstants, XMLConstants

    public class SVGPath
    extends SVGGraphicObjectConverter
    Utility class that converts a Shape object into an SVG path element. Note that this class does not attempt to find out what type of object (e.g., whether the input Shape is a Rectangle or an Ellipse. This type of analysis is done by the SVGShape class). Note that this class assumes that the parent of the path element it generates defines the fill-rule as nonzero. This is not the SVG default value. However, because it is the GeneralPath's default, it is preferable to have this attribute specified once to set the default (in the parent element, e.g., a group) and then only in the rare instance where the winding rule is different than the default. Otherwise, the attribute would have to be specified in the majority of path elements.
    • Constructor Detail

      • SVGPath

        public SVGPath​(SVGGeneratorContext generatorContext)
        Parameters:
        generatorContext - used to build Elements
    • Method Detail

      • toSVG

        public org.w3c.dom.Element toSVG​(java.awt.Shape path)
        Parameters:
        path - the Shape that should be converted to an SVG path element.
        Returns:
        a path Element.
      • toSVGPathData

        public static java.lang.String toSVGPathData​(java.awt.Shape path,
                                                     SVGGeneratorContext gc)
        Parameters:
        path - the GeneralPath to convert
        Returns:
        the value of the corresponding d attribute