SVG for FXML-Conversion

So some weeks ago I read Jasper Potts blog on FXG to FXML-Conversion tool (useing simple XSL-Stylesheet). This blog Jasper asked if there’s probably one day someone providing a conversion tool for SVG.

This has been on my list for some time now and because I was traveling a bit in the last 2 weeks I had some time to hack on such a converter. I’ve not used XSL but instead used xtend (svg-parser (java),fxml-converter (xtend)) (because an XML-File comes with a lot of multiline strings). It took some time to wrap my head around SVG and how I could translate this in FXML/JavaFX 2.0 API calls but I finally I’m at a point where I have something to show off:

Please note that the JavaFX 2.0 image on the left is only made up of primitive JavaFX 2.0 elements (Circles, SVGPaths, Rect, Gradients, …) and it by far does not yet handle all the nifty stuff one can do with SVG but it shows me that such a conversion tool is doable to some extend though e.g. when it comes to filtering, … SVG has much more definitions than the JavaFX-API currently provides.

I was not even able to convert the SVG-Gaussian-Blur to JavaFX’ Gaussian-Blur (but that might just me I’m not an expert in graphics stuff), SVG allows to apply multiple filters/effects to a node, … . So to provide full SVG-Support – without residing to libraries like Batik – in JavaFX 2.x we’d need more API (or at least a tutorial how to e.g. write custom effects) but even with the current API one can get quite far as you don’t notice any missing thing in the above screenshot.

I’ve pushed the orignal svg-File (from the KDE oxygen-theme) and the resulting fxml-File to my git repo so that you can compare them.

6 Responses to “SVG for FXML-Conversion”

  1. Good Job !!
    Fxml is so boring to write but interesting to use with cllaboration of graphic designers
    Is there any chance to be able to download it ? or to see it packaged into e(fx)clipse ?
    Thx

    • Yes the plan is to provide FXG and SVG import wizards within e(fx)clipse which can also run outside eclipse (e.g. as an ant-task)

  2. Great News !!! I’m impatient ot test it !

Trackbacks/Pingbacks

  1. Java desktop links of the week, January 24 | Jonathan Giles - January 24, 2012

    [...] Schindl has created a SVG to FXML converter, which he plans to include in a future release of his e(fx)clipse [...]

  2. JavaFX links of the week, January 24 // JavaFX News, Demos and Insight // FX Experience - January 24, 2012

    [...] Schindl has created a SVG to FXML converter, which he plans to include in a future release of his e(fx)clipse [...]

  3. e(fx)clipse 0.0.12 released | Tomsondev Blog - January 31, 2012

    [...] started working on SVG and FXG to FXML-Converters as I already outline in one my last posts my plan was to add them to e(fx)clipse to allow you converting those external formats to JavaFX 2.0 [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 73 other followers