bibliothek.gui.dock.util.icon
Class DefaultIconScheme

java.lang.Object
  extended by bibliothek.gui.dock.util.AbstractUIScheme<Icon,DockIcon,DockIconBridge>
      extended by bibliothek.gui.dock.util.icon.AbstractIconScheme
          extended by bibliothek.gui.dock.util.icon.DefaultIconScheme
All Implemented Interfaces:
UIScheme<Icon,DockIcon,DockIconBridge>

public class DefaultIconScheme
extends AbstractIconScheme

This default implementation of an UIScheme for Icons reads an ini-file which consists of "key=icon-path" pairs, and loads all the icons described in that ini file when needed.

Author:
Benjamin Sigg

Nested Class Summary
static class DefaultIconScheme.IconResource
          A helper class describing a source for icons
 
Constructor Summary
DefaultIconScheme(DockController controller, DefaultIconScheme.IconResource... resources)
          Creates a new scheme loading icons from all the specified resources.
DefaultIconScheme(String file, ClassLoader loader, DockController controller)
          Creates a new scheme loading first the contents of the ini file file and then the icons that are found by analyzing the content of file.
If no file is found, then this scheme just remains empty.
DefaultIconScheme(String file, DockController controller)
          Creates a new scheme loading first the contents of the ini file file and then the icons that are found by analyzing the content of file.
If no file is found, then this scheme just remains empty.
 
Method Summary
protected  void changed(String id, Icon icon)
          Called if property accessed through a PropertyKey changed its value.
 DockIconBridge getBridge(Path name, UIProperties<Icon,DockIcon,DockIconBridge> properties)
          Creates the UIBridge that handles resources of type name.
 Icon getResource(String name, UIProperties<Icon,DockIcon,DockIconBridge> properties)
          Creates the resource with name name.
protected  void initHardcoded()
          Called by the constructor of this class, initializes some hard coded icons.
 void setBridge(Path type, DockIconBridge bridge)
          Sets the DockIconBridge with type type.
 void setIcon(String name, Icon icon)
          Changes the icon with name name to icon.
 
Methods inherited from class bibliothek.gui.dock.util.icon.AbstractIconScheme
install, link, uninstall, unlink
 
Methods inherited from class bibliothek.gui.dock.util.AbstractUIScheme
addListener, fire, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultIconScheme

public DefaultIconScheme(String file,
                         DockController controller)
Creates a new scheme loading first the contents of the ini file file and then the icons that are found by analyzing the content of file.
If no file is found, then this scheme just remains empty.

Parameters:
file - the file to read
controller - the DockController in whose realm this scheme will be used

DefaultIconScheme

public DefaultIconScheme(String file,
                         ClassLoader loader,
                         DockController controller)
Creates a new scheme loading first the contents of the ini file file and then the icons that are found by analyzing the content of file.
If no file is found, then this scheme just remains empty.

Parameters:
file - the file to read
loader - the ClassLoader whose ClassLoader.getResource(String) method will be used to load any files
controller - the DockController in whose realm this scheme will be used

DefaultIconScheme

public DefaultIconScheme(DockController controller,
                         DefaultIconScheme.IconResource... resources)
Creates a new scheme loading icons from all the specified resources.

Parameters:
controller - the DockController in whose realm this scheme will be used
resources - a list of files with "key=path" lines telling key and path of the icons to load. If a key appears more than once, then the last occurance of the key wins
Method Detail

initHardcoded

protected void initHardcoded()
Called by the constructor of this class, initializes some hard coded icons.


getBridge

public DockIconBridge getBridge(Path name,
                                UIProperties<Icon,DockIcon,DockIconBridge> properties)
Description copied from interface: UIScheme
Creates the UIBridge that handles resources of type name.

Parameters:
name - the name of the bridge
properties - the map that will use the resource
Returns:
the new bridge or null if this scheme does not know name

getResource

public Icon getResource(String name,
                        UIProperties<Icon,DockIcon,DockIconBridge> properties)
Description copied from interface: UIScheme
Creates the resource with name name. This method may be called often and should complete quickly.

Parameters:
name - the name of some resource
properties - the map that will use the resource
Returns:
the resource or null if this scheme does not know name

setIcon

public void setIcon(String name,
                    Icon icon)
Changes the icon with name name to icon. Please note that if name was linked, the newly set value may be overriden again.

Parameters:
name - the unique key of the icon
icon - the new icon, can be null

setBridge

public void setBridge(Path type,
                      DockIconBridge bridge)
Sets the DockIconBridge with type type.

Parameters:
type - the unique identifier of the type that should be handled by the new bridge
bridge - the new bridge or null

changed

protected void changed(String id,
                       Icon icon)
Description copied from class: AbstractIconScheme
Called if property accessed through a PropertyKey changed its value.

Specified by:
changed in class AbstractIconScheme
Parameters:
id - the identifier of the value that changed
icon - the new value, can be null