net.sf.doolin.gui.service.icon
Class AbstractIconService

java.lang.Object
  extended by net.sf.doolin.gui.service.icon.AbstractIconService
All Implemented Interfaces:
IconService
Direct Known Subclasses:
DefaultIconService

public abstract class AbstractIconService
extends Object
implements IconService

Icon manager that loads icon from a map of icon definitions.

Author:
Damien Coraboeuf

Nested Class Summary
protected static class AbstractIconService.IconItem
          Associations between icon sizes and actual icons.
 
Constructor Summary
AbstractIconService()
          Constructor.
 
Method Summary
 Icon getIcon(String id, IconSize size)
          Looks for the icon ata given size.
 Map<String,IconDefinition> getIconDefinitions()
          Gets the list of icon definitions
 URL getIconURL(String iconId, IconSize size)
          Returns the URL to an icon.
protected  void init()
          Initializes the manager.
protected  void load()
          This method actually initializes the icon manager.
protected abstract  Icon loadIconObject(String path)
          This method must be overriden by subclasses in order to load an icon from a path.
 void setIconDefinitions(Map<String,IconDefinition> iconDefinitions)
          Sets the list of icon definitions
protected abstract  URL toURL(String path)
          This method must be overriden by subclasses in order to return the URL to an icon defined by the given path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractIconService

public AbstractIconService()
Constructor. Registers the "icon:" protocol.

See Also:
URLUtils.registerURLStreamHandler(String, java.net.URLStreamHandler)
Method Detail

getIcon

public Icon getIcon(String id,
                    IconSize size)
Looks for the icon ata given size. If the icon is not found, a smaller icon is looked for.

Specified by:
getIcon in interface IconService
Parameters:
id - Icon id
size - Required icon size
Returns:
Icon

getIconDefinitions

public Map<String,IconDefinition> getIconDefinitions()
Gets the list of icon definitions

Returns:
List of icon definitions

getIconURL

public URL getIconURL(String iconId,
                      IconSize size)
Description copied from interface: IconService
Returns the URL to an icon.

Specified by:
getIconURL in interface IconService
Parameters:
iconId - Icon id
size - Required icon size
Returns:
URL to the icon

init

protected void init()
Initializes the manager. This is a lazy initialization.

See Also:
load()

load

protected void load()
This method actually initializes the icon manager.


loadIconObject

protected abstract Icon loadIconObject(String path)
This method must be overriden by subclasses in order to load an icon from a path.

Parameters:
path - Path to the icon (could be a resource path but could be something else according to the icon manager implementation).
Returns:
Icon

setIconDefinitions

public void setIconDefinitions(Map<String,IconDefinition> iconDefinitions)
Sets the list of icon definitions

Parameters:
iconDefinitions - List of icon definitions

toURL

protected abstract URL toURL(String path)
This method must be overriden by subclasses in order to return the URL to an icon defined by the given path.

Parameters:
path - Path to the icon (could be a resource path but could be something else according to the icon manager implementation).
Returns:
Icon URL


Copyright © 2011. All Rights Reserved.