Class SurfaceRasterizer
A shared software renderer for desktop ports (the JavaSE simulator, the native Windows and
Linux ports): draws a parsed surface descriptor node into a mutable Codename One Image using
only Graphics primitives -- no Container/Label components and no theme dependence, so the
output looks the same on every desktop surface. Must run on the EDT (it creates images and
measures fonts).
The input is the wire format produced by SurfaceSerializer parsed back with
com.codename1.io.JSONParser -- numbers may arrive as Double or Long, both are handled.
Alongside the pixels the rasterizer returns the absolute hit rectangles of every node carrying
an action, plus the epoch time when a re-render is due for time-driven content (countdowns,
clocks, date-interval progress).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe absolute bounds of a node that carries a tap action, in pixels of the rasterized image.static classThe output of a rasterization pass: pixels, action hit rectangles and the next re-render deadline. -
Method Summary
Modifier and TypeMethodDescriptioncurrentEntry(Map<String, Object> timelineDoc, long now) Returns the timeline entry whose date most recently passed, or the first entry when none passed yet, or null for an entry-less document.layoutForSize(Map<String, Object> timelineDoc, String sizeName) Picks the layout of a timeline document for a size name (small/medium/large/lockscreen): the explicit per-size layout when present, else thedefaultlayout, else null.static longnextEntryFlip(Map<String, Object> timelineDoc, long now) Returns the epoch millis of the next entry flip afternow, or 0 when no future entry exists.static SurfaceRasterizer.Resultrasterize(Map<String, Object> node, Map<String, Object> state, Map<String, byte[]> images, int width, int height, boolean dark, long now) Rasterizes a descriptor node into a transparent image of the requested size.
-
Method Details
-
rasterize
public static SurfaceRasterizer.Result rasterize(Map<String, Object> node, Map<String, Object> state, Map<String, byte[]> images, int width, int height, boolean dark, long now) Rasterizes a descriptor node into a transparent image of the requested size. Must run on the EDT.
Parameters
node: a parsed descriptor node map as produced by the serializer and parsed back withcom.codename1.io.JSONParserstate: the current entry's state map, may be nullimages: PNG blobs keyed by wire name, may be nullwidth: target width in pixelsheight: target height in pixelsdark: true to resolve dark-mode colorsnow: the current epoch millis used for dynamic text and interval progress
Returns
the rasterization result
-
currentEntry
Returns the timeline entry whose date most recently passed, or the first entry when none passed yet, or null for an entry-less document.
Parameters
timelineDoc: a parsed timeline JSON documentnow: the current epoch millis
Returns
the active entry map (
date,state), or null -
nextEntryFlip
-
layoutForSize
Picks the layout of a timeline document for a size name (
small/medium/large/lockscreen): the explicit per-size layout when present, else thedefaultlayout, else null.Parameters
timelineDoc: a parsed timeline JSON documentsizeName: the wire-format size name
Returns
the layout's root node map, or null
-