FX animations contd - A rudimentary screensaver

I was little off the hook with FX for a week now since Consumer JRE has taken up most of my time. As stated in Chet's blog, there is so much of cool stuff lined up for the Java community through consumer JRE and catch a glimpse of it when you get time.

Coming back to FX, I wanted to spend some time on Groups which can be considered as a non-visual container that offers the capability of combining multiple visual objects together and performing various transformations on the group as a whole. Groups by default introduces a new coordinate system and graphical objects assigned to the group are placed with respect to the group's origin.

The flexibility and convenience that the group offers to FX programmers is significant in my view and the ability to treat multiple objects as one and being able to perform operations/transformations on the group of objects as a whole is simply awesome. Groups directly exposes one of the primary advantages of the underlying scenegraph model, to the FX developer.

As I stated in one of my earlier postings, one of my other goals was to use pure FX animation loops in lieu of Swing Timer. But I was little short of ideas when it came to developing a small demo. Sitting in front of my machine, I was thinking for a while and fortunately it was long enough to trigger the screensaver on my linux box that broke my desktop into pieces. That gave me the necessary jolt to overcome the inertia and I came up with a small screensaver kind of application.

I still call it rudimentary because it is nowhere near the original screensaver that triggered it but nevertheless, it was a good starting point for me.

FX ScreenSaver

In this application, I am rotating and zooming various geometric objects individually and as a group as well. In addition to that, I am also trying animate multiple rectangles on the screen which would show the contents of the desktop right below it. All the objects would zoom out and zoom in repeatedly.

Click on the image to launch it. You would need JDK5+. While the screensaver is running, click on it to alternate between 'Transforming individual objects' vs 'Transforming a group'. You will see the difference pretty clearly. Right click on the screensaver to exit.

FX ScreenSaver

 
This animation is using Pure FX animation loops. It was little hard to get the synchronization right for zoom in/zoom out. Zooming should reverse only when all the objects reach the min/Max possible size and I am also changing the rotation angle at the same time alongwith opacity.

Take a look at the script -

screensaver.fx

Clipping 

I have slightly modified the screensaver demo given above to set the clipping region to the union of 4 different shapes shown in the screenshot, keeping the background intact. FX provides Clip class to this. I have defined the 'shape' attribute of the Clip class to be the union of 4 different shapes. Additions, Intersections, Subtractions, Xor of shapes can be achieved through built-in subclasses of Area - Add, Subtract, Intersect and XOR. That's pretty straight-forwrd. However, I am not clear why the commented part of the code inside the Clip construct in the source is not working?!!. That should ideally do the same what the uncommented piece of code does.

(Click on the screenshot to launch the application. You would need jdk5+. Click the mouse to exit)

Screenshot

Source Script -

clipping.fx

I am going to take a small break (perhaps a week!) from FX to get back to Consumer JRE. Stay Tuned ...   

Comments:

I run it on a very fast XP box with dual core and 2GB of RAM.

It was pretty slow and choppy. Looks the FX language still needs some performance enhancements...

Posted by Jacek on August 23, 2007 at 05:33 PM IST #

Hi Jacek,

Thanks for trying it out. I don't think the sloppiness is due to FX and most likely it is because of the sampling rate that I use for changing the rotation and scaling parameters. I have modified it now in such a way that params are changed within a duration of 2000 ms instead of 7000 ms as coded earlier. Check if it is better now (make sure you clear the webstart cache). Typically the app can be fine-tuned further by altering the above duration in whichever way we want.

Posted by praveen on August 24, 2007 at 07:06 AM IST #

nice animation there praveen. but as mentioned earlier, the animation is choppy. Hope the FX compiler will fix it.

Posted by nataraj subramanian on August 24, 2007 at 07:48 PM IST #

Nice application ! But yes, its taking almost 126 MB of memory to run which sounds too much.

Hope FX will make it more cooler and lighter.

Posted by Vaibhav Choudhary on January 13, 2008 at 04:00 PM IST #

Nice work.

Is there a way to install it (or other JavaFX programs) as an actual screen saver on a windows machine?

Posted by Jeremy Pyman on March 06, 2008 at 02:37 AM IST #

Really, I got astonished actually .
That UR work is sooooooooooooooooooooo fine & superrrrrrrrrrrrrrrrrrrrrrrrr.
I need ur help &guidens .for my small project and java study.so please contact me via my e-mail address.

Posted by divya on September 29, 2008 at 09:56 AM IST #

hi..
Excellent work...

Posted by Codes on May 21, 2009 at 08:05 AM IST #

Good & congrats Praveen. I am trying to reach you.. mail me.

Posted by Krishna on June 10, 2009 at 08:36 PM IST #

Congrats da. Trying to reach you mail me asap

Posted by Krishna siptech on June 10, 2009 at 08:37 PM IST #

It was pretty slow and choppy. Looks the FX language still needs some performance enhancements...

Posted by Jacek on August 24, 2007 at 12:33 AM IST #

Hi Jacek,

Thanks for trying it out. I don't think the sloppiness is due to FX and most likely it is because of the sampling rate that I use for changing the rotation and scaling parameters. I have modified it now in such a way that params are changed within a duration of 2000 ms instead of 7000 ms as coded earlier. Check if it is better now (make sure you clear the webstart cache). Typically the app can be fine-tuned further by altering the above duration in whichever way we want.

Posted by praveen on August 24, 2007 at 02:06 PM IST #

nice animation there praveen. but as mentioned earlier, the animation is choppy. Hope the FX compiler will fix it.

Posted by nataraj subramanian on August 25, 2007 at 02:48 AM IST #

Nice application ! But yes, its taking almost 126 MB of memory to run which sounds too much.

Posted by abercrombie kids hoodie on September 15, 2010 at 09:26 AM IST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

mohanpraveen

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today