Skip to main content

[PROPOSAL] Icon Packs

8 replies [Last post]
nicolaken
Offline
Joined: 2003-06-11

Hi everyone, I'm back with a humble proposal that I'd like to work on.

When I create a Swing app, I know sure that different look and feels can be applied to it... except for the icons.

Putting icons in Swing apps is a PITA, and there is no possibility of switching icon packs, so that a Windows L&F and a Metal L&F will get the same application icons, making only one L&F not look crappy.

Overmore developers have to write and translate all the corrisponding labels and accelerator keys, each on their own.

Java has an icon repository, but it has only metal icons, and no automatic way I know of getting labels and mnemonics:

http://java.sun.com/developer/techDocs/hi/repository/

A proposed solution would be to have Icon Packs, that contain icons to be used with the most common look and feels, with their corresponding labels and mnemonics translated in different languages.

To make it work, a standard naming has to be sought out, or simply copied from:
http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-lates...

In this way, SwingX would have icons for all the standard ones, and the extra icons for an app would simply be put in an extra Icon Pack.

Comments, suggestions, etc?

--
nicolaken

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
evickroy
Offline
Joined: 2004-07-23

Wouldn't this tie in with JIC in some way? It seems that there was a suggestion about icon sets and such being added to JIC. Maybe a new JIC sub-project under Swinglabs that encompasses the JIC classes from the incubator and this proposal for Icon Packs? Here was some infor on JIC: http://weblogs.java.net/blog/rbair/archive/2005/10/jic_java_icon_f.html

Erik

rbair
Offline
Joined: 2003-07-08

Hey Erik,

In my mind they are separate, but could be used together. JIC is more a multi-resolution icon file format and IconPack is an API for loading/providing icons based on a LAF/locale/theme.

Richard

dan@ikayzo.com

> In my mind they are separate, but could be used together. JIC is more a
> multi-resolution icon file format and IconPack is an API for
> loading/providing icons based on a LAF/locale/theme.

Agreed. I think they could be used together. JIC also provides some
utilities that could be useful for implementing the IconPack idea.

I still need to finish vector icon support. If only we lived on a larger
planet with longer days...

Dan

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

nicolaken
Offline
Joined: 2003-06-11

Very good point, [b]themes[/b] are important as well.

As for the programmatically created icons, would not SVG icons be good enough (IIRC the blog posts on it were about resizability)?

I have tried Substance but I am not familiar with the code.
Could you kindly point me where to look in the code at for programmatic icon creation and switching for themes?

TIA

kirillcool
Offline
Joined: 2004-11-17

See [1] that contains (almost) all Java2D image-creation functions. There's a lot of functions there for the UIManager icons, such as getTreeIcon(), getTreeNodeIcon(), getTreeLeafIcon() - for trees, getHomeIcon(), getComputerIcon(), ... - for file chooser, getQuestionMarker(), getErrorMarker(), getWarningMarker(), ... - for option panes etc.

These functions are called in the SubstanceTheme.addCustomEntriesToTable function [2] using lazy initialization.

Kirill

[1] https://substance.dev.java.net/source/browse/substance/src/org/jvnet/sub...
[2] https://substance.dev.java.net/source/browse/substance/src/org/jvnet/sub...

kirillcool
Offline
Joined: 2004-11-17

In Substance LAF [1] all icons (except third-party contributions from Quaqua) are created programmatically using Java2D. Although this precludes shipping LAF with professionally designed icons, it allows chaging icons on theme change. As Substance comes with 40+ color themes, some of them very bright, some of them very dark, it's a must to have icons that match the current theme. How do you propose to handle this aspect?

[1] https://substance.dev.java.net

rbair
Offline
Joined: 2003-07-08

Hey Nicola

> Putting icons in Swing apps is a PITA, and there is
> no possibility of switching icon packs, so that a
> Windows L&F and a Metal L&F will get the same
> application icons, making only one L&F not look
> crappy.

Yep

> Overmore developers have to write and translate all
> the corrisponding labels and accelerator keys, each
> on their own.

Yep

> A proposed solution would be to have Icon Packs, that
> contain icons to be used with the most common look
> and feels, with their corresponding labels and
> mnemonics translated in different languages.

Cool.

> To make it work, a standard naming has to be sought
> out, or simply copied from:
>
> http://standards.freedesktop.org/icon-naming-spec/ico
> n-naming-spec-latest.html
>
> In this way, SwingX would have icons for all the
> standard ones, and the extra icons for an app would
> simply be put in an extra Icon Pack.
>
> Comments, suggestions, etc?

Sounds like an excellent project, and something that is sorely needed. You're right, I've always just picked one set of icons and hoped for the best (I love http://www.iconexperience.com/index.php, by the way). But for a truly professional look it would be nice to have a different set (or perhaps just a few different icons) depending on the look and feel, and the locale.

Some basic requirements could be:
* Change icons per LAF & locale
* Work with any image format (png, svg, etc)
* Minimal new API

If it were me, I'd try to stash the actual Icon object in the UIManager, and then provide a simple API for loading a different IconPack, removing IconPacks, inspect which IconPacks have been installed, and retrieving Icons for specific keys.

I think the freedesktop naming standards are a great way to go. In addition to following an established standard, it means we have a ready supply of icon packs to use right away.

So, here's one suggestion on how to implement this:

* Use UIDefaults for the current LAF to store the icons
- UIDefaults has a getIcon(String key, Locale l)
method. This will first look for an Icon that
has been previously defined. If not found, it
will check whatever ResourceBundles have been
registered via addResourceBundle
* Define a new ResourceBundle subclass that loads
the correct Icon based on the given key and locale
- Perhaps this is what you would call IconPack
- Could be subclassed to load icons differently.
For example, you might have a subclass that reads
tgz files to load icons from a Gnome/KDE archive.
Or, a subclass to load icons using the JIC format
in the incubator
* Define a IconPacks static factory class for
retreiving an Icon.
- This should have an enum stating all of the
common Icon keys (like those found in the
freedesktop.org document you linked to). Of
course, folks can use custom Icon keys as well.
- Has static methods for getting an Icon, loading
and IconPack, removing an IconPack, etc

Anyway, just some ideas of the direction I'd probably take with this. Looking forward to the direction you take this. Can't wait to see the demos ;-)

Cheers
Richard

sse
Offline
Joined: 2006-01-16

It seems to go towards app versatility and ease of configuration.

So, +1 for that !