Home > javafx > JavaFX – SVGPath

JavaFX – SVGPath

We recently celebrated Holi – Festival of Colours.
It was real fun! Now lets try to celebrate Holi with JavaFX!.

You can create an SVG path in JavaFX using SVGPath class. It accepts content which is a string formatted as specified here.

SVGPath {
    content: "M48.859,43.518c8.424,17.64,2.736,140.832-7.128,184.032"
    fill: Color.BLACK

We can combine a series of SVGPath to create the final image. Now we can manipulate attributes of individual SVGPath such as fill, stroke, strokeWidth etc. I’m using the same ColorChooser code as in previous post.

For Applet mode, click on above image

For standalone mode

To paint Duke select any part of Duke and then select a color from color chooser.
Now you can play Holi with Duke! Have fun!


var dzone_url = “http://blogs.sun.com/rakeshmenonp/entry/javafx_svgpath”;
var dzone_style = ‘2’;

Categories: javafx Tags: ,
  1. March 14, 2009 at 3:56 AM

    Very nice. I am not able to deselect it. Is it possible to deselect on next click because that selected line, not allow me to see the duke nicely with other colors.

  2. Farrukh Obaid
    March 14, 2009 at 3:10 PM

    Nice demo
    Please check my demo i created in JavaFX my first Demo on my website
    i will enhance this demo to complete website in JavaFX ur help will be needed

  3. March 16, 2009 at 5:21 AM

    @Vaibhav Thanks! Added toggle selection

  4. March 16, 2009 at 5:27 AM

    @Farrukh Thatz cool! Great start.. ‘ll definitely help you.

  5. Farrukh Obaid
    March 16, 2009 at 3:51 PM

    thanks Rakesh
    1) how to embed True Type Font(ttf) in JavaFX
    i think we can embed in FXZ format by using
    Font.fontFromURL(path,size) i check this works but i want to use in normal fx file it is not working..
    2) first time we see applet it chached in the system i update file and upload again "with the same name" when i browse applet it load previoud version in order to see new one i delete the file from cache is there any method to tackle this…

  6. Rakesh Menon
    March 16, 2009 at 9:59 PM

    @Farrukh (1) I think its not supported, I didn’t find any public APIs. Yes, there are some internal APIs, but that is not recommended. I’ll confirm this and get back to you. (2) By default the cache system depends on timestamp, so ideally it must load the new jar after few minutes. This is not reliable, also may fail on slow network. The check times out after few seconds. You need to use versioning for reliable mechanism.

  7. Rakesh Menon
    March 19, 2009 at 11:46 PM

    @Farrukh Thanks for your question. I have a new post on how to use ttf font – http://blogs.sun.com/rakeshmenonp/entry/javafx_custom_fonts

  1. No trackbacks yet.

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 )

Google+ photo

You are commenting using your Google+ 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

%d bloggers like this: