Filthy-Rich Clients – Talk Dirty to Me

Romain Guy, of Google, and Chet Hasse, of Sun, presented on their forth coming book Filthy Rich Clients which is based on a previous JavaOne technical session of the same name. They described this session as “the presentation based on the book based on the presentation.”

The session began with a slide listing Data Binding as a goal for the talk. Romain then said, “Data Binding is the most critical development of Swing today, but is it not here yet.” The next slide crossed out Data Binding and listed Applications Framework which is subsequently scratched out for ‘Cooler Applications.’

The ingredients, or agenda, for developing cooler applications according to these filthy rich engineers is based on graphics, performance, animation, and effects. Romain suggested that you override the paintComponent method instead of the paint method for custom components. Overriding the paint method may clobber some painting code that should really happen, like appropriately calling paintBorder, paintChildren, etc. The session titled Bring Life to Swing Desktop Applications talked about overriding the paint method.

For the performance portion of the talk, Romain was mostly concerned with the performance of scaling images, such as creating thumbnails, applying effects, etc. For these types of image operations quality and performance matter. Romain explain how there are simply to many options to scale images in Java. The best performing methods to scale an image down is to use the drawImage method using the default interpolation (NEAREST), the second best method is to use drawImage with BILINEAR, followed with BICUBIC.

Another common sense piece of advice offered here was to request repaints only for the area where the UI has changed, this is generally known as clipping. To repaint just what you need you can use the repaint(x, y, w, h) method on the component.

In regards to animating your Swing application, Romain and Chet recommend you use the Timing Framework from the SwingLabs for scheduling and running animations. The Timing framework has an Animator class that can run a instance of a TimingTarget which has the animating code.

For effects they recommend the blur, drop shadow, spring (ghost effect), morphing, and animated transitions. The SwingLabs has a GaussianBlurFilter, ShadowRenderer, Morphing2D class to achieve blurs, drop shadows, and morphings.

The idea of using animated transitions such as fading in and out is to lead your users, not leave them. Romain and Chet are working on an Animated Transitions project related to the book.

Technorati Tags: , , , , , ,


Leave a Reply