JFXStudio: sketch, hack, share

JFXtras Shelf Control

Posted by: steveonjava on: July 5, 2009

I was looking for a JavaFX display shelf control (similar to the iTunes cover flow) that I could use for some WidgetFX GUI improvements.  I couldn’t find anything that met my needs, so I rolled my own.  Some of the design goals included:

  • Extreme scalability – WidgetFX supports image lists of up to 10,000 in size (possibly more in the future), so performance had to be independent of list size.
  • Ultra-high performance – If your GUI is slow, users assume your whole application is slow, so this had to be tuned for maximum performance (and minimum resource usage).
  • Visual appeal – Let’s face it, this is an eye-candy control, so if the graphics, transitions, and effects are not breathtaking, it is a failure.

I put together a quick screencast of the finished product (this is the first of many screencasts I will be putting together, so let me know how I can improve it — better audio is already on my short list):

Keith was my co-conspirator on this project and you can thank for the fine selection of Anime images in the demo.

The Shelf control includes the following features:

  • Image Titles – Images can optionally have titles that are shown below them on the shelf.
  • ScrollBar – Quick navigation of the list via a scroll bar that can be enabled or disabled.
  • Reflection – Supports a reflection effect that can be enabled or disabled
  • Configurable aspect ratio – The aspect ratio of the images in the list can be set based on the type of images loaded. The default value is 1:1 (square).
  • Intelligent caching – Uses Soft References to cache images that are off-screen. This will save images up to available memory, and free the least recently used images on garbage collection.

You can find the full source code as well as a runnable web start demo on the JFXtras Samples project web site here:

JFXtras Shelf Control Demo

Speaking of JFXtras Samples, it is a new open repository of JavaFX samples targeted at teaching the language and APIs.  JFXtras Samples is designed to be complementary to blogs such as this, by providing a searchable archive with full source access.  Please join the community and post your samples by following the instructions here:

Guide to Uploading Samples

There are lots of little good nuggets in the Shelf implementation, such as rotation effects, image caching, and render cycle optimizations, so if there is interest, I will post a more detailed making-of-blog at steveonjava.com

7 Responses to "JFXtras Shelf Control"

[...] link: JFXtras Shelf Control « JFXStudio: sketch, hack, share [...]

Very nice. And performance is very very good as well.

Very impressive. One question, one suggestions:

Question: can it only do images or could one put any node in the areas?

Suggestion: load-ahead, try to load images at least 2 pages of images ahead. The loading-on-demand is technically great but cosmetically should be as less visible as possible.

@TBee I kept it to Images only, for simplicity of the API, and because it is not possible to get full event handling after a PerspectiveTransform is applied (limiting the usefulness of adding arbitrary Nodes).

A load-ahead setting is a great idea… I will make that a configuration option in the final version. The current setting is visible +/-1 load-ahead.

[...] of JFXtras, Stephen Chin has developed a ‘Shelf control’ (i.e. iTunes coverflow), which is now part of JFXtras. You can even watch a video which Stephen created to understand more about how the shelf control [...]

[...] XShelfView – A high performance Display Shelf control implementation with support for reflection, titles, and a scrollbar as showcased on JFXStudio. [...]

Leave a Reply

Challenge: Small is the New Big

This month's challenge: code something cool in only 30 lines, using the theme of Holiday. Ends December 15th.

Tags