The Source for Java Technology Collaboration
User: Password:



Kirill Grouchnikov

Kirill Grouchnikov's Blog

SVG and Java UIs part 1: SVG-based resizable icons for next-generation UIs

Posted by kirillcool on August 30, 2006 at 12:01 AM | Comments (10)

The high-resolution LCD and plasma monitors are quickly becoming an affordable commodity, and the next versions of two major OSes (Vista and Leopard) will be using vector-based continuously-scalable icons and UI elements to create UIs that easily scale on 120+ DPI monitors. One of the vector-based formats quickly gaining popularity is SVG.

One of the flagship Microsoft's applications was and remains Office. Office 2007 introduces a new UI concept called ribbon which makes very heavy usage of scalable graphics to convery the same amount of information on different monitor sizes and application resizing. You can either read through Jensen's blog or find a short version right here. Giving the user the ability to scale the UI to his / her taste will be an invaluable feature, but it comes at a price for us, the developers. See this entry on Geertjan's blog to see the wrong way to scale icons.

This entry from about a year ago showed how to utilize Java2D to create scalable icons. However, this requires considerable design talent and time investment. What if you're short on one of them? SVG comes to the rescue. With continuous additions to the Tango project (thanks to Kohsuke for mentioning this project on his blog a few months back), and open-source libraries such as Apache Batik toolkit, the icon scalability can be easily achieved in modern Java UIs. The test application that comes with the flamingo components (see WebStart link at the end) uses the SVG Salamander renderer to turn SVG files into scalable icons. The choice between Batik and SVG Salamander in this particular case was in favor of the later, since it is much smaller and has less steep learning curve (although it has quite a few problems in rendering some of the Tango images).

Here are a few screenshots of the Ribbon UI under different application sizes. All the screenshots feature the same highlighted button, to that you will be able to see the same icon rendered in different sizes. The first image shows the UI when all the buttons are rendered at full size:

The second image shows the UI when some of the less important buttons use smaller icons but still show the labels:

The third image shows the UI when all buttons use smaller icons only due to the lack of screen space:

The final image shows the UI under extremely small width, where the entire band has been collapsed to a single button, which (when clicked) shows the original full-size buttons in a popup window:

Note that SVG supports transparency and translucency, allowing the icons to blend with different color backgrounds (note the circular shadow beneath the clock and the fuzzy yellow thingies in the top corners). Here are some screenshots of the same band under different color schemes (using Substance skins described here):





To launch the test application, click on the image below. You can play with the icon sizes by resizing the window. You can play with various themes / watermarks by going to the "Look & Feel" task.


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Hi,
    when i click on the webstart link,
    an error is raised saying that all jar resources are not signed with the same certificate.

    cheers,

    Charles.
    http://www.jguard.net

    Posted by: diabolo512 on August 30, 2006 at 01:33 AM

  • I get webstart error I havent seen before:
    java.net.MalformedURLException: unknown protocol: socket

    Posted by: benloud on August 30, 2006 at 02:33 AM

  • Although I experience the same WebStart issues as diabolo512, the shot alone look way cool!

    Posted by: herkules on August 30, 2006 at 04:12 AM

  • Webstart works great for me on Java 6 in Firefox. Great stuff!!

    Posted by: eldaaran on August 30, 2006 at 06:26 AM

  • I just updated all the jars to be unsigned - they shouldn't be in any case for this demo since it doesn't access anything local. Charles, Joerg - let me know if this works for you. This works for me under Java6 beta2 in Firefox 1.5.0.6.

    Posted by: kirillcool on August 30, 2006 at 08:35 AM

  • I can't get the app to launch.

    Here's the exception:

    java.lang.ClassCastException: java.lang.String cannot be cast to javax.swing.InputMap
    at javax.swing.plaf.basic.BasicComboBoxUI.getInputMap(Unknown Source)
    at javax.swing.plaf.basic.BasicComboBoxUI.installKeyboardActions(Unknown Source)
    at javax.swing.plaf.basic.BasicComboBoxUI.installUI(Unknown Source)
    at org.jvnet.substance.SubstanceComboBoxUI.__org__jvnet__substance__SubstanceComboBoxUI__installUI(SubstanceComboBoxUI.java)
    at org.jvnet.substance.SubstanceComboBoxUI.installUI(SubstanceComboBoxUI.java)
    at javax.swing.JComponent.setUI(Unknown Source)
    at javax.swing.JComboBox.setUI(Unknown Source)
    at javax.swing.JComboBox.updateUI(Unknown Source)
    at javax.swing.JComboBox.init(Unknown Source)
    at javax.swing.JComboBox.(Unknown Source)
    at test.ribbon.BasicCheckRibbon.getFontBand(BasicCheckRibbon.java:276)
    at test.ribbon.BasicCheckRibbon.configureRibbon(BasicCheckRibbon.java:710)
    at test.ribbon.NewCheckRibbon.configureRibbon(NewCheckRibbon.java:18)
    at test.ribbon.NewCheckRibbon.main(NewCheckRibbon.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.sun.javaws.Launcher.executeApplication(Unknown Source)
    at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
    at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
    at com.sun.javaws.Launcher.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

    Posted by: naikrovek on August 30, 2006 at 02:31 PM

  • naikrovek,
    This is a regression in b96 and b97 of Mustang. It has been reported and fixed and should appear in one of the next Mustang drops. If you want to run the demo, use either Tiger or Mustang beta 2.

    Posted by: kirillcool on August 30, 2006 at 02:35 PM

  • By the way, the link to that bug report is right here

    Posted by: kirillcool on August 30, 2006 at 02:39 PM

  • ah that worked, thank you. stupid me for not thinking to test another version.

    Posted by: naikrovek on August 30, 2006 at 08:33 PM

  • Hi,
    now it works for me.

    thanks!!

    Charles GAY.
    http://www.jguard.net

    Posted by: diabolo512 on September 01, 2006 at 02:26 AM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds