public final class SurfaceRasterizer
- Object
- 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 types
class SurfaceRasterizer.ActionRect | The absolute bounds of a node that carries a tap action, in pixels of the rasterized image. |
class SurfaceRasterizer.Result | The output of a rasterization pass: pixels, action hit rectangles and the next re-render deadline. |
Methods
Inherited methods
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)Parameters
nodeMap<String, Object>- a parsed descriptor node map as produced by the serializer and parsed back with
com.codename1.io.JSONParser stateMap<String, Object>- the current entry’s state map, may be null
imagesMap<String, byte[]>- PNG blobs keyed by wire name, may be null
widthint- target width in pixels
heightint- target height in pixels
darkboolean- true to resolve dark-mode colors
nowlong- the current epoch millis used for dynamic text and interval progress
Returns
currentEntry
public static Map<String, Object> currentEntry(Map<String, Object> timelineDoc, long now)Parameters
timelineDocMap<String, Object>- a parsed timeline JSON document
nowlong- the current epoch millis
Returns
date, state), or nullnextEntryFlip
public static long nextEntryFlip(Map<String, Object> timelineDoc, long now)now, or 0 when no future entry
exists.Parameters
timelineDocMap<String, Object>- a parsed timeline JSON document
nowlong- the current epoch millis
Returns
layoutForSize
public static Map<String, Object> layoutForSize(Map<String, Object> timelineDoc, String sizeName)Picks the layout of a timeline document for a size name (small / medium / large /
lockscreen / the watch* complication families): the explicit per-size layout when
present, else a family-specific substitute, else the default layout, else null.
Two substitutions, matching what the platform renderers do so a preview and a device
agree. watchCorner falls back to watchCircular, because a corner complication is
round and Wear OS has no corner slot at all; watchRectangular falls back to
lockscreen, which is the same WidgetKit family on Apple.
Parameters
timelineDocMap<String, Object>- a parsed timeline JSON document
sizeNameString- the wire-format size name
Returns
formatDynamicText
public static String formatDynamicText(String style, long dateMillis, long now)Formats a dynamic-text value the way the OS-native views would show it.
Public because a surface that cannot tick natively needs the text form: a Wear complication slot takes a string, and a Tile freezes its value between timeline flips. Both go through this rather than formatting for themselves, so a countdown reads the same on a watch face as in the simulator preview and on a home screen.
Parameters
styleString- the wire style name (
timerDown,timerUp,time,date,relative) dateMillislong- the target epoch millis
nowlong- the current epoch millis