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> @NonNull PathBuilder<T> buildSvgString(@NonNull PathBuilder<T> builder, @NonNull 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 @NonNull String awtPathIteratorToDoubleSvgString(@NonNull 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 @NonNull String awtPathIteratorToDoubleRelativeSvgString(@NonNull 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 @NonNull String awtPathIteratorToFloatRelativeSvgString(@NonNull 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 @NonNull String awtPathIteratorToFloatSvgString(@NonNull 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 @NonNull Path2D.Double svgStringToAwtShape(@NonNull 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(@NonNull PathBuilder<?> builder, @Nullable String pathstr, @NonNull 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