From: <fle...@us...> - 2007-02-24 02:27:56
|
Revision: 567 http://svn.sourceforge.net/magicmap/?rev=567&view=rev Author: flederohr Date: 2007-02-23 18:27:55 -0800 (Fri, 23 Feb 2007) Log Message: ----------- changed Handling of NodeIcons Added Paths: ----------- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/NodeIcons.java Added: trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/NodeIcons.java =================================================================== --- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/NodeIcons.java (rev 0) +++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/NodeIcons.java 2007-02-24 02:27:55 UTC (rev 567) @@ -0,0 +1,68 @@ + +package net.sf.magicmap.client.gui.utils; + +import java.awt.Color; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.Icon; + +import net.sf.magicmap.client.model.node.Node; + +import org.apache.log4j.Logger; + +/** + * @author Florian Lederer + */ +public class NodeIcons { + + private static NodeIcons ni = null; + + private static Logger log = Logger.getLogger(NodeIcons.class); + + private static final INodeIcon DEFAULT_ICON = new INodeIcon() { + + Icon defaultIcon = GUIBuilder.getToolIcon("default.png", + "NodeIcons"); + + public Color getBgColor(Node node){ + return Color.BLACK; + } + + public Color getFgColor(Node node){ + return Color.BLACK; + } + + public Icon getIcon(Node node){ + return defaultIcon; + } + + public Class getNodeClass(){ + return null; + } + + public int getNodeType(){ + return -1; + } + }; + + private final Map<Class, INodeIcon> iconMap = new HashMap<Class, INodeIcon>(); + + private NodeIcons() {} + + public static NodeIcons getInstance(){ + if (NodeIcons.ni == null) NodeIcons.ni = new NodeIcons(); + return NodeIcons.ni; + } + + public INodeIcon getNodeIcon(Node node){ + if (node == null) return null; + if (iconMap.containsKey(node.getClass())) return iconMap.get(node.getClass()); + return DEFAULT_ICON; + } + + public void registerNodeIcon(INodeIcon icon){ + iconMap.put(icon.getNodeClass(), icon); + } + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |