Class SvgPaths

java.lang.Object
org.jhotdraw8.geom.SvgPaths

public class SvgPaths extends Object
Provides methods for parsing and generating SVG path strings from AWT paths.
  • Method Details

    • buildSvgString

      public static <T> PathBuilder<T> buildSvgString(PathBuilder<T> builder, String str) throws ParseException
      Returns a value as a SvgPath2D.

      Also supports elliptical arc commands 'a' and 'A' as specified in w3.org

      Parameters:
      builder - the builder
      str - the SVG path
      Returns:
      the path builder
      Throws:
      ParseException - if the String is not a valid path
    • awtPathIteratorToDoubleSvgString

      public static String awtPathIteratorToDoubleSvgString(PathIterator iter)
      Converts a Java Path iterator to a SVG path with double precision.
      Parameters:
      iter - AWT Path Iterator
      Returns:
      SVG Path
    • awtPathIteratorToDoubleRelativeSvgString

      public static String awtPathIteratorToDoubleRelativeSvgString(PathIterator iter)
      Converts a Java Path iterator to a SVG path with double precision.
      Parameters:
      iter - AWT Path Iterator
      Returns:
      SVG Path
    • awtPathIteratorToFloatRelativeSvgString

      public static String awtPathIteratorToFloatRelativeSvgString(PathIterator iter)
      Converts a Java Path iterator to a SVG path with double precision.
      Parameters:
      iter - AWT Path Iterator
      Returns:
      SVG Path
    • awtPathIteratorToFloatSvgString

      public static String awtPathIteratorToFloatSvgString(PathIterator iter)
      Converts a Java Path iterator to a SVG path with float precision.
      Parameters:
      iter - AWT Path Iterator
      Returns:
      SVG Path
    • svgStringToAwtShape

      public static Path2D.Double svgStringToAwtShape(String str) throws ParseException
      Returns a value as a SvgPath2D.

      Also supports elliptical arc commands 'a' and 'A' as specified in w3.org

      Parameters:
      str - the SVG path
      Returns:
      the SvgPath2D
      Throws:
      ParseException - if the String is not a valid path
    • buildReshapedSvgString

      public static void buildReshapedSvgString(PathBuilder<?> builder, @Nullable String pathstr, javafx.geometry.Bounds b)
      Fits the specified SVGPath into the given bounds.

      If parsing the SVG Path fails, logs a warning message and fits a rectangle into the bounds.

      Parameters:
      builder - the builder into which the path is output
      pathstr - an SVGPath String
      b - the desired bounds