Class SvgReader

java.lang.Object
com.codename1.art.SvgReader

public final class SvgReader extends Object

Reads SVG 1.1 and SVG 2 static documents into an ArtDocument.

Covers shapes and paths, groups, nested svg, use with symbol, switch, presentation attributes, inline styles and <style> sheets (type, class, id and compound selectors), gradients with href inheritance, patterns, clipPath, mask, every filter primitive, text with tspan, image with data URLs and resolved links, mix-blend-mode and viewBox with preserveAspectRatio. Markers are expanded into shapes. Animation and scripts have no static meaning and are reported as notes.

  • Constructor Details

    • SvgReader

      public SvgReader()
  • Method Details

    • setResolver

      public SvgReader setResolver(SvgReader.ResourceResolver resolver)

      Sets what loads linked images and documents; without one only data URLs are read.

      Parameters
      • resolver: the resolver, or null
    • read

      public static ArtDocument read(InputStream in) throws IOException

      Reads an SVG document.

      Parameters
      • in: the document; not closed
      Throws:
      IOException
    • read

      public static ArtDocument read(byte[] data) throws IOException

      Reads an SVG document from bytes.

      Parameters
      • data: the document
      Throws:
      IOException
    • parse

      public ArtDocument parse(InputStream in) throws IOException

      Reads an SVG document with this reader's settings.

      Parameters
      • in: the document; not closed
      Throws:
      IOException
    • transform

      public static Matrix transform(String v)

      Parses an SVG transform attribute.

      Parameters
      • v: the attribute; null gives the identity