The demo applications for the Flamingo JRibbon component make heavy use of the SVG icons to make sure that the icons can be scaled without losing visual details. While Flamingo provides Batik-based implementation of the ResizableIcon interface, this has proven to place a noticeable burden on CPU during the application startup phase. One of the ways to address this performance issue is to use the SVG-Java2D transcoder that is part of Flamingo core distribution.

There’s nothing like eating your own dog food, and while trying to use the transcoded Java2D class to replace the runtime SVG decoding i found that it was lacking some of the basic functionality. The most glaring one was lack of API to query the default bounds of the SVG image. This is now exposed in the Java2D class with two static methods – getOrigWidth and getOrigHeight.

The second enhancement to the org.jvnet.flamingo.svg.SvgTranscoder class is the new setJavaToImplementResizableIconInterface(boolean) method. If you call this method prior to calling the transcode(), the resulting class will implement the org.jvnet.flamingo.common.icon.ResizableIcon interface, making it ready to be used instead of the org.jvnet.flamingo.svg.SvgBatikResizableIcon class. This comes handy since the heavy transcoding is done offline, and the size of the compiled class is comparable with the size of the compressed SVG file (especially if you turn the debugging info off). You can see the difference yourself by running the ribbon demo below – once the application frame is shown, all the icons are immediately visible and you can start interacting with it.

To change the package name of the generated Java2D class, call the setJavaPackageName(String) method prior to transcode() call. The last addition is the sample test.svg.SvgBatchConverter class that shows how to run the SVG-Java2D conversion in batch mode on all SVG files in a given folder.

Using the offline transcoding has another advantage – you don’t need to bundle the Batik jars that are around 3-4MB heavy. One point left to your consideration is the issue of the license of the original SVG images and its implications on the transcoded Java2D classes.

Here are some Swing links that you might have missed during this week:

  • Bruce Eckel wonders if anyone really cares about desktop Java, and the responses are mixed. Any established technology has its shortcomings, and it would be short-sighted to assume that the same question will not be asked in five-ten years about Flex. In the meantime, those have have invested in learning Swing produce good-looking and responsive applications.
  • Karl Tauber has announced release 4.0 of the JFormDesigner tool for designing Swing user interfaces. New in this version are support for GroupLayout, FormLayout 1.2, improved conversion of IntelliJ forms and more.
  • JavaPosse has talked about multi-threading in UI toolkits, and there’s a follow-up discussion on this subject in the Google group of the show.
  • Eskil Blomfeldt reports that Qt Jambi AWT bridge has been rewritten to provide better support for window activation and whitespace around embedded components. It sounds that this project faces much the same issues as Albireo (that aims to provide the bridge between Swing and SWT). The Qt Jambi AWT bridge has still some unresolved issues with keyboard focus – something that has been addressed in Albireo.
  • Alex Ruiz has announced the first beta for release 1.0 of FEST Swing, a library that provides a fluent interface for functional Swing UI testing.
  • JavaSwing.net has a number of useful tutorials on using the JTextField and related classes, including the introduction to DocumentFilter to enforce upper limit on the number of characters, auto-conversion to upper case, number-only content and e-mail content. For more background on using regular expressions in e-mail verification see this article.
  • Clemens Eisserer has committed the first changeset for the XRender pipeline under the OpenJDK innovators’ challenge program.
  • And finally, Alexander Potochkin writes about the internal implementation of JXLayer‘s event interception on subcomponents in a non-intrusive manner using the InputContext class.

Here are some Swing links that you might have missed during this week:

  • Clemens Eisserer continues working on the XRender pipeline for Java2D, and has a few screenshots showing the progress of this project. Part 1, part 2 and part 3 show different test applications under this pipeline.
  • A message from Richard Bair on the mailing list of AppFramework (reference implementation of JSR 296) announces that Alex Potochkin has taken over the ownership of this project. The time indeed has arrived – the last source commit was in October 2007, and while Alex hasn’t posted any message on the mailing list / his blog, i would assume that he is taking his time making himself familiar with the project itself and the JCP / JSR process in general.
  • Alex himself continues writing about the JXLayer project and talks about the internal painting implementation in his latest entry. Jing Ge has a follow up entry in which he builds a complete validation module using BeansBinding, JXLayer and Hibernate Validator.
  • Xavier Young has a short introduction for using the EaSynth look-and-feel.
  • Ethan Nicholas introduces the JavaCSS project that aims to provide CSS support for styling Swing and JavaFX components. While the amount of comments on this entry indicates a significant level of interest in this project, it would be interesting to see how well will it be able to cope with the expectations implied by using the “CSS” in its name. As mentioned by Ben Galbraith in his JavaOne 2006 session, Swing and HTML are sufficiently different in that you can not take the existing “pure” CSS directives and apply them on Swing components. In addition, implementing the layout constructs of CSS may require changing the existing application layout managers. Throw the look-and-feel layer into the mix (don’t forget that the look-and-feel is responsible for computing the inner metrics of Swing components, such as margings, padding, gaps, etc), and you get quite an interesting challenge.
  • Ken Orr writes about unified toolbar buttons in his quest to emulate the appearance of native Mac applications. Surprisingly, this entry features a rather questionable advice on using the SwingUtilities2 class. Not sure about the Apple VM, but this is a strict no-no for even Sun VMs. Not only this class is in an internal sun package, it has also changed location between JDK 5.0 and JDK 6.0. What’s the alternative for SwingUtilities2.drawStringUnderlineCharAt? Call BasicGraphicsUtils.drawStringUnderlineCharAt and install the desktop rendering hints before that.
  • This is most probably will be a part of the next weekly JDK 7 build. Bug 6725214 on forward-porting the new D3D rendering pipeline from 6u10 has been marked as Fix delivered. For the brave souls wishing to venture into the implementation details, follow this Mercurial changeset. No word yet on porting the support for shaped and translucent windows and which package that might end up in.
  • Jacek Furmankiewicz continues working on the Java SwingBuilder project, and this time he writes about adding an SWT-style API for creating menus.
  • And finally, Richard Kennard adds component wiring based on Commons JEXL to his MetaWidget project, aiming at those environments that don’t have expression languages built into the language (such as Swing).

Here are some Swing links that you might have missed during this week:

  • James Williams has a tongue-in-cheek list of five tips to tame Matisse layouts. This resonates with my earlier post on JBuilder and getting locked to an IDE that enforces any non-standard logic on the UI code that it creates.
  • Luan O’Carroll writes about distributing a WebStart application via CD-ROM, expanding on such subjects as WebStart cache, not relying on existing JRE installations, working with no Internet connection and others.
  • Build 27 of 6u10 is out and it addresses the issue that prevented applications from using the Synthetica look-and-feel. It also features performance improvements for Nimbus (about 8% as measured in the dynamic performance suite from the LightBeam project). Although not official, we can expect the release candidate of 6u10 this week.
  • Ken Orr writes about a custom implementation of placard button commonly found in Mac applications.
  • Alexander Potochkin introduces yet another useful feature of his JXLayer project – ability to lock (disable) the entire Swing container, including blocking any user interaction with its children.
  • The “Ask the Experts” session on 6u10 is over, and (much like two years ago), i had a question that was not addressed. I will be polite and blame the intratubes, but the topic at hand will be a subject of a forthcoming entry.