com.mucommander.ui.icon
Class IconManager

java.lang.Object
  extended by com.mucommander.ui.icon.IconManager

public class IconManager
extends java.lang.Object

IconManager takes care of loading, caching, rescaling the icons contained inside the application's JAR file.

Author:
Maxence Bernard

Field Summary
static int ACTION_ICON_SET
          Designates the action icon set
static int COMMON_ICON_SET
          Designates the table icon set
static int FILE_ICON_SET
          Designates the file icon set
static int LANGUAGE_ICON_SET
          Designates the language icon set
static int PREFERENCES_ICON_SET
          Designates the preferences icon set
static int PROGRESS_ICON_SET
          Designates the progress icon set
static int STATUS_BAR_ICON_SET
          Designates the toolbar icon set
 
Method Summary
static javax.swing.ImageIcon getCompositeIcon(javax.swing.Icon backgroundIcon, javax.swing.Icon foregroundIcon)
          Returns a 'composite' icon made by composing the two given icons: the backgroundIcon is painted first, and the foregroundIcon is superposed, letting its non-transparent pixels reveal the background icon.
static javax.swing.ImageIcon getIcon(int iconSet, java.lang.String iconName)
          Convenience method, calls and returns the result of getIcon(iconSet, iconName, scaleFactor) with a scale factor of 1.0f (no rescaling).
static javax.swing.ImageIcon getIcon(int iconSet, java.lang.String iconName, float scaleFactor)
          Returns an icon in the specified icon set and with the given name.
static javax.swing.ImageIcon getIcon(java.lang.String iconPath)
          Convenience method, calls and returns the result of getIcon(iconPath, scaleFactor) with a scale factor of 1.0f (no rescaling).
static javax.swing.ImageIcon getIcon(java.lang.String iconPath, float scaleFactor)
          Creates and returns an ImageIcon instance using the specified icon path and scale factor.
static java.lang.String getIconSetFolder(int iconSet)
          Returns the path to the folder that contains the image resource files of the given icon set.
static javax.swing.ImageIcon getImageIcon(javax.swing.Icon icon)
          Creates and returns an ImageIcon with the same content and dimensions.
static javax.swing.ImageIcon getPaddedIcon(javax.swing.ImageIcon icon, java.awt.Insets insets)
          Returns an icon made of the specified icon and some transparent space around it.
static javax.swing.ImageIcon getScaledIcon(javax.swing.ImageIcon icon, float scaleFactor)
          Returns a scaled version of the given ImageIcon instance, using the specified scale factor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_ICON_SET

public static final int FILE_ICON_SET
Designates the file icon set

See Also:
Constant Field Values

ACTION_ICON_SET

public static final int ACTION_ICON_SET
Designates the action icon set

See Also:
Constant Field Values

STATUS_BAR_ICON_SET

public static final int STATUS_BAR_ICON_SET
Designates the toolbar icon set

See Also:
Constant Field Values

COMMON_ICON_SET

public static final int COMMON_ICON_SET
Designates the table icon set

See Also:
Constant Field Values

PREFERENCES_ICON_SET

public static final int PREFERENCES_ICON_SET
Designates the preferences icon set

See Also:
Constant Field Values

PROGRESS_ICON_SET

public static final int PROGRESS_ICON_SET
Designates the progress icon set

See Also:
Constant Field Values

LANGUAGE_ICON_SET

public static final int LANGUAGE_ICON_SET
Designates the language icon set

See Also:
Constant Field Values
Method Detail

getIcon

public static javax.swing.ImageIcon getIcon(java.lang.String iconPath,
                                            float scaleFactor)
Creates and returns an ImageIcon instance using the specified icon path and scale factor. No caching.

Parameters:
iconPath - path of the icon resource inside the application's JAR file
scaleFactor - the icon scale factor, 1.0f to have the icon in its original size (no rescaling)

getIcon

public static javax.swing.ImageIcon getIcon(java.lang.String iconPath)
Convenience method, calls and returns the result of getIcon(iconPath, scaleFactor) with a scale factor of 1.0f (no rescaling).


getScaledIcon

public static javax.swing.ImageIcon getScaledIcon(javax.swing.ImageIcon icon,
                                                  float scaleFactor)
Returns a scaled version of the given ImageIcon instance, using the specified scale factor.

Parameters:
icon - the icon to scale.
scaleFactor - the icon scale factor, 1.0f to have the icon in its original size (no rescaling)

getCompositeIcon

public static javax.swing.ImageIcon getCompositeIcon(javax.swing.Icon backgroundIcon,
                                                     javax.swing.Icon foregroundIcon)
Returns a 'composite' icon made by composing the two given icons: the backgroundIcon is painted first, and the foregroundIcon is superposed, letting its non-transparent pixels reveal the background icon. For this method to provide a meaningful result, the two icons should have the same dimensions and the foreground should have some transparent pixels.

Parameters:
backgroundIcon - the icon that is painted first
foregroundIcon - the icon that is superposed above backgroundIcon, should use transparency
Returns:
a 'composite' icon made by composing the two given icons

getIcon

public static javax.swing.ImageIcon getIcon(int iconSet,
                                            java.lang.String iconName,
                                            float scaleFactor)
Returns an icon in the specified icon set and with the given name. If a scale factor other than 1.0f is passed, the return icon will be scaled accordingly.

If the icon set has a cache, first looks for an existing instance in the cache, and if it couldn't be found, create an instance and store it in the cache for future access. Note that the cached icon is unscaled, i.e. the scaled icon is not cached.

Parameters:
iconSet - an icon set (see public constants for possible values)
iconName - filename of the icon to retrieve
scaleFactor - the icon scale factor, 1.0f to have the icon in its original size (no rescaling)
Returns:
an ImageIcon instance corresponding to the specified icon set, name and scale factor, null if the image wasn't found or couldn't be loaded

getIcon

public static javax.swing.ImageIcon getIcon(int iconSet,
                                            java.lang.String iconName)
Convenience method, calls and returns the result of getIcon(iconSet, iconName, scaleFactor) with a scale factor of 1.0f (no rescaling).


getPaddedIcon

public static javax.swing.ImageIcon getPaddedIcon(javax.swing.ImageIcon icon,
                                                  java.awt.Insets insets)
Returns an icon made of the specified icon and some transparent space around it.

Parameters:
icon - the original icon, will be painted at the center of the new icon
insets - specifies the dimensions of the transparent space around the returned icon
Returns:
an icon made of the specified icon and some transparent space around it

getImageIcon

public static javax.swing.ImageIcon getImageIcon(javax.swing.Icon icon)
Creates and returns an ImageIcon with the same content and dimensions. This method is useful when an ImageIcon is needed and only an Icon is available.

If the given Icon is already an ImageIcon, the same instance is returned. If it is not, a new ImageIcon is created and returned.


getIconSetFolder

public static java.lang.String getIconSetFolder(int iconSet)
Returns the path to the folder that contains the image resource files of the given icon set. The returned path is relative to the application JAR file's root and contains a trailing slash.

Parameters:
iconSet - an icon set (see public constants for possible values)


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard