Class SVGPath

All Implemented Interfaces:
XMLConstants, SVGSyntax, CSSConstants, SVGConstants

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.
Version:
$Id: SVGPath.java 1808888 2017-09-19 14:22:11Z ssteiner $
  • Constructor Details

    • SVGPath

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

    • toSVG

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

      public static String toSVGPathData(Shape path, SVGGeneratorContext gc)
      Parameters:
      path - the GeneralPath to convert
      Returns:
      the value of the corresponding d attribute
    • appendPoint

      private static void appendPoint(StringBuffer d, float x, float y, SVGGeneratorContext gc)
      Appends a coordinate to the path data