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

    • svgStringToBuilder

      public static <T> @NonNull PathBuilder<T> svgStringToBuilder(@NonNull String str, @NonNull PathBuilder<T> builder) 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
      builder - the builder
      Returns:
      the path builder
      Throws:
      ParseException - if the String is not a valid path
    • awtPathIteratorToDoubleSvgString

      public static @NonNull String awtPathIteratorToDoubleSvgString(@NonNull Shape shape)
      Converts a Java AWT Shape iterator to a JavaFX Shape.
      Parameters:
      shape - AWT Shape
      Returns:
      SVG Path
    • awtPathIteratorToDoubleSvgString

      public static @NonNull String awtPathIteratorToDoubleSvgString(@NonNull Shape shape, AffineTransform at)
      Converts a Java AWT Shape iterator to a JavaFX Shape.
      Parameters:
      shape - AWT Shape
      at - Optional transformation which is applied to the shape
      Returns:
      SVG 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
    • awtShapeToDoubleRelativeSvgString

      public static @NonNull String awtShapeToDoubleRelativeSvgString(@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
    • svgStringReshapeToBuilder

      public static void svgStringReshapeToBuilder(@Nullable String pathstr, @NonNull javafx.geometry.Bounds b, @NonNull PathBuilder<?> builder)
      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:
      pathstr - an SVGPath String
      b - the desired bounds
      builder - the builder into which the path is output