com.anthonyeden.lib.util
Class IconManager

java.lang.Object
  extended bycom.anthonyeden.lib.util.IconManager

public class IconManager
extends java.lang.Object

The IconManager provides a central location for loading and caching Icons loaded from the class loader as resources.

Author:
Anthony Eden

Constructor Summary
IconManager()
          Default constructor.
IconManager(java.lang.String basePath)
          Construct an IconManager with the given base path.
 
Method Summary
 java.lang.String getBasePath()
          Get the base path for finding icons.
static java.lang.String getDefaultBasePath()
          Get the default base path for loading icons.
 javax.swing.Icon getIcon(java.lang.String path)
          Get the icon at the given path.
protected static java.util.Map getIcons()
          Get a Map of all cached icons.
 void setBasePath(java.lang.String basePath)
          Set the base path for finding icons.
static void setDefaultBasePath(java.lang.String _defaultBasePath)
          Set the default base path for loading icons.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IconManager

public IconManager()
Default constructor. The base path will be set to the value returned from the getDefaultBasePath() method.


IconManager

public IconManager(java.lang.String basePath)
Construct an IconManager with the given base path.

Parameters:
basePath - The base path
Method Detail

getBasePath

public java.lang.String getBasePath()
Get the base path for finding icons. The base path should be a relative path with the '/' character as a separator.

Returns:
The base path

setBasePath

public void setBasePath(java.lang.String basePath)
Set the base path for finding icons. The base path should be a relative path with the '/' character as a separator.

Parameters:
basePath - The base path

getIcon

public javax.swing.Icon getIcon(java.lang.String path)
Get the icon at the given path. The path should point to a GIF in the class path. If no image is located at the given location, then this method returns null.

Returns:
An icon or null

getDefaultBasePath

public static java.lang.String getDefaultBasePath()
Get the default base path for loading icons. The value of defaultBasePath will be appended to the path argument of getIcon if the base path of the current IconManager instance is not set. By default the value is an empty String.

Returns:
The default base path

setDefaultBasePath

public static void setDefaultBasePath(java.lang.String _defaultBasePath)
Set the default base path for loading icons. The value of defaultBasePath will be appended to the path argument of getIcon if the base path of the current IconManager instance is not set. By default the value is an empty String.

Parameters:
_defaultBasePath - The default base path

getIcons

protected static java.util.Map getIcons()
Get a Map of all cached icons.

Returns:
The cached icon Map


Copyright (c) 2000-2003 Anthony Eden. All Rights Reserved.