Chris Oliver's Weblog
- All
- F3
- JavaFX
- Programming
JavaFX SVG Translator Preview
It'll take a few more days before we post the code to OpenJFX, but in the meantime here's a preview of the latest version of our SVG to FX translator. The translator converts an SVG document into a single JavaFX class. Each definition id in the SVG is converted into a method of the class that returns the JavaFX equivalent of that element. The generated class itself is an instance of the JavaFX class Node, which means it can be used anywhere in a JavaFX Canvas.
Having this translator makes it straightforward to incorporate graphics created in vector drawing tools into JavaFX programs.
The below demo program consists of an SVG browser that uses the translator to convert SVG into JavaFX source code and then compiles and executes the result. In addition, the browser lets you view the original SVG source as well as the translated JavaFX source.
You can drag URL's that point at SVG files from web pages into the SVG Browser's canvas. It's pretty sad to see how little quality vector artwork is available on the public internet. Anyway, below are a few examples for you to try:
Posted at 11:53PM Jun 24, 2007 by Christopher Oliver in JavaFX | Comments[11]

http://upload.wikimedia.org/wikipedia/commons/7/74/Timeline_of_web_browsers.svg
After the translation the text is a bit of a mess.Posted by some geek on June 25, 2007 at 12:57 AM PDT #
Posted by Sam Ruby on June 25, 2007 at 06:43 AM PDT #
Posted by bjb on June 25, 2007 at 11:56 AM PDT #
Posted by Nir Tayeb on June 25, 2007 at 01:56 PM PDT #
Hi Chris--thanks for posting this, always enjoy your demos. I am pleasantly surprised by the performance, seems much snappier than the earlier SVG/F3 demo app. There does seem to be some copy-and-paste problem (am on JDK 6, Ubuntu Feisty)--copy a URL from this page (the one in the comments), paste into gEdit--OK, paste into SVG browser--pastes as a reference to InputStreamReader (java.io.InputStreamReader@17cc01d). Might be something funny about how Firefox handles copy, don't know.
Some URLs that do work: http://www.croczilla.com/svg/samples/butterfly/butterfly.svg, http://www.croczilla.com/svg/samples/lion/lion.svg.
Rendering performance is surprisingly good, as it scaling. I get CPU spikes when scrolling quickly up and down, but it settles down immediately.
Cheers
Patrick
Posted by Patrick Wright on June 25, 2007 at 11:18 PM PDT #
Posted by Harry on June 26, 2007 at 01:37 AM PDT #
http://www.oxygen-icons.org/nuno/CrystalOfficeIcons.tar.gz
Posted by aberrant on July 24, 2007 at 10:35 AM PDT #
There is a big hole in JavaFX.
Threading.
It seems from the language docs if you use "do" or "do later" you have to use Java classes and look after your own synchronization (and error returns).
This required a VERY skillful programmer.
What we need is threading and result synchronization that the 'average' programmer can use and access directly from the scripting language.
Posted by Matthew on September 13, 2007 at 07:29 PM PDT #
Hi..
Where is the source code populated?
I have trouble using the script code in my app. I like to see how it is done in the web start app..
Posted by Kasper on October 18, 2007 at 01:52 AM PDT #
Doesn't properly handle <text> elements that have transform attributes like this:
transform="matrix( ... )"
It just creates a text node in the Javafx w/o the transform.
Otherwise, great job!
Posted by Daniel Joyce on October 30, 2007 at 01:18 PM PDT #
Thanks
Posted by Digitürk on February 22, 2008 at 06:50 AM PST #