com.dlsc.flexgantt.icons
Class AbstractIconMap

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<IconId,javax.swing.Icon>
          extended by com.dlsc.flexgantt.icons.AbstractIconMap
All Implemented Interfaces:
IIconMap, java.io.Serializable, java.lang.Cloneable, java.util.Map<IconId,javax.swing.Icon>
Direct Known Subclasses:
Gif16IconMap

public abstract class AbstractIconMap
extends java.util.HashMap<IconId,javax.swing.Icon>
implements IIconMap

An abstract implementation of the IIconMap interface that provides mechanisms to store, retrieve, and load icons.

Since:
1.0
Author:
Dirk Lemmermann
See Also:
Serialized Form

Constructor Summary
protected AbstractIconMap()
          Constructs a new icon map.
 
Method Summary
 javax.swing.Icon getIcon(IconId id)
          Returns the icon specified by the given ID.
protected  javax.swing.Icon loadIcon(java.lang.Class<? extends AbstractIconMap> iconMap, java.lang.String fileName)
          Loads the image with the given name from the package where the specified class is located.
 void setIcon(IconId id, javax.swing.Icon icon)
          Specifies a new icon for the given ID.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

AbstractIconMap

protected AbstractIconMap()
Constructs a new icon map.

Since:
1.0
Method Detail

getIcon

public javax.swing.Icon getIcon(IconId id)
Returns the icon specified by the given ID.

Specified by:
getIcon in interface IIconMap
Parameters:
id - the icon ID
Returns:
the icon that is mapped to the given ID
Since:
1.0

setIcon

public void setIcon(IconId id,
                    javax.swing.Icon icon)
Specifies a new icon for the given ID.

Specified by:
setIcon in interface IIconMap
Parameters:
id - the ID of the icon that will be replaced
icon - the new icon to use for the given ID
Since:
1.0

loadIcon

protected javax.swing.Icon loadIcon(java.lang.Class<? extends AbstractIconMap> iconMap,
                                    java.lang.String fileName)
Loads the image with the given name from the package where the specified class is located. Usually the icon map class and the icons managed by it are located in the same package.

Parameters:
iconMap - the class of the icon map implementation
fileName - the name of the icon file (e.g. Folder.gif)
Returns:
Icon the icon for the given file name
Since:
1.0