|
From: <fle...@us...> - 2008-02-04 16:59:42
|
Revision: 729
http://magicmap.svn.sourceforge.net/magicmap/?rev=729&view=rev
Author: flederohr
Date: 2008-02-04 07:22:07 -0800 (Mon, 04 Feb 2008)
Log Message:
-----------
Introduced new icon-concept
Modified Paths:
--------------
trunk/magicmapclient/src/net/sf/magicmap/client/gui/MainGUI.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/MapView.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/OutlineTree.java
Added Paths:
-----------
trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/
trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/AccessPointNodeIcon.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/ClientNodeIcon.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/GeoPosNodeIcon.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/LocationNodeIcon.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/MapNodeIcon.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/
trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/AbstractNodeIcon.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/INodeIcon.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconAndPredicate.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconContainer.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconNotPredicate.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconOrPredicate.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconPredicate.java
Removed Paths:
-------------
trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/AccessPointNodeIcon.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/ClientNodeIcon.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/GeoPosNodeIcon.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/INodeIcon.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/LocationNodeIcon.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/MapNodeIcon.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/NodeIcons.java
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/gui/MainGUI.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/MainGUI.java 2008-02-01 13:41:00 UTC (rev 728)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/MainGUI.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -1,6 +1,5 @@
/*
- * Created on 21.11.2004
- * Refactored on 15.02.2006
+ * Created on 21.11.2004 Refactored on 15.02.2006
*/
package net.sf.magicmap.client.gui;
@@ -11,17 +10,19 @@
import javax.swing.JComponent;
-import net.sf.magicmap.client.gui.utils.AccessPointNodeIcon;
-import net.sf.magicmap.client.gui.utils.ClientNodeIcon;
-import net.sf.magicmap.client.gui.utils.GeoPosNodeIcon;
-import net.sf.magicmap.client.gui.utils.LocationNodeIcon;
-import net.sf.magicmap.client.gui.utils.MapNodeIcon;
-import net.sf.magicmap.client.gui.utils.NodeIcons;
+import net.sf.magicmap.client.gui.icons.AccessPointNodeIcon;
+import net.sf.magicmap.client.gui.icons.ClientNodeIcon;
+import net.sf.magicmap.client.gui.icons.GeoPosNodeIcon;
+import net.sf.magicmap.client.gui.icons.LocationNodeIcon;
+import net.sf.magicmap.client.gui.icons.MapNodeIcon;
+import net.sf.magicmap.client.gui.utils.icon.NodeIconContainer;
import net.sf.magicmap.client.model.node.INodeSelectionModel;
+import net.sf.magicmap.client.model.node.NodeModelConstants;
import net.sf.magicmap.client.model.node.NodeSelectionModel;
/**
* The main GUI window
+ *
* @author thuebner
* @author Florian Lederer
*/
@@ -34,6 +35,7 @@
/**
* Getter for the singleton instance of the main GUI
+ *
* @return the main GUI (creates a new one if none exists)
*/
public static MainGUI getInstance(){
@@ -41,31 +43,30 @@
return MainGUI.mainGUI;
}
- private Map<String, JComponent> jComponentMap = new HashMap<String, JComponent>();
+ private Map<String, JComponent> jComponentMap = new HashMap<String, JComponent>();
private INodeSelectionModel nodeSelectionModel;
- private NodeIcons nodeIcons;
+ private NodeIconContainer nodeIconContainer;
private MainFrame mainFrame;
+ public static final String VIEW_KEY_MAP_VIEW = "mapView";
+ public static final String VIEW_KEY_MAP_PANEL = "mapPanel";
- public static final String VIEW_KEY_MAP_VIEW = "mapView";
- public static final String VIEW_KEY_MAP_PANEL = "mapPanel";
-
/**
- * Erzeugt Hauptfenster der Anwendung.
- * Private constructor, only used by getInstance() to fulfill singleton pattern
+ * Erzeugt Hauptfenster der Anwendung. Private constructor, only used by
+ * getInstance() to fulfill singleton pattern
*/
private MainGUI() {
// NodeSelectionModel
nodeSelectionModel = new NodeSelectionModel();
- // NodeIcons
- nodeIcons = NodeIcons.getInstance();
- nodeIcons.registerNodeIcon(new ClientNodeIcon());
- nodeIcons.registerNodeIcon(new AccessPointNodeIcon());
- nodeIcons.registerNodeIcon(new LocationNodeIcon());
- nodeIcons.registerNodeIcon(new GeoPosNodeIcon());
- nodeIcons.registerNodeIcon(new MapNodeIcon());
+ // NodeIconContainer
+ nodeIconContainer = NodeIconContainer.getInstance();
+ nodeIconContainer.registerNodeIcon(NodeModelConstants.NODETYPE_CLIENT, new ClientNodeIcon());
+ nodeIconContainer.registerNodeIcon(NodeModelConstants.NODETYPE_ACCESSPOINT, new AccessPointNodeIcon());
+ nodeIconContainer.registerNodeIcon(NodeModelConstants.NODETYPE_LOCATION, new LocationNodeIcon());
+ nodeIconContainer.registerNodeIcon(NodeModelConstants.NODETYPE_GEOPOS, new GeoPosNodeIcon());
+ nodeIconContainer.registerNodeIcon(NodeModelConstants.NODETYPE_MAP, new MapNodeIcon());
}
/**
@@ -95,7 +96,7 @@
return nodeSelectionModel;
}
- public NodeIcons getNodeIcons(){
- return nodeIcons;
+ public NodeIconContainer getNodeIconContainer(){
+ return nodeIconContainer;
}
}
Copied: trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/AccessPointNodeIcon.java (from rev 726, trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/AccessPointNodeIcon.java)
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/AccessPointNodeIcon.java (rev 0)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/AccessPointNodeIcon.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -0,0 +1,108 @@
+
+package net.sf.magicmap.client.gui.icons;
+
+import java.awt.Color;
+
+import net.sf.magicmap.client.gui.utils.GUIBuilder;
+import net.sf.magicmap.client.gui.utils.icon.AbstractNodeIcon;
+import net.sf.magicmap.client.gui.utils.icon.NodeIconAndPredicate;
+import net.sf.magicmap.client.gui.utils.icon.NodeIconPredicate;
+import net.sf.magicmap.client.model.node.AccessPointNode;
+import net.sf.magicmap.client.model.node.Node;
+
+/**
+ * @author Florian Lederer
+ */
+public class AccessPointNodeIcon extends AbstractNodeIcon {
+
+ private final NodeIconPredicate apIsHiddenPredicate = new NodeIconPredicate() {
+
+ public boolean showIcon(Node node){
+ return ((AccessPointNode) node).isHidden();
+ };
+ };
+
+ private final NodeIconPredicate apIsFixPredicate = new NodeIconPredicate() {
+
+ public boolean showIcon(Node node){
+ return ((AccessPointNode) node).isFix();
+ };
+ };
+
+ private final NodeIconPredicate apIsHiddenAndFixPredicate = new NodeIconAndPredicate(apIsHiddenPredicate,
+ apIsFixPredicate);
+
+ public AccessPointNodeIcon() {
+ super();
+
+ try {
+
+ addBackgroundIcon(GUIBuilder.getToolIcon("accesspoint.png", "NodeIcons"), NodeIconPredicate.TRUE);
+ addBackgroundIcon(GUIBuilder.getToolIcon("accesspoint_hidden.png", "NodeIcons"), apIsHiddenPredicate);
+
+ addOverlayIcon(GUIBuilder.getToolIcon("anchor_white.png", "NodeIcons"), apIsFixPredicate);
+ addOverlayIcon(GUIBuilder.getToolIcon("anchor_black.png", "NodeIcons"), apIsHiddenAndFixPredicate);
+
+ } catch (SecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ //
+ // ImageIcon accessPoint;
+ // ImageIcon accessPointFixed;
+ // ImageIcon accessPointHidden;
+ // ImageIcon accessPointHiddenFixed;
+ //
+ // private ImageIcon getAccessPoint(){
+ // if (accessPoint == null) accessPoint = GUIBuilder.getToolIcon("accesspoint.png", "NodeIconContainer");
+ // return accessPoint;
+ // }
+ //
+ // private ImageIcon getAccessPointFixed(){
+ // if (accessPointFixed == null) {
+ // final ImageIcon anchor = GUIBuilder.getToolIcon("anchor_white.png", "NodeIconContainer");
+ // accessPointFixed = new ImageIcon(getAccessPoint().getImage()) {
+ //
+ // @Override
+ // public synchronized void paintIcon(Component c, Graphics g, int x, int y){
+ // super.paintIcon(c, g, x, y);
+ // g.drawImage(anchor.getImage(), x, y, x + getIconWidth(), y + getIconHeight(), 0, 0, anchor
+ // .getIconWidth(), anchor.getIconHeight(), null);
+ // }
+ // };
+ // }
+ // return accessPointFixed;
+ // }
+ //
+ // private ImageIcon getAccessPointHidden(){
+ // if (accessPointHidden == null)
+ // accessPointHidden = GUIBuilder.getToolIcon("accesspoint_hidden.png", "NodeIconContainer");
+ // return accessPointHidden;
+ // }
+ //
+ // private ImageIcon getAccessPointHiddenFixed(){
+ // if (accessPointHiddenFixed == null) {
+ // final ImageIcon anchor = GUIBuilder.getToolIcon("anchor_black.png", "NodeIconContainer");
+ // accessPointHiddenFixed = new ImageIcon(getAccessPointHidden().getImage()) {
+ //
+ // @Override
+ // public synchronized void paintIcon(Component c, Graphics g, int x, int y){
+ // super.paintIcon(c, g, x, y);
+ // g.drawImage(anchor.getImage(), x, y, x + getIconWidth(), y + getIconHeight(), 0, 0, anchor
+ // .getIconWidth(), anchor.getIconHeight(), null);
+ // }
+ // };
+ // }
+ // return accessPointHiddenFixed;
+ // }
+
+ public Color getBgColor(Node node){
+ return Color.RED;
+ }
+
+ public Color getFgColor(Node node){
+ return Color.BLACK;
+ }
+}
Copied: trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/ClientNodeIcon.java (from rev 726, trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/ClientNodeIcon.java)
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/ClientNodeIcon.java (rev 0)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/ClientNodeIcon.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -0,0 +1,42 @@
+
+package net.sf.magicmap.client.gui.icons;
+
+import java.awt.Color;
+
+import net.sf.magicmap.client.gui.utils.GUIBuilder;
+import net.sf.magicmap.client.gui.utils.icon.AbstractNodeIcon;
+import net.sf.magicmap.client.gui.utils.icon.NodeIconPredicate;
+import net.sf.magicmap.client.model.node.Node;
+
+/**
+ * @author Florian Lederer
+ */
+public class ClientNodeIcon extends AbstractNodeIcon {
+
+ private final NodeIconPredicate clientIsFixPredicate = new NodeIconPredicate() {
+
+ public boolean showIcon(Node node){
+ return node.isFix();
+ }
+ };
+
+ public ClientNodeIcon() {
+ super();
+ try {
+ addBackgroundIcon(GUIBuilder.getToolIcon("client.png", "NodeIcons"), NodeIconPredicate.TRUE);
+ addOverlayIcon(GUIBuilder.getToolIcon("anchor_black.png", "NodeIcons"), clientIsFixPredicate);
+ } catch (SecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public Color getBgColor(Node node){
+ return Color.GREEN;
+ }
+
+ public Color getFgColor(Node node){
+ return Color.BLACK;
+ }
+
+}
Copied: trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/GeoPosNodeIcon.java (from rev 726, trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/GeoPosNodeIcon.java)
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/GeoPosNodeIcon.java (rev 0)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/GeoPosNodeIcon.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -0,0 +1,31 @@
+
+package net.sf.magicmap.client.gui.icons;
+
+import java.awt.Color;
+
+import net.sf.magicmap.client.gui.utils.GUIBuilder;
+import net.sf.magicmap.client.gui.utils.icon.AbstractNodeIcon;
+import net.sf.magicmap.client.gui.utils.icon.NodeIconPredicate;
+import net.sf.magicmap.client.model.node.Node;
+
+/**
+ * @author Florian Lederer
+ */
+public class GeoPosNodeIcon extends AbstractNodeIcon {
+
+ // if (geoPos == null) geoPos = GUIBuilder.getToolIcon("geopos.png", "NodeIconContainer");
+ // if (geoPosBig == null) geoPosBig = GUIBuilder.getToolIcon("geopos_big.png", "NodeIconContainer");
+
+ public GeoPosNodeIcon() {
+ super();
+ addBackgroundIcon(GUIBuilder.getToolIcon("geopos.png", "NodeIcons"), NodeIconPredicate.TRUE);
+ }
+
+ public Color getBgColor(Node node){
+ return Color.YELLOW;
+ }
+
+ public Color getFgColor(Node node){
+ return Color.BLACK;
+ }
+}
Copied: trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/LocationNodeIcon.java (from rev 726, trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/LocationNodeIcon.java)
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/LocationNodeIcon.java (rev 0)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/LocationNodeIcon.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -0,0 +1,44 @@
+
+package net.sf.magicmap.client.gui.icons;
+
+import java.awt.Color;
+
+import net.sf.magicmap.client.gui.utils.GUIBuilder;
+import net.sf.magicmap.client.gui.utils.icon.AbstractNodeIcon;
+import net.sf.magicmap.client.gui.utils.icon.NodeIconPredicate;
+import net.sf.magicmap.client.model.node.LocationNode;
+import net.sf.magicmap.client.model.node.Node;
+
+/**
+ * @author Florian Lederer
+ */
+public class LocationNodeIcon extends AbstractNodeIcon {
+
+ private NodeIconPredicate locationUpdateIconPredicate = new NodeIconPredicate() {
+
+ public boolean showIcon(Node node){
+ return ((LocationNode) node).isUpdate();
+ }
+ };
+
+ public LocationNodeIcon() {
+ super();
+ try {
+ addBackgroundIcon(GUIBuilder.getToolIcon("location.png", "NodeIcons"), NodeIconPredicate.TRUE);
+ addBackgroundIcon(GUIBuilder.getToolIcon("location_rescan.png", "NodeIcons"), locationUpdateIconPredicate);
+ } catch (SecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public Color getBgColor(Node node){
+ return Color.BLUE;
+ }
+
+ @Override
+ public Color getFgColor(Node node){
+ return Color.BLACK;
+ }
+}
Copied: trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/MapNodeIcon.java (from rev 726, trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/MapNodeIcon.java)
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/MapNodeIcon.java (rev 0)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/icons/MapNodeIcon.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -0,0 +1,30 @@
+
+package net.sf.magicmap.client.gui.icons;
+
+import java.awt.Color;
+
+import net.sf.magicmap.client.gui.utils.GUIBuilder;
+import net.sf.magicmap.client.gui.utils.icon.AbstractNodeIcon;
+import net.sf.magicmap.client.gui.utils.icon.NodeIconPredicate;
+import net.sf.magicmap.client.model.node.Node;
+
+/**
+ * @author Florian Lederer
+ */
+public class MapNodeIcon extends AbstractNodeIcon {
+
+ public MapNodeIcon() {
+ super();
+ addBackgroundIcon(GUIBuilder.getToolIcon("map.png", "NodeIcons"), NodeIconPredicate.TRUE);
+ }
+
+ @Override
+ public Color getBgColor(Node node){
+ return Color.GRAY;
+ }
+
+ @Override
+ public Color getFgColor(Node node){
+ return Color.BLACK;
+ }
+}
Deleted: trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/AccessPointNodeIcon.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/AccessPointNodeIcon.java 2008-02-01 13:41:00 UTC (rev 728)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/AccessPointNodeIcon.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -1,98 +0,0 @@
-
-package net.sf.magicmap.client.gui.utils;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Graphics;
-
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-
-import net.sf.magicmap.client.model.node.AccessPointNode;
-import net.sf.magicmap.client.model.node.INodeModel;
-import net.sf.magicmap.client.model.node.Node;
-
-/**
- * @author Florian Lederer
- */
-public class AccessPointNodeIcon implements INodeIcon {
-
- ImageIcon accessPoint;
- ImageIcon accessPointFixed;
- ImageIcon accessPointHidden;
- ImageIcon accessPointHiddenFixed;
-
- private ImageIcon getAccessPoint(){
- if (accessPoint == null) accessPoint = GUIBuilder.getToolIcon("accesspoint.png", "NodeIcons");
- return accessPoint;
- }
-
- private ImageIcon getAccessPointFixed(){
- if (accessPointFixed == null) {
- final ImageIcon anchor = GUIBuilder.getToolIcon("anchor_white.png", "NodeIcons");
- accessPointFixed = new ImageIcon(getAccessPoint().getImage()) {
-
- @Override
- public synchronized void paintIcon(Component c, Graphics g, int x, int y){
- super.paintIcon(c, g, x, y);
- g.drawImage(anchor.getImage(), x, y, x + getIconWidth(), y + getIconHeight(), 0, 0, anchor
- .getIconWidth(), anchor.getIconHeight(), null);
- }
- };
- }
- return accessPointFixed;
- }
-
- private ImageIcon getAccessPointHidden(){
- if (accessPointHidden == null)
- accessPointHidden = GUIBuilder.getToolIcon("accesspoint_hidden.png", "NodeIcons");
- return accessPointHidden;
- }
-
- private ImageIcon getAccessPointHiddenFixed(){
- if (accessPointHiddenFixed == null) {
- final ImageIcon anchor = GUIBuilder.getToolIcon("anchor_black.png", "NodeIcons");
- accessPointHiddenFixed = new ImageIcon(getAccessPointHidden().getImage()) {
-
- @Override
- public synchronized void paintIcon(Component c, Graphics g, int x, int y){
- super.paintIcon(c, g, x, y);
- g.drawImage(anchor.getImage(), x, y, x + getIconWidth(), y + getIconHeight(), 0, 0, anchor
- .getIconWidth(), anchor.getIconHeight(), null);
- }
- };
- }
- return accessPointHiddenFixed;
- }
-
- public Color getBgColor(Node node){
- return Color.BLACK;
- }
-
- public Color getFgColor(Node node){
- return Color.BLACK;
- }
-
- public Icon getIcon(Node node){
- AccessPointNode ap = (AccessPointNode) node;
- if (ap.isHidden()) {
- if (ap.isFix())
- return getAccessPointHiddenFixed();
- else
- return getAccessPointHidden();
- } else {
- if (ap.isFix())
- return getAccessPointFixed();
- else
- return getAccessPoint();
- }
- }
-
- public Class getNodeClass(){
- return AccessPointNode.class;
- }
-
- public int getNodeType(){
- return INodeModel.NODETYPE_ACCESSPOINT;
- }
-}
Deleted: trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/ClientNodeIcon.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/ClientNodeIcon.java 2008-02-01 13:41:00 UTC (rev 728)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/ClientNodeIcon.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -1,66 +0,0 @@
-
-package net.sf.magicmap.client.gui.utils;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Graphics;
-
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-
-import net.sf.magicmap.client.model.node.ClientNode;
-import net.sf.magicmap.client.model.node.INodeModel;
-import net.sf.magicmap.client.model.node.Node;
-
-/**
- * @author Florian Lederer
- */
-public class ClientNodeIcon implements INodeIcon {
-
- private ImageIcon client;
- private ImageIcon clientFixed;
-
- private ImageIcon getClient(){
- if (client == null) client = GUIBuilder.getToolIcon("client.png", "NodeIcons");
- return client;
- }
-
- private ImageIcon getClientFixed(){
- if (clientFixed == null) {
- final ImageIcon anchor = GUIBuilder.getToolIcon("anchor_black.png", "NodeIcons");
- clientFixed = new ImageIcon(getClient().getImage()) {
-
- @Override
- public synchronized void paintIcon(Component c, Graphics g, int x, int y){
- super.paintIcon(c, g, x, y);
- g.drawImage(anchor.getImage(), x, y, x + getIconWidth(), y + getIconHeight(), 0, 0, anchor
- .getIconWidth(), anchor.getIconHeight(), null);
- }
- };
- }
- return clientFixed;
- }
-
- public Color getBgColor(Node node){
- return Color.BLACK;
- }
-
- public Color getFgColor(Node node){
- return Color.BLACK;
- }
-
- public Icon getIcon(Node node){
- if (node.isFix()) return getClientFixed();
- return getClient();
-
- }
-
- public Class getNodeClass(){
- return ClientNode.class;
- }
-
- public int getNodeType(){
- return INodeModel.NODETYPE_CLIENT;
- }
-
-}
Deleted: trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/GeoPosNodeIcon.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/GeoPosNodeIcon.java 2008-02-01 13:41:00 UTC (rev 728)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/GeoPosNodeIcon.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -1,51 +0,0 @@
-package net.sf.magicmap.client.gui.utils;
-
-import java.awt.Color;
-
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-
-import net.sf.magicmap.client.model.node.GeoPosNode;
-import net.sf.magicmap.client.model.node.INodeModel;
-import net.sf.magicmap.client.model.node.Node;
-
-/**
- * @author Florian Lederer
- */
-public class GeoPosNodeIcon implements INodeIcon {
-
- private ImageIcon geoPos;
- private ImageIcon geoPosBig;
-
- private ImageIcon getGeoPos(){
- if (geoPos == null) geoPos = GUIBuilder.getToolIcon("geopos.png", "NodeIcons");
- return geoPos;
- }
-
- private ImageIcon getGeoPosBig(){
- if (geoPosBig == null) geoPosBig = GUIBuilder.getToolIcon("geopos_big.png", "NodeIcons");
- return geoPosBig;
- }
-
- public Color getBgColor(Node node){
- return Color.BLACK;
- }
-
- public Color getFgColor(Node node){
- return Color.BLACK;
- }
-
- public Icon getIcon(Node node){
- return getGeoPos();
-
- }
-
- public Class getNodeClass(){
- return GeoPosNode.class;
- }
-
- public int getNodeType(){
- return INodeModel.NODETYPE_GEOPOS;
- }
-
-}
Deleted: trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/INodeIcon.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/INodeIcon.java 2008-02-01 13:41:00 UTC (rev 728)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/INodeIcon.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -1,23 +0,0 @@
-package net.sf.magicmap.client.gui.utils;
-
-import java.awt.Color;
-
-import javax.swing.Icon;
-
-import net.sf.magicmap.client.model.node.Node;
-
-
-/**
- *
- * @author Jan Friderici
- * @author Florian Lederer
- *
- * @param <T> the nodetype this is icon is for.
- */
-public interface INodeIcon {
- public int getNodeType();
- public Class getNodeClass();
- public Icon getIcon(Node node);
- public Color getFgColor(Node node);
- public Color getBgColor(Node node);
-}
Deleted: trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/LocationNodeIcon.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/LocationNodeIcon.java 2008-02-01 13:41:00 UTC (rev 728)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/LocationNodeIcon.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -1,57 +0,0 @@
-
-package net.sf.magicmap.client.gui.utils;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Graphics;
-
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-
-import net.sf.magicmap.client.model.node.INodeModel;
-import net.sf.magicmap.client.model.node.LocationNode;
-import net.sf.magicmap.client.model.node.Node;
-
-/**
- * @author Florian Lederer
- */
-public class LocationNodeIcon implements INodeIcon {
-
- ImageIcon location;
- ImageIcon locationFixed;
- ImageIcon locationRescan;
-
- private ImageIcon getLocation(){
- if (location == null) location = GUIBuilder.getToolIcon("location.png", "NodeIcons");
- return location;
- }
-
- private ImageIcon getLocationRescan(){
- if (locationRescan == null) locationRescan = GUIBuilder.getToolIcon("location_rescan.png", "NodeIcons");
- return locationRescan;
- }
-
- public Color getBgColor(Node node){
- return Color.BLACK;
- }
-
- public Color getFgColor(Node node){
- return Color.BLACK;
- }
-
- public Icon getIcon(Node node){
- if (node.isUpdate()) {
- return getLocationRescan();
- } else {
- return getLocation();
- }
- }
-
- public Class getNodeClass(){
- return LocationNode.class;
- }
-
- public int getNodeType(){
- return INodeModel.NODETYPE_LOCATION;
- }
-}
Deleted: trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/MapNodeIcon.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/MapNodeIcon.java 2008-02-01 13:41:00 UTC (rev 728)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/MapNodeIcon.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -1,45 +0,0 @@
-
-package net.sf.magicmap.client.gui.utils;
-
-import java.awt.Color;
-
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-
-import net.sf.magicmap.client.model.node.INodeModel;
-import net.sf.magicmap.client.model.node.MapNode;
-import net.sf.magicmap.client.model.node.Node;
-
-/**
- * @author Florian Lederer
- */
-public class MapNodeIcon implements INodeIcon {
-
- private ImageIcon map;
-
- private ImageIcon getMap(){
- if (map == null) map = GUIBuilder.getToolIcon("map.png", "NodeIcons");
- return map;
- }
-
- public Color getBgColor(Node node){
- return Color.BLACK;
- }
-
- public Color getFgColor(Node node){
- return Color.BLACK;
- }
-
- public Icon getIcon(Node node){
- return getMap();
-
- }
-
- public Class getNodeClass(){
- return MapNode.class;
- }
-
- public int getNodeType(){
- return INodeModel.NODETYPE_MAP;
- }
-}
Deleted: trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/NodeIcons.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/NodeIcons.java 2008-02-01 13:41:00 UTC (rev 728)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/NodeIcons.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -1,68 +0,0 @@
-
-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
Added: trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/AbstractNodeIcon.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/AbstractNodeIcon.java (rev 0)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/AbstractNodeIcon.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -0,0 +1,105 @@
+
+package net.sf.magicmap.client.gui.utils.icon;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.util.ArrayList;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+import net.sf.magicmap.client.model.node.Node;
+
+/**
+ * @author Florian Lederer
+ */
+
+abstract public class AbstractNodeIcon implements INodeIcon {
+
+ private class IconStore {
+
+ public NodeIconPredicate condition;
+ public ImageIcon icon;
+
+ public IconStore(NodeIconPredicate condition, ImageIcon icon) {
+ this.condition = condition;
+ this.icon = icon;
+ }
+ }
+
+ private ArrayList<IconStore> overlayIcons = new ArrayList<IconStore>();
+
+ private ArrayList<IconStore> backgroundIcons = new ArrayList<IconStore>();
+
+ abstract public Color getBgColor(Node node);
+
+ abstract public Color getFgColor(Node node);
+
+ public Icon getIcon(Node node){
+
+ final ImageIcon overlayIcon = getOverlayIcon(node);
+ final ImageIcon backgroundIcon = getBackgroundIcon(node);
+
+ if (overlayIcon == null)
+ return backgroundIcon;
+ else if (backgroundIcon == null)
+ return overlayIcon;
+ else
+ return new ImageIcon(getBackgroundIcon(node).getImage()) {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public synchronized void paintIcon(Component c, Graphics g, int x, int y){
+ super.paintIcon(c, g, x, y);
+ g.drawImage(overlayIcon.getImage(), x, y, x + getIconWidth(), y + getIconHeight(), 0, 0,
+ overlayIcon.getIconWidth(), overlayIcon.getIconHeight(), null);
+ }
+ };
+ }
+
+ public void addBackgroundIcon(ImageIcon icon, NodeIconPredicate condition){
+ backgroundIcons.add(0, new IconStore(condition, icon));
+ }
+
+ public void addOverlayIcon(ImageIcon icon, NodeIconPredicate condition){
+ overlayIcons.add(0, new IconStore(condition, icon));
+ }
+
+ protected ImageIcon getBackgroundIcon(final Node node){
+ ImageIcon icon = null;
+ for (IconStore store : backgroundIcons) {
+ try {
+ if (store.condition.showIcon(node)) {
+ icon = store.icon;
+ break;
+ }
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return icon;
+ }
+
+ protected ImageIcon getOverlayIcon(final Node node){
+ ImageIcon icon = null;
+ for (IconStore store : overlayIcons) {
+ try {
+ if ((Boolean) store.condition.showIcon(node)) {
+ icon = store.icon;
+ break;
+ }
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return icon;
+ }
+
+}
Copied: trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/INodeIcon.java (from rev 726, trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/INodeIcon.java)
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/INodeIcon.java (rev 0)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/INodeIcon.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -0,0 +1,23 @@
+
+package net.sf.magicmap.client.gui.utils.icon;
+
+import java.awt.Color;
+
+import javax.swing.Icon;
+
+import net.sf.magicmap.client.model.node.Node;
+
+/**
+ *
+ * @author Jan Friderici
+ * @author Florian Lederer
+ *
+ */
+public interface INodeIcon {
+
+ public Icon getIcon(Node node);
+
+ public Color getFgColor(Node node);
+
+ public Color getBgColor(Node node);
+}
Added: trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconAndPredicate.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconAndPredicate.java (rev 0)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconAndPredicate.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -0,0 +1,24 @@
+
+package net.sf.magicmap.client.gui.utils.icon;
+
+import net.sf.magicmap.client.model.node.Node;
+
+/**
+ * @author Florian Lederer
+ */
+
+public class NodeIconAndPredicate implements NodeIconPredicate {
+
+ private final NodeIconPredicate first;
+ private final NodeIconPredicate second;
+
+ public NodeIconAndPredicate(NodeIconPredicate first, NodeIconPredicate second) {
+
+ this.first = first;
+ this.second = second;
+ }
+
+ public boolean showIcon(Node node){
+ return first.showIcon(node) && second.showIcon(node);
+ }
+}
\ No newline at end of file
Added: trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconContainer.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconContainer.java (rev 0)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconContainer.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -0,0 +1,62 @@
+
+package net.sf.magicmap.client.gui.utils.icon;
+
+import java.awt.Color;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.Icon;
+
+import net.sf.magicmap.client.gui.utils.GUIBuilder;
+import net.sf.magicmap.client.model.node.Node;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author Florian Lederer
+ */
+public class NodeIconContainer {
+
+ private static NodeIconContainer ni = null;
+
+ private static Logger log = Logger.getLogger(NodeIconContainer.class);
+
+ public 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;
+ }
+ };
+
+ private final Map<Integer, INodeIcon> iconMap = new HashMap<Integer, INodeIcon>();
+
+ private NodeIconContainer() {}
+
+ public static NodeIconContainer getInstance(){
+ if (NodeIconContainer.ni == null) NodeIconContainer.ni = new NodeIconContainer();
+ return NodeIconContainer.ni;
+ }
+
+ public INodeIcon getNodeIcon(Node node){
+ if (node == null) return null;
+ // TODO: replace getType() with getCategory() when implemented
+ if (iconMap.containsKey(node.getType())) return iconMap.get(node.getType());
+ return DEFAULT_ICON;
+ }
+
+ public void registerNodeIcon(int category, INodeIcon icon){
+ iconMap.put(category, icon);
+ }
+
+}
\ No newline at end of file
Added: trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconNotPredicate.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconNotPredicate.java (rev 0)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconNotPredicate.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -0,0 +1,22 @@
+
+package net.sf.magicmap.client.gui.utils.icon;
+
+import net.sf.magicmap.client.model.node.Node;
+
+/**
+ * @author Florian Lederer
+ */
+
+public class NodeIconNotPredicate implements NodeIconPredicate {
+
+ private final NodeIconPredicate other;
+
+ public NodeIconNotPredicate(NodeIconPredicate other) {
+ this.other = other;
+ }
+
+ public boolean showIcon(Node node){
+ return !other.showIcon(node);
+ }
+
+}
Added: trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconOrPredicate.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconOrPredicate.java (rev 0)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconOrPredicate.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -0,0 +1,24 @@
+
+package net.sf.magicmap.client.gui.utils.icon;
+
+import net.sf.magicmap.client.model.node.Node;
+
+/**
+ * @author Florian Lederer
+ */
+
+public class NodeIconOrPredicate implements NodeIconPredicate {
+
+ private final NodeIconPredicate first;
+ private final NodeIconPredicate second;
+
+ public NodeIconOrPredicate(NodeIconPredicate first, NodeIconPredicate second) {
+
+ this.first = first;
+ this.second = second;
+ }
+
+ public boolean showIcon(Node node){
+ return first.showIcon(node) || second.showIcon(node);
+ }
+}
\ No newline at end of file
Added: trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconPredicate.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconPredicate.java (rev 0)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/icon/NodeIconPredicate.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -0,0 +1,25 @@
+package net.sf.magicmap.client.gui.utils.icon;
+
+import net.sf.magicmap.client.model.node.Node;
+
+/**
+ * @author Florian Lederer
+ */
+
+
+public interface NodeIconPredicate {
+
+ public boolean showIcon(Node node);
+
+ public static final NodeIconPredicate TRUE = new NodeIconPredicate() {
+ public boolean showIcon(Node node) {
+ return true;
+ };
+ };
+
+ public static final NodeIconPredicate FALSE = new NodeIconPredicate() {
+ public boolean showIcon(Node node) {
+ return false;
+ };
+ };
+}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/MapView.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/MapView.java 2008-02-01 13:41:00 UTC (rev 728)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/MapView.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -26,7 +26,7 @@
import net.sf.magicmap.client.gui.utils.GUIBuilder;
import net.sf.magicmap.client.gui.utils.GUIConstants;
import net.sf.magicmap.client.gui.utils.GUIUtils;
-import net.sf.magicmap.client.gui.utils.NodeIcons;
+import net.sf.magicmap.client.gui.utils.icon.NodeIconContainer;
import net.sf.magicmap.client.meta.MapInfo;
import net.sf.magicmap.client.model.location.INodePlacer;
import net.sf.magicmap.client.model.location.jung.JungNodePlacer;
@@ -102,7 +102,7 @@
private boolean calculateHeight = false;
- private static Logger log = Logger.getLogger(NodeIcons.class);
+ private static Logger log = Logger.getLogger(NodeIconContainer.class);
// @TODO TEST LAYOUT!
JungNodePlacer layoutModel;
@@ -210,7 +210,7 @@
if (!showLocations) return null;
break;
}
- return MainGUI.getInstance().getNodeIcons().getNodeIcon(node).getFgColor(node);
+ return MainGUI.getInstance().getNodeIconContainer().getNodeIcon(node).getFgColor(node);
}
public Color getBackColor(Vertex v){
@@ -226,7 +226,7 @@
if (!showLocations) return null;
break;
}
- return MainGUI.getInstance().getNodeIcons().getNodeIcon(node).getBgColor(node);
+ return MainGUI.getInstance().getNodeIconContainer().getNodeIcon(node).getBgColor(node);
}
public Icon getIcon(Vertex v){
@@ -242,7 +242,7 @@
if (!showLocations) return null;
break;
}
- return MainGUI.getInstance().getNodeIcons().getNodeIcon(node).getIcon(node);
+ return MainGUI.getInstance().getNodeIconContainer().getNodeIcon(node).getIcon(node);
}
});
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/OutlineTree.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/OutlineTree.java 2008-02-01 13:41:00 UTC (rev 728)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/OutlineTree.java 2008-02-04 15:22:07 UTC (rev 729)
@@ -88,7 +88,7 @@
} else {
c = (JLabel) super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
c.setText(node.getDisplayName());
- Icon icon = MainGUI.getInstance().getNodeIcons().getNodeIcon(node).getIcon(node);
+ Icon icon = MainGUI.getInstance().getNodeIconContainer().getNodeIcon(node).getIcon(node);
if (icon == null) icon = this.getDefaultLeafIcon();
c.setIcon(icon);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|