When Eileen and I were working on our session for JavaOne on Designer-Developer workflow we needed a way of converting some vector graphics from Adobe Illustrator into JavaFX. So I tried the FXG to JavaFX converter I found on the web and did not have much luck as what Eileen and draw was pretty advanced. So I thought well FXG is a XML file and FXML is a XML file and as I used to do XML->XML conversion all the time for a previous job using XSLT. I thought how hard can be be to write a converter, well about 4 hours later and some dusting off of The XSLT book here is what I came up with:
I put a simple JavaFX UI around the XSLT conversion. There is not much code to the XSL file about 100 lines. It doesn’t support anywhere near all of the FXG file format and in some places it approximates the conversions rather than being exact. Even with its limitations its still very useful for quickly taking vector graphics into JavaFX. I think it would be simple to do exactly the same thing for SVG to FXML conversion, hopefully one of you will take this on and create a XSL file for that.
You can download the Netbeans project for this here:
The original graphic Eileen asked me to convert in Illustrator looks like:
And when converted to FXML in JavaFX it looks like:
Its not perfect but I think its not a bad quality of conversion for a couple hours work.