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

public final class FigmaReader

  1. Object
  2. FigmaReader

Reads a Figma file from the JSON of Figma’s REST API (GET /v1/files/:key) into an ArtDocument.

Request the file with geometry=paths: each node’s outline then comes as SVG path data, which is drawn exactly – boolean operations and vector networks included. Without it, rectangles, ellipses and frames are rebuilt from their sizes and other vectors are skipped with a note. FigmaClient fetches a file that way.

Every canvas (page) becomes a group under the root; the first is visible and the document is sized to its content. Frames, groups, components and instances keep their structure; fills, strokes, drop and inner shadows, layer and background blurs, blend modes, masks, opacity and text are read and rendered. Image fills are looked up by their imageRef.

Fields

public static final int MAX_DEPTH = 256The deepest node nesting read.
public static final int MAX_NODES = 500000The most nodes read.

Methods

public static ArtDocument read(InputStream json, Map<String, byte[]> images) throws IOExceptionReads a file’s JSON.
public static ArtDocument read(byte[] json, Map<String, byte[]> images) throws IOExceptionReads a file’s JSON from bytes.
public static List<String> imageRefs(Map<String, Object> json)The imageRef of every image fill in a file’s JSON, so the caller can fetch them.

Inherited methods

Field details

MAX_DEPTH

public static final int MAX_DEPTH = 256
The deepest node nesting read.

MAX_NODES

public static final int MAX_NODES = 500000
The most nodes read.

Method details

read

public static ArtDocument read(InputStream json, Map<String, byte[]> images) throws IOException
Reads a file’s JSON.

Parameters

json InputStream
the API response; read to its end, not closed
images Map<String, byte[]>
image fill bytes keyed by imageRef, or null to leave image fills empty

read

public static ArtDocument read(byte[] json, Map<String, byte[]> images) throws IOException
Reads a file’s JSON from bytes.

Parameters

json byte[]
the API response
images Map<String, byte[]>
image fill bytes keyed by imageRef, or null

imageRefs

public static List<String> imageRefs(Map<String, Object> json)
The imageRef of every image fill in a file’s JSON, so the caller can fetch them.

Parameters

json Map<String, Object>
the parsed API response