Repository navigation
Design Import: turn Figma, Sketch, PSD, SVG and HTML designs into forms - #6355
Conversation
…ip proof Adds scripts/designimport, a Codename One app whose engine turns a PSD, Sketch, Figma or SVG document into a Form, theme.css and a unit test: scope, detect, structure, classify, layout, responsive, style and emit stages, with issues and TODOs recorded per stage, a live preview and a fidelity score (SSIM plus component-box overlap). RoundTripTest builds the twelve GUI Builder demo forms with a known theme, exports them to SVG with every layer renamed generically, and re-imports them: 71 of 74 components come back with the right role. Core: art nodes keep layout attributes through copies and the native format; Sketch outline masks with no fill no longer hide their content. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every round-trip form, every docs Sketch file and a design of hostile layer names (keywords, digits, duplicates, comment terminators, quotes, backslashes, non-ASCII) now has its generated Form, Base and test classes compiled with javac and checked for ASCII. The docs Sketch files are the held-out set: collapsing single-child wrappers lowered every one of them, so only groups nobody named are collapsed now, and SmokeTest holds their scores to a floor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DesignImportService exposes open, frames, options, run, tree, issues, set, resolve, preview, score and emit as JSON-ready operations; the designimport_* MCP tools, the CLI (one-shot, --script, --mcp-stdio) and ServiceTest all drive the same code. emit adds the form stylesheet to theme.css through @import, since a project build compiles only theme.css, and never overwrites the user's subclass. design-import.sh --mcp-smoke runs a real JSON-RPC session and fails on anything but protocol output on stdout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… warning ExamplesTest writes examples/: the twelve demo forms through SVG, three through PSD, a phone/tablet pair and a screen inside a device mockup, each with before/after renders, the generated sources and its issues. Fixes found on the way: frames without layer ids (every SVG and hand-built document) resolved to the whole document; tablets were classed as phones by aspect alone; a design that is only pictures now raises a "flattened" warning instead of scoring well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Layers, the design and the live form side by side, an inspector that overrides role, layout and UIID, the issue checklist grouped by stage, a phone/tablet/width switcher and an onion skin of the design over the form. Every action goes through DesignImportService, the operations the MCP tools expose. Dark desktop theme in theme.css. WorkbenchTest drives it headlessly against the app's compiled theme and renders examples/workbench.png. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
designimport.yml runs the tests, regenerates the gallery as an artifact and runs the MCP smoke session; on a pull request only when the tool, its inputs (demo forms, guide Sketch files) or the core readers change, and nightly otherwise. ExamplesTest re-imports the twelve SVG round trips only when it writes the gallery, since RoundTripTest already scores them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app theme carries the standard header; the generated example gallery is skipped by the header gate, since it is the tool's output and is rewritten on every regeneration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GeneratedCompiles now loads what it compiled and runs the emitted test against the emitted form on the EDT with the emitted stylesheet, for every round trip, docs file and hostile-name design; until now they were only compiled. The workbench screenshot shows the file name, not the machine's directory. The chapter says what the generated test checks; the workflow drops two general core paths, per the nightly policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
createBufferedImage never makes a buffer below 20x20, but updateBufferSize compared the buffer with the raw canvas size. A canvas that was never shown is 0x0 (headless runs, unit tests, command line tools), so every call replaced the buffer, dropped the Graphics2D, and getGraphics2D slept 10ms to make a new one -- once for each stringWidth and font height. Design Import's suite went from 8 minutes to 13 seconds; one import from 13s of rendering to 0.3s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… project The engine and its command line move into the reactor module maven/design-import (codenameone-design-import). Neither build plugin depends on it: cn1:import-design resolves it at the plugin's own version and forks it, and the Gradle importDesign task does the same through a cn1DesignImport configuration, so a project that never imports a design never downloads it. The CLI's new --project mode prints each pipeline stage on standard error as it finishes, and both plugins pass those lines through as progress; a whole import takes one to two seconds, most of it JVM start. The module joins the SpotBugs gate at zero. gradle-app-test.sh and designimport.yml run an import in a generated application and build what it wrote. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sign
`mvn cn1:import-design` and `./gradlew importDesign` with no design named (or with
cn1.design.gui=true) open a wizard: choose the design, choose the screen in it (or let
the import pair a phone frame with its tablet twin), review in the workbench, and write
the form into the project. The window, its launcher and its stylesheet move into the
codenameone-design-import jar so the build tools can run them; the scripts app is now a
shell around them. Closing the window early exits with its own status, which the build
reports as "nothing was imported" rather than a failure.
Bugs the wizard turned up, fixed here:
- SvgReader ignored data-name, so every layer name written by SvgWriter or Illustrator
was lost.
- A multi-frame SVG imported as one frame: the <svg> wrapper group is now recognised as
holding screens when it draws nothing itself and its children are non-overlapping
screen-sized groups.
- With names back, a text layer named after its own text ("Inner box button") was
classified by that name; such a name is no longer read as a role hint. Layout overlap
rose on 10 of the 12 SVG round-trip examples.
- The headless --frame always imported the chosen frame as a phone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The wizard's screen step is a grid of every screen in the design, all chosen to begin with; each becomes a form of its own (a phone and a tablet frame of one screen stay one adaptive form), named after its screen and written in one pass. Choosing a screen no longer re-runs the import, which is what made the old toggles flicker and drop the selection. The review step shows the design and the form side by side, each scaled to its pane, with the selected element outlined on both. A click on either picture selects the element under it. Issues carry the bounds of their element, and a guide walks them one at a time, warnings first, outlining each. A tour of the panes plays the first time. A-/A+ scale every text in the tool and are remembered. The theme is restyled: cards, chips, segmented controls. UI kit mockups: the phone's home indicator is chrome and left out, overlapping shapes with no text are one picture, and a tab bar wrapped in its own backdrop adopts it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…review Issue rows wrap and carry the whole text as a tooltip; clicking one brings it into the guide. The guide offers alternatives under "Or try" (another component kind, a picture, exact positions, keep chrome, leave it out). The form pane renders at a real phone or tablet size. Name hints match whole words only, so "Credits" is no longer a text field via "edit". Going Back no longer re-adds components that are already on a page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A symbol instance whose size differs from its master was drawn as the
master scaled to fit, which stretched every chat bubble's text. The
master is now copied, the overrides are applied to the copy (a swapped
nested symbol takes its slot's frame; a nested override reaches only
the instance its path names) and each layer is placed by its resizing
constraint. A text that fits its content and got a longer string pushes
the layers to its right, as Sketch does. A detached symbol's override
that names no layer applies to the master's only text.
The options op refuses a variant that is not {scope, kind}. A passed
wizard step is a button back to it. The tool's theme turns on the
desktop scrollbars core already has (track click pages, thumb drags).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ned workbench The pipeline: - A layer that dims the screen and holds a smaller panel becomes a popup that a tap outside closes; one at the bottom edge becomes a bottom sheet. - A screen drawn taller than a device scrolls between its title bar and tab bar. A lone full-screen wrapper group is hoisted so both bars are found. A strip that runs past the edge scrolls sideways. - A rectangular mask keeps its layers when it cuts none of them, instead of turning the whole screen into one picture. Boolean shapes rasterize. - Layers are ordered by paint order. - Captions keep 30% headroom inside their box, so a wider device font does not truncate them. Check box captions follow their box. - Field hints take the design's colour, font and inset. - A labelled field symbol is a group holding the field. - Full-width layers stretch, and a fixed item in the middle of a bar stays centred. The workbench: - A screen chip strip replaces the screen combo. - The size bar is two rows, so nothing overlaps in a narrow pane. - A Code card shows the Java and CSS behind the selection, with the whole files a click away. - A Resizing card holds stretch, scroll, max width and breakpoints. - Thumbnails are supersampled. - Combo and popup styles are consistent. - Examples, scores and screenshots are regenerated, and the docs cover the live preview, the cards, popups and long screens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e presets Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It read only the path field, so with the field empty a press did nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…calmer review column
- scripts/designimport starts the four-step wizard again; the bare workbench is behind
-Ddesignimport.workbench=true.
- A selection dims what is around it instead of tinting it pink, in the design and the
form alike, so its detail stays readable.
- Picking a row in All issues no longer scrolls the column away from it; the list sits
under the guide, and the Code and Resizing cards open on request.
- A pill hugging its text keeps the design's inset and centres the text vertically; only a
wide bar's inset is trimmed to its title's headroom ("20 C" was squeezed).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… ranking test - The review step's screen chips are a drop-down again, between previous and next, so the bar stays one line however many screens there are. - Inside the wizard the workbench reports into the wizard's status line; the second bottom row is gone. - ConversionRankTest converts every frame of the given designs, scores each against the design's render and writes a worst-first report with the worst frames side by side (-Ddesignimport.rank=files). - Layers named dialog/popup/sheet/modal are popups; the layer list says so. - A price and a wide button make a row whose button takes the rest; a caption nudged off centre stays centred; text across most of the screen wraps. - Stacked fills are exported as one image, and an image background drops the border that painted over it; strips wider than the screen scroll. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…buttons - The code card colours Java and CSS with the code editor's own tokenizer. - The form's device, size and mode controls sit in one bar above both the design and the form, so the two panes start level. - The screen picker's text is readable and its bar is centred vertically. - Selecting a layer restyles two rows instead of rebuilding the list, which scrolled it back to the top. - Layers named radio are RadioButtons in one group, drawn as the design's ring and dot; the drawn dot picks the selected one. - A group named "Buttons" holding a button and a link stays a group, and one named "icon" with its caption inside is not flattened to a picture. - A design longer than the device shows at its whole length. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ainst the preview - The screen picker and the live view's size, rotation and mode controls move into the wizard's top toolbar; the steps move into the bottom bar. Rows are centred with valign-by-row, which is what misaligned the picker's arrows. - The live view's stage scrolls without making the form take its preferred width, so long text wraps inside the screen instead of running past its edge. - A switch is drawn in the design's track and thumb colours, in the preview and in the generated code, so both states are visible. - The write page can be built twice (Back then Next) without reusing attached fields. - Generated forms arrange for their own width and read images through resource(). - GeneratedCompiles builds the compiled form and holds its pixels to the preview; the examples, the docs Sketch files and the wizard's written form go through it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rong, the target folder follows the package Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bol labels, unreadable text flagged Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…et a Figma token Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed text sizes the bubble Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ields, a reading status Figma's quota on whole-file reads is small; a Starter token was locked out for four days after a few reads. A fetched file is kept under the app home and reopened when Figma refuses, and the refusal says how long Figma asks to wait. A tall box with one grey line at its top left imports as a multi-line field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… branch ending the loop Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Figma link imports headless too The developer guide chapter gains a section on importing from a Figma link (getting a token, FIGMA_TOKEN, the rate limit and the saved copy), the step tours, and screenshots of the real wizard. cn1:import-design and the Gradle importDesign task passed a Figma link through as a file path and failed; they now hand it to the tool as written. A multi-line field starts its text and hint at the top, as the design draws it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… for refusals, Chrome off the EDT A class or package name from the wizard, the CLI, the plugins or MCP is refused unless it is a Java name, so it can no longer write outside the sources. A Figma 403 or 404 no longer opens the saved copy; only the rate limit or no connection does. An HTML prototype is read in invokeAndBlock so the wizard keeps painting. A theme that starts with @charset keeps it first. A Figma key is ASCII, as the client and the cache expect. The chapter names the run stages and the full options. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Generated comments carry the frame and file names as printable ASCII with no backslash, so a name like C:\users or a non-ASCII one cannot break the build. Every arrangement sets each component's margin, zeros included, as the live preview does, so a tablet margin no longer stays behind on the phone layout. The generated test checks the narrowest arrangement, the one the simulator shows. An empty package is refused, both names are checked before either is kept, a refused open keeps the previous session, and the error reads without the exception class. The wizard stops when its class name is refused. The workflow no longer cleans away the gallery it uploads, and runs for the Gradle task and CoachMarks too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cing a workstation's env.sh tools/env.sh names one machine's JDK paths; on the CI runner it replaced the container's valid JAVA_HOME and the MCP smoke step failed before starting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rowing on the EDT Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…into, not HOME's Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Compared 288 screenshots: 288 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
Native fidelity (Android, Material 3)54 pairs compared -- median 95.6%, worst 91.3% ( Distribution --
Geometry vs native (bbox offset / size ratio / center offset / corner radius) -- gated separately from the visual score
Side-by-side comparisons (worst first)
|
Cloudflare Preview
|
|
Compared 12 screenshots: 12 matched. |
|
Compared 380 screenshots: 380 matched. |
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
|
Compared 303 screenshots: 303 matched. Benchmark ResultsDetailed Performance Metrics
ParparVM vs HotSpot (JDK 25): Windows x64Runner CPU: AMD64 Family 25 Model 17 Stepping 1, AuthenticAMD (baseline Ratios are ParparVM / JDK 25: below 1.00x ParparVM is faster (time) or smaller (RAM). Median of 5 interleaved, paired rounds; every run's output was verified. A ratio more than 20% (time) / 25% (RAM) above its baseline in
Result: no regression |
|
Compared 303 screenshots: 303 matched. ParparVM vs HotSpot (JDK 25): Linux x64Runner CPU: AMD EPYC 9V45 96-Core Processor (baseline Ratios are ParparVM / JDK 25: below 1.00x ParparVM is faster (time) or smaller (RAM). Median of 5 interleaved, paired rounds; every run's output was verified. A ratio more than 20% (time) / 25% (RAM) above its baseline in
Result: no regression |
|
Compared 303 screenshots: 303 matched. ParparVM vs HotSpot (JDK 25): Linux arm64Runner CPU: Neoverse-N2 (baseline Ratios are ParparVM / JDK 25: below 1.00x ParparVM is faster (time) or smaller (RAM). Median of 5 interleaved, paired rounds; every run's output was verified. A ratio more than 20% (time) / 25% (RAM) above its baseline in
Result: no regression |
|
Compared 303 screenshots: 303 matched. Benchmark ResultsDetailed Performance Metrics
|
|
Compared 303 screenshots: 303 matched. Benchmark ResultsDetailed Performance Metrics
ParparVM vs HotSpot (JDK 25): Windows arm64Runner CPU: ARMv8 (64-bit) Family 8 Model D49 Revision 0, MICROSOFT CORPORATION (baseline Ratios are ParparVM / JDK 25: below 1.00x ParparVM is faster (time) or smaller (RAM). Median of 5 interleaved, paired rounds; every run's output was verified. A ratio more than 20% (time) / 25% (RAM) above its baseline in
Result: no regression |
… as the snippet gate requires Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>












































































































Design Import: turn a design into a Codename One form
A new tool that reads a Figma link or file, Sketch, PSD, SVG or a React/HTML prototype and writes a
Form(a generated base class plus a subclass you own), a stylesheet and a unit test.maven/design-import: scope, classify, structure, layout, responsive, style and emit stages, with every guess and CSS compromise recorded as an issue. Pure Java on core, tested headless.scripts/designimport: four steps (design, screens, review, write), with the design and the live form side by side, size switching, interact mode, the generated code per element, and a coach-mark tour on every step.mvn cn1:import-designand./gradlew importDesign(window or headless; a Figma link works headless withFIGMA_TOKEN), a CLI, and MCP tools (designimport_*) so an LLM can drive the import.FigmaClientreportsRetry-After,CoachMarksfixes, and a JavaSE port buffer fix.Design-Import.asciidoc, with screenshots taken from the running tool.design-importis in the SpotBugs zero-findings lists, anddesignimport.ymlruns it nightly and on PRs that touch its inputs.Before this PR, the branch went through two adversarial review rounds; every confirmed finding was fixed. Locally, SpotBugs and PMD report 0 for core-unittests and design-import, and the design-import, Maven plugin and Gradle plugin tests pass.
Screenshots show the Laza E-commerce UI Kit (Figma Community, CC BY 4.0).
🤖 Generated with Claude Code