Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class SvgReader

  1. Object
  2. SvgReader

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.

Nested types

interface SvgReader.ResourceResolverLoads what an href names.

Constructors

public SvgReader()

Methods

public SvgReader setResolver(SvgReader.ResourceResolver resolver)Sets what loads linked images and documents; without one only data URLs are read.
public static ArtDocument read(InputStream in) throws IOExceptionReads an SVG document.
public static ArtDocument read(byte[] data) throws IOExceptionReads an SVG document from bytes.
public ArtDocument parse(InputStream in) throws IOExceptionReads an SVG document with this reader’s settings.
public static Matrix transform(String v)Parses an SVG transform attribute.

Inherited methods

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 SvgReader.ResourceResolver
the resolver, or null

read

public static ArtDocument read(InputStream in) throws IOException
Reads an SVG document.

Parameters

in InputStream
the document; not closed

read

public static ArtDocument read(byte[] data) throws IOException
Reads an SVG document from bytes.

Parameters

data byte[]
the document

parse

public ArtDocument parse(InputStream in) throws IOException
Reads an SVG document with this reader’s settings.

Parameters

in InputStream
the document; not closed

transform

public static Matrix transform(String v)
Parses an SVG transform attribute.

Parameters

v String
the attribute; null gives the identity