November 21st, 2008Inkscape and JavaFX working together
Inkscape is a open source cross-platform vector graphics editor application that I use daily to create draws.

When Project Nile was launched, me and some others guys complained about lack of open source alternatives in the workflow of creation with JavaFX. So we developed a module inside Inkscape that converts your SVG drawings to JavaFX code.
Features
- Both are free and open source technologies, providing more tools on a powerful workflow for programmers and designers to develop Rich Internet Applications.
- Comes natively with Inkscape. Install Inkscape an have JavaFX exporting out-of-the-box. No needing to install external plugins.
- Provides a way to Inkscape users to make RIA applications reusing their work at drawing tool.
- Provides a way to JavaFX programmers a tool for designers their graphics and interfaces.
- Keep separated the JavaFX programming logic from the graphics resources but also provide a way to connect them.
- They work on Windows, Mac OS, Linux, OpenSolaris and FreeBSD.
Workflow Example

I’ll show here step by step how would be a designer-developer workflow from designing graphical elements, such interfaces, to integrating it to a JavaFX Script code in NetBeans. In this example I’m using Inkscape 0.46-devel, build from the unstable sources and NetBeans 6.1 with the JavaFX module. See here how to build Inkscape from sources and here how to do some optimizations on the build.
Here’s a artwork (a modified version from another one I did in another post) made with Inkscape.
Doesn’t matter the complexity of the drawing it is made of discrete elements such circles, rectangles, paths and others. What the exporting module does is converting these SVG elements into JavaFX Scene Graph API elements.
To do that just click on File → Save As… or Shift+Ctrl+S.
Select JavaFx as the output format.
And chose a name. I’m saving the drawing as Girl.fx.
Now the drawing is a JavaFX class that extends from CustomNode. Once in your classpath (in this case the same directory of your main code) you can call it.
Girl{}
Another example, the famous SVG tiger.
Tiger{}
Actually, you can get the elements of your drawing as attributes nodes of the main node. We use the name you gave to your object to name the attributes.
import javafx.scene.paint.Color; var girl = Girl{} girl.rightiris.fill = Color.LIME; girl.fringe.fill = Color.WHITE; girl.backhair.fill = Color.DARKGRAY; girl.hair.fill = Color.GRAY;
import javafx.scene.paint.Color; var girl = Girl{} girl.rightiris.fill = Color.GREEN; girl.backhair.fill = Color.DARKRED; girl.hair.fill = Color.RED;
You can also put event handling by code.
import javafx.input.MouseEvent; var p = Player{} p.x.onMouseClicked = function( e: MouseEvent ):Void { java.lang.System.exit(0); }
As a ordinary JavaFX Node, you can do whatever you do with a Node, like using it inside a application or applying effects or transformations.
import javafx.application.Frame; import javafx.application.Stage; import javafx.scene.effect.SepiaTone; var girl = Girl{ scaleX: 0.5 scaleY: 0.5 effect: SepiaTone{} } Frame { visible: true stage: Stage { content: [girl] } }
Using this approach you can have the reference and total control under all those elements that compose your drawing. You can design complete interfaces and attach event handling by code.
Source code
The module is already on the main Inkscape dev tree and working properly. I guess it will be officially released to all users in the next Inkscape release.
Still to do
- Fix some problems with strokes.
- Fix some problems in the gradients.
- Use Zlib to create jfd files when the structure is too big.
- Provide a dynamic method like getElementById in JavaScript.
- Convert effects like blur to JavaFX effects.
- There are some i18n errors in the module to be fixed.
- Finish the adaption from Paths to SVGPaths.
- Finish the adaption to the new JavaFX 1.0 syntax (coming December, 2).
Thanks!
Thanks for all guys that worked on this module and also on the projects Inkscape and JavaFX. Specially thanks for Bob Jamison, Jim Clarke, Joshua Marinacci and others. That’s my first contribution to a big free software, I’m very glad and I want to do much more.

























November 21st, 2008 at 10:40 am
Boa Silveira, parabéns! Bem legal essa contribuição!
November 21st, 2008 at 11:39 am
About chosing the output format, it says “Compressed Inkscape SVG” twice. If that’s a screenshot, please report a bug.
November 21st, 2008 at 11:49 am
Way cool! I see you already realize that the JavaFX API and language will be changing with 1.0 and be incompatible from the preview release. For example javafx.application package isn’t there in the javadoc for the latest 1.0-prereleases and the Stage class is the preferred toplevel.
November 21st, 2008 at 3:18 pm
Include me in one of those sad with the lack of Inkscape integration in project Nile, i even posted in their forums.
Inkscape will be the best tool for do graphics for JFX.
I wish when 0.46 gets out, JavaFX 1 is out and the JFX exporter is good enought for work.
Bom trabalho Silveira!
November 21st, 2008 at 6:26 pm
@Porfirio: you definitely meant “When 0.47 is out”
November 21st, 2008 at 6:47 pm
Awesome! I’m looking forward to the release
Hehe… finally I can see myself actually getting to learn Inkscape.
November 22nd, 2008 at 10:40 am
I never understood, why Sun is feeding with Project Nile, what they want to fight with Java FX: Adobe.
Inkscape is such a solid drawing tool, while open source…. At least I would have expected Sun to support Open Office Draw, but even that is not supported.
Thank you very much for this wonderful export filter for Inkscape.
November 23rd, 2008 at 12:59 am
Carsten, we decided base on the survey we’ve done among designers communities. We haven’t met a single professional designer (i.e. a designer which makes living on doing designs) who would be using inskscape or gimp for the work. The reason very often was professional designers don’t care much about open source and while the price tag on the Adobe products might be annoying, the productivity and features of those products far exceed the expense they need to make.
November 24th, 2008 at 4:26 pm
Nice….
Can we get a release of this version when JavaFx is released?
November 24th, 2008 at 4:44 pm
Kendrick, probably not. The next version of Inkscape should be the version 0.47 and I guess in not planned to be launched this year (2008). In the other hand anyone can compile yourself Inkscape and distribute a especial release, but I guess is not the best thing to do because this would break the official calendar of the project.
So my suggestion is to you try to compile yourself the current development version of Inkscape.
November 24th, 2008 at 5:42 pm
It seems to be a small change…Can it be back ported to .46?
November 26th, 2008 at 1:55 am
Awesome! This Inkscape plugin alone has rekindled my interest in JavaFX. What a great idea!
November 26th, 2008 at 11:45 am
Very nice!
Hope I can try it very soon.
Regards,
Guido
November 26th, 2008 at 5:43 pm
Don’t forget that we make builds of the current development code for Win32 here. JavaFX export is definitely in these already.
http://inkscape.modevia.com/win32/?C=M;O=D
November 26th, 2008 at 5:44 pm
Really Cool Bob, that’s excatly what they are trying to find out!
November 26th, 2008 at 6:28 pm
[...] for all comments, suggestions and feedback on the post Inkscape and JavaFX working together. The JavaFX guru James Weaver posted about on his blog and it also figured out on java.sun.com on [...]
November 26th, 2008 at 8:48 pm
Cara, animal!
November 27th, 2008 at 12:24 am
Actually, i am really really appreciate your greate job. It almost changes my view to javafx
I am eager to see the release.
November 27th, 2008 at 5:11 am
Thanks!
November 27th, 2008 at 6:15 am
Wonderfull.
This gives me a good raison to test Inskape.
Bravo.
November 27th, 2008 at 8:51 am
[...] a recent post, Inkscape and JavaFX working together, Silveira explains a little about the new JavaFX export feature for [...]
November 27th, 2008 at 12:32 pm
This is a great plugin, for me, it will be one of the bests!
Thanks so much and keep going ahead!
November 28th, 2008 at 8:28 am
EXCELLENT Silveira!
Already liking Inkscape and now I can use it directly for JavaFx fun.
I’m all eager to create
December 2nd, 2008 at 7:00 am
Someone should immediately merge InkScape and some advanced editor (jEdit, Notepad++, SciTe or something) into an open source equivalent of Adobe Flash.
This is great!
December 3rd, 2008 at 4:55 am
[...] support has still a long way to go, but it is getting better (I really like to see this project to [...]
December 4th, 2008 at 5:06 am
This is the coolest thing I heard from JavaFX world. JavaFX without plugins for tools like Inkscape is useless.
Great work.
Kishore
December 4th, 2008 at 8:53 am
Would be cool to expand the plugin to exporting .fxd files as well. As I understand it, this will be the primary format to use when incorporating more complex graphics. That said, a little collaboration between the efforts of converting SVG to JavaFX and this sweet thing could probably speed things up further?
December 9th, 2008 at 9:14 pm
WooW
It is impressive.
December 10th, 2008 at 4:39 am
Thanks,
it’s a benefit for inkscape and javaFX,
December 17th, 2008 at 2:40 pm
Awesome work guys … !
Any idea when a JavaFX 1.0 compliant version will be checked in ?
What type of help is required ?
Seb
December 30th, 2008 at 10:32 am
Hey! Really very nice! All of your work. I have just read half of your blog
So to follow up on my predecessor: When will a JavaFX 1.0 compliant version be available?
I have just tried out the latest Inkscape build (Inkscape20412-0812291919) and it still does export the pre-1.0 code!
Thanks,
Adam