Monday Nov 09, 2009

One of my previous post mentioned about way to specify Z-Order for JavaFX Nodes. Just thought of putting this approach to use in a carousel. There are lots of interesting samples available at shinedraw.com - Flash vs Silverlight Repository. Below is JavaFX port of FPS-Meter..



To launch click on above image or Click to add more images.

Note: The icons used in this sample are from MouseRunner.com licensed under the Attribution-ShareAlike 3.0 Unported.

I did some monitoring with JConsole. It was giving consistent 60 fps for 50 nodes with average 13% CPU usage. JConsole details available here. I'll leave it to experts to come up with proper conclusion...

Launch JavaFX FPS Meter. Start JConsole and select the process
- com.sun.javafx.runtime.Main javafxfpsmeter.Main -
from "Local Process" list.

System Information:

  • JavaFX: 1.2.1 (public)
  • JavaSE: 1.6.0_16
  • OS: Windows Vista
  • Processor: Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz
  • Memory (RAM): 1.00 GB
  • Display: NVIDIA Quadro NVS

There is significant performance improvement done in different components of JavaFX for next release.. Stay tuned.. I will share the statistics with exactly same test and same system so as to compare the improvement..

Please try it out and share your information and thoughts..


Friday Nov 06, 2009

Creating Resolution Independent UI - This is very tricky and complicated topic. The real solution will be to use layout. But sometimes (mostly?) you learn this the hard way!

I was preparing some demos for SiliconIndia Mobile Application Conference. I downloaded a bunch of samples from javafx.com - samples. Installed it on Sony Ericsson - X1. Cool! The demos launched successfully.. But...!!!

BrickBreaker sample as seen in mobile with [480 x 800] resolution..

Actual Scaled

Many of the nice samples are written for [240 x 320] (resolution of default JavaFX emulator skin). So they appear to be so small on [480 x 800] resolution phone. There is no straight forward way to fix all these samples in such short time (have to show it in conference!!). What next?

Hmm.. Just scale the root node so as to fit the screen. It doesn't look bad at all on mobile (above screenshot may not look good though)... Well this is not an attempt to provide a solution, but just to help you in case you end up in similar situation! Ofcourse the solution is still to avoid hard-coding of coordinates in the application.. This is just a gentle reminder..

Yes! The demos and presentation was successful.. But yeah.. sometimes you have to incorporate such workaround.. Hope you agree!! You may also be interested in new website - Josh On Design with topics related to UI design..

Diff of BrickBreaker Main.fx

Wednesday Oct 28, 2009

SiliconIndia brings the Mobile Application Conference to Bangalore, India

Come listen to some of the brightest minds in mobile technology discuss the future of mobile technology. They are gathering over 800 of the most interesting mobile developers, investors, executives, entrepreneurs, marketers, carriers, content developers and aggregators, advertisers and press for a day of in-depth discussion, debate and power networking.

Don't miss the opportunity to get hands-on with JavaFX! There will be sessions on JavaFX and demonstration of some nice applications.. Please visit the website for more information.

Last and the least.. an opportunity to interact with me in person!
Saturday, 31st October 2009 [ Bangalore, India ] See you there!

Tuesday Oct 27, 2009

Z-order is an ordering of overlapping two-dimensional objects, such as windows in a graphical user interface (GUI) or shapes in a vector graphics editor. One of the features of a typical GUI is that windows may overlap, so that one window hides part or all of another. When two windows overlap, their Z-order determines which one appears on top of the other. courtesy: wikipedia

JavaFX provides toFront() and toBack() methods in Node to change the Z-order. But users may want more control on how to order the nodes.


For Applet mode, click on above image

For standalone mode

In above sample, the Rectangles are stacked. The node is brought to top when user clicks on it. ActionScript provides DisplayObjectContainer.setChildIndex(child, index). Silverlight provides ZIndexProperty which can be set using SetValue method. Looks like its two different approach, one is done on Container and another on Node. So what is best way to address this in JavaFX? Here is an attempt...

In JavaFX, a sequence of Node is added to Group. So we could change the Z-order by sorting the sequence. This may be done using utility method - sort - available in javafx.util.Sequences.

The sort method is expecting an instance of java.lang.Comparable, for this we can create a CustomNode which implements Comparable and implement compareTo method. Also we can add an additional attribute zOrder. The comparison can be done based on this zOrder attribute. Please refer to NodeZ implementation for more information.

Now we can manipulate the Z-order by updating UI with node array returned by Sequences.sort(). The comparator may also be implemented based on various other attributes such as scale, translate, opacity etc. Yes, there may be some concern regarding updating of content in Group for every sort. What will be its implications? I need to perform some analysis on that, will try to share some info soon..

Try it out and let me know feedback and other options..


Monday Oct 26, 2009

I'm back from vacation.. Hmm.. well it was not this long though.. (my last post was more than a month back).. I traveled to few places, exploring new things.. You may view the some of the photos here!

Well was busy with many other things as well..
Oracle OpenWorld, Mobile Application Conference..

Anyway back to the topic.. Is it always good to compress the jar while deploying the Java/JavaFX application? What will be its impact on startup time? Or may be I was doing too much pack and unpack of luggage during vacation and hence the thought is still lingering in my mind?!

I think the answer depends on the application and target users. Pack helps to compress the jar file size (reduce download time). But it may increase the start-up time due to additional step - unpack. So if the application is too small, it may be better not to use compressed jar. Also if the target audience has very good bandwidth, then user may not see the benefit of reduced download time.

Applet - Pack Applet - No-Pack

Note: Above example is not the best to demonstrate any significant difference in warm start-up time

Also set update check to background in jnlp files as shown below.. Please refer to tech tip on start-up time for more information.

<update check="background"/>

JavaFX packager was generating jnlp files with missing / for close tag for applet-desc - param tag. Due to this any subsequent tags were getting ignored. So we need to ensure that all tags are properly closed. This issue with javafxpackager is resolved (not be available in 1.2)

<applet-desc ... >
     <param name="MainJavaFXScript" value="..." />
</applet-desc>

Best way to validate the jnlp is to launch the application and view the jnlp in Java Cache Viewer. Ensure that all entries are reflected properly. Update check must be set to "background" and not "timeout".

Well.. I never thought that one character (or lack of it) can contribute so much towards start-up time! Keep exploring!!

This blog copyright 2009 by Rakesh Menon