From: <jan...@us...> - 2008-01-01 23:15:17
|
Revision: 708 http://magicmap.svn.sourceforge.net/magicmap/?rev=708&view=rev Author: jan_fride Date: 2008-01-01 15:14:33 -0800 (Tue, 01 Jan 2008) Log Message: ----------- Infoobject branch.... Modified Paths: -------------- branches/info/magicmapclient/build.xml branches/info/magicmapclient/magicmapclient.iml branches/info/magicmapclient/src/com/jgoodies/uif_lite/panel/SimpleInternalFrame.java branches/info/magicmapclient/src/edu/uci/ics/jung/visualization/VisualizationViewer.java branches/info/magicmapclient/src/net/sf/magicmap/client/gui/utils/GUIUtils.java branches/info/magicmapclient/src/net/sf/magicmap/client/model/node/INode.java branches/info/magicmapclient/src/net/sf/magicmap/client/model/node/INodeModel.java branches/info/magicmapclient/src/net/sf/magicmap/client/model/node/Node.java Added Paths: ----------- branches/info/magicmapclient/ branches/info/magicmapclient/src/net/sf/magicmap/client/model/location/INodePlacer.java branches/info/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java branches/info/magicmapclient/src/net/sf/magicmap/client/model/node/IMagicEdge.java branches/info/magicmapclient/src/net/sf/magicmap/core/ branches/info/magicmapclient/src/net/sf/magicmap/core/model/ branches/info/magicmapclient/src/net/sf/magicmap/core/model/graph/ branches/info/magicmapclient/src/net/sf/magicmap/core/model/graph/IGraphEdge.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/graph/IGraphElement.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/graph/IGraphNode.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/graph/INodeGraph.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/graph/impl/ branches/info/magicmapclient/src/net/sf/magicmap/core/model/graph/impl/BaseGraphElement.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/graph/impl/BaseGraphNode.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/graph/impl/BaseNodeGraph.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/graph/jung/ branches/info/magicmapclient/src/net/sf/magicmap/core/model/location/ branches/info/magicmapclient/src/net/sf/magicmap/core/model/location/ForwardingNodePlacer.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/node/ branches/info/magicmapclient/src/net/sf/magicmap/core/model/node/InterceptableNodeModel.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/node/KeyGenerator.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/node/NodeFilter.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/node/NodeIndex.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/node/NodeModelInterceptor.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/node/SearchableNodeIndex.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/node/SearchableNodeModel.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/node/impl/ branches/info/magicmapclient/src/net/sf/magicmap/core/model/node/impl/BaseNodeIndex.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/node/impl/MacNodeKeyGenerator.java branches/info/magicmapclient/src/net/sf/magicmap/core/model/node/impl/NodeIndexFactory.java Removed Paths: ------------- branches/info/magicmapclient/src/net/sf/magicmap/client/model/location/INodePlacer.java branches/info/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java branches/info/magicmapclient/src/net/sf/magicmap/client/model/node/IMagicEdge.java Copied: branches/info/magicmapclient (from rev 704, trunk/magicmapclient) Modified: branches/info/magicmapclient/build.xml =================================================================== --- trunk/magicmapclient/build.xml 2007-12-21 12:06:47 UTC (rev 704) +++ branches/info/magicmapclient/build.xml 2008-01-01 23:14:33 UTC (rev 708) @@ -8,7 +8,7 @@ <property name="main.class" value="net.sf.magicmap.client.core.MagicMapApplication" /> <!-- Setting for maven path--> - <property name="maven.home" value="D:\_development\_Tools\maven-2.0.5"/> + <property name="maven.home" value="/usr/local/maven"/> @@ -156,7 +156,7 @@ <!-- Setting for maven path must be checked.--> <target name="maven-install"> - <exec executable="${maven.home}/bin/mvn.bat"> + <exec executable="${maven.home}/bin/mvn"> <arg value="install:install-file"/> <arg value="-Dfile=magicmap.jar"/> <arg value="-DgroupId=net.sf.magicmap"/> Modified: branches/info/magicmapclient/magicmapclient.iml =================================================================== --- trunk/magicmapclient/magicmapclient.iml 2007-12-21 12:06:47 UTC (rev 704) +++ branches/info/magicmapclient/magicmapclient.iml 2008-01-01 23:14:33 UTC (rev 708) @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<module version="4" relativePaths="false" type="JAVA_MODULE"> - <component name="ModuleRootManager" /> - <component name="NewModuleRootManager" inherit-compiler-output="false"> +<module relativePaths="true" type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> <output url="file://$MODULE_DIR$/build" /> <exclude-output /> <output-test url="file://$MODULE_DIR$/build-test" /> @@ -9,35 +8,34 @@ <sourceFolder url="file://$MODULE_DIR$/res" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src-gen" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" /> - <excludeFolder url="file://$MODULE_DIR$/build" /> - <excludeFolder url="file://$MODULE_DIR$/build-test" /> - <excludeFolder url="file://$MODULE_DIR$/target" /> + <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="false" /> </content> - <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://X:/maven/junit/junit/3.8.1/junit-3.8.1.jar!/" /> + <root url="jar://$MODULE_DIR$/../magicmapserver/dist/magicmap-server.jar!/" /> </CLASSES> <JAVADOC /> - <SOURCES /> + <SOURCES> + <root url="file://$MODULE_DIR$/../magicmapserver/src" /> + </SOURCES> </library> </orderEntry> <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/dom4j-1.6.1.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/commons-httpclient-3.0-rc3.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> + <orderEntry type="inheritedJdk" /> <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/forms-1.0.5.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/colt.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -55,7 +53,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/foxtrot.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/concurrent.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -64,7 +62,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/jaxrpc.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/xercesImpl.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -73,7 +71,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/ostermillerutils_1_05_00.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/xml-apis.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -82,7 +80,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/commons-codec-1.3.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/xmlParserAPIs.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -91,7 +89,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/concurrent.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/RelativeLayout.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -100,7 +98,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/colt.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/forms-1.0.5.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -109,7 +107,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/nekohtml.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/activation.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -118,7 +116,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/commons-logging.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/mail.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -127,7 +125,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/jung-1.5.2.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/commons-discovery.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -136,7 +134,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/saaj.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/commons-logging.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -145,7 +143,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/xmlParserAPIs.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/jaxrpc.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -154,7 +152,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/derby.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/saaj.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -163,7 +161,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/RelativeLayout.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/wsdl4j.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -172,7 +170,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/xercesImpl.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/axis.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -181,7 +179,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/xml-apis.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/jung-1.5.2.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -190,7 +188,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/mail.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/derby.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -199,7 +197,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/jaxen-1.1-beta-9.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/jpox-20041204.032009.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -208,7 +206,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/commons-httpclient-3.0-rc3.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/log4j-1.2.8.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -217,7 +215,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/jpox-20041204.032009.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/ostermillerutils_1_05_00.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -226,7 +224,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/looks-1.2.2.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/dom4j-1.6.1.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -235,7 +233,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/log4j-1.2.8.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/commons-codec-1.3.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -244,7 +242,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/axis.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/jaxen-1.1-beta-9.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -253,7 +251,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/activation.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/foxtrot.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -262,7 +260,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/wsdl4j.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/nekohtml.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -271,15 +269,6 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/commons-discovery.jar!/" /> - </CLASSES> - <JAVADOC /> - <SOURCES /> - </library> - </orderEntry> - <orderEntry type="module-library"> - <library> - <CLASSES> <root url="jar://$MODULE_DIR$/lib-dev/junit.jar!/" /> </CLASSES> <JAVADOC /> @@ -289,13 +278,12 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib-dev/axis-ant.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/looks-2.1.4.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> - <orderEntry type="module" module-name="magicmapserver" /> <orderEntryProperties /> </component> </module> Modified: branches/info/magicmapclient/src/com/jgoodies/uif_lite/panel/SimpleInternalFrame.java =================================================================== --- trunk/magicmapclient/src/com/jgoodies/uif_lite/panel/SimpleInternalFrame.java 2007-12-21 12:06:47 UTC (rev 704) +++ branches/info/magicmapclient/src/com/jgoodies/uif_lite/panel/SimpleInternalFrame.java 2008-01-01 23:14:33 UTC (rev 708) @@ -30,30 +30,13 @@ package com.jgoodies.uif_lite.panel; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.GradientPaint; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Insets; -import java.awt.LayoutManager; -import java.awt.Paint; +import com.jgoodies.looks.LookUtils; +import net.sf.magicmap.client.gui.utils.ShadowBorder; -import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JToolBar; -import javax.swing.SwingConstants; -import javax.swing.UIManager; +import javax.swing.*; import javax.swing.border.AbstractBorder; +import java.awt.*; -import net.sf.magicmap.client.gui.utils.ShadowBorder; - -import com.jgoodies.plaf.LookUtils; - /** * A <code>JPanel</code> subclass that has a drop shadow border and * that provides a header with icon, title and tool bar.<p> Modified: branches/info/magicmapclient/src/edu/uci/ics/jung/visualization/VisualizationViewer.java =================================================================== --- trunk/magicmapclient/src/edu/uci/ics/jung/visualization/VisualizationViewer.java 2007-12-21 12:06:47 UTC (rev 704) +++ branches/info/magicmapclient/src/edu/uci/ics/jung/visualization/VisualizationViewer.java 2008-01-01 23:14:33 UTC (rev 708) @@ -24,7 +24,6 @@ import java.awt.geom.AffineTransform; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import javax.swing.JPanel; Modified: branches/info/magicmapclient/src/net/sf/magicmap/client/gui/utils/GUIUtils.java =================================================================== --- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/GUIUtils.java 2007-12-21 12:06:47 UTC (rev 704) +++ branches/info/magicmapclient/src/net/sf/magicmap/client/gui/utils/GUIUtils.java 2008-01-01 23:14:33 UTC (rev 708) @@ -5,32 +5,23 @@ package net.sf.magicmap.client.gui.utils; -import java.awt.Dimension; -import java.awt.Window; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.ResourceBundle; +import com.jgoodies.looks.Options; +import com.jgoodies.looks.plastic.Plastic3DLookAndFeel; +import com.jgoodies.looks.plastic.PlasticLookAndFeel; +import com.jgoodies.looks.plastic.theme.ExperienceBlue; +import net.sf.magicmap.client.gui.MainGUI; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.SwingConstants; -import javax.swing.UIManager; -import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.plaf.metal.MetalLookAndFeel; +import java.awt.*; +import java.util.*; -import net.sf.magicmap.client.gui.MainGUI; +import apple.laf.AquaLookAndFeel; -import com.jgoodies.plaf.FontSizeHints; -import com.jgoodies.plaf.Options; -import com.jgoodies.plaf.plastic.Plastic3DLookAndFeel; -import com.jgoodies.plaf.plastic.theme.ExperienceBlue; - /** * @author msc - * + * */ public class GUIUtils { @@ -39,22 +30,33 @@ private static Map<String, ResourceBundle> bundles = null; public static void setPlasticLookAndFeel(){ + try { - UIManager.setLookAndFeel(new Plastic3DLookAndFeel()); + if (!isOsX()) { + UIManager.setLookAndFeel(new Plastic3DLookAndFeel()); + + } } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } - UIManager.put("Application.useSystemFontSettings", Boolean.TRUE); - UIManager.put(Options.USE_SYSTEM_FONTS_APP_KEY, Boolean.TRUE); - UIManager.put(com.jgoodies.plaf.Options.DEFAULT_ICON_SIZE_KEY, new Dimension(18, 18)); - Options.setGlobalFontSizeHints(FontSizeHints.MIXED); - // PlasticLookAndFeel.setFontSizeHints(FontSizeHints.SYSTEM); - MetalLookAndFeel.setCurrentTheme(new ExperienceBlue()); - Options.setGlobalFontSizeHints(FontSizeHints.MIXED); + if (!isOsX()) { + UIManager.put("Application.useSystemFontSettings", Boolean.TRUE); + UIManager.put(Options.USE_SYSTEM_FONTS_APP_KEY, Boolean.TRUE); + //UIManager.put(com.jgoodies.plaf.Options.DEFAULT_ICON_SIZE_KEY, new Dimension(18, 18)); + // Options.setGlobalFontSizeHints(FontSizeHints.MIXED); + // PlasticLookAndFeel.setFontSizeHints(FontSizeHints.SYSTEM); + MetalLookAndFeel.setCurrentTheme(new ExperienceBlue()); + //Options.setGlobalFontSizeHints(FontSizeHints.MIXED); + } } + private static boolean isOsX() { + String lcOSName = System.getProperty("os.name").toLowerCase(); + return lcOSName.startsWith("mac os x"); + } + public static void locateOnScreen(Window frame){ Dimension paneSize = frame.getSize(); Dimension screenSize = frame.getToolkit().getScreenSize(); @@ -155,14 +157,14 @@ return JOptionPane.showOptionDialog(MainGUI.getInstance().getMainFrame(), GUIUtils.i18n("serverresponse") + "\n" + message, GUIUtils.i18n("authentificationerror"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE, null, new String[]{GUIUtils.i18n("retry"), GUIUtils.i18n("no")}, GUIUtils - .i18n("retry")) == JOptionPane.YES_OPTION; + .i18n("retry")) == JOptionPane.YES_OPTION; } public static boolean showConnectionError(){ return JOptionPane.showOptionDialog(MainGUI.getInstance().getMainFrame(), GUIUtils .i18n("connectionsproblemsreconnect"), GUIUtils.i18n("connectionproblems"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE, null, new String[]{GUIUtils.i18n("yes"), - GUIUtils.i18n("no")}, GUIUtils.i18n("yes")) == JOptionPane.YES_OPTION; + GUIUtils.i18n("no")}, GUIUtils.i18n("yes")) == JOptionPane.YES_OPTION; } public static void showErrorDialog(String message){ Deleted: branches/info/magicmapclient/src/net/sf/magicmap/client/model/location/INodePlacer.java =================================================================== --- trunk/magicmapclient/src/net/sf/magicmap/client/model/location/INodePlacer.java 2007-12-21 12:06:47 UTC (rev 704) +++ branches/info/magicmapclient/src/net/sf/magicmap/client/model/location/INodePlacer.java 2008-01-01 23:14:33 UTC (rev 708) @@ -1,128 +0,0 @@ - -package net.sf.magicmap.client.model.location; - -import java.util.HashMap; - -import net.sf.magicmap.client.algorithms.NodeMetricManager; -import net.sf.magicmap.client.model.node.IMagicEdge; -import net.sf.magicmap.client.model.node.Node; - -/** - * Berechnet die Orte von Knoten. Um einem Model ein INodePlacer hinzuzfügen - * muss man nur - * </ul> - * <li>das Model dem Konstruktor übergeben (wenn der OPlacer dies unterstüzt) oder</li> - * <li>Den Nodeplacer zusätzlich das ModelListener Interface implementieren lassen und - * sich beim Model registrieren.</li> - * </ul> - * @author Jan Friderici - * - */ -public interface INodePlacer { - - /** - * Fügt einen neuen Knoten ein. - * - * @param node der neue Knoten. - */ - public void insertNode(Node node); - - /** - * Löscht einen Knoten. - * @param node - */ - public void deleteNode(Node node); - - /** - * Legt eine gerichtete Kante zwischen den beiden Knoten an. - * - * @param n1 die Quelle der Kante - * @param n2 das Ziel der Kante - * @return - */ - public IMagicEdge addEdge(Node n1, Node n2); - - /** - * Löscht eine gerichtete Kante. (also nur eine Richtung). - * @param n1 - * @param n2 - */ - public void removeEdge(Node n1, Node n2); - - /** - * Die Größe des Layoutalgorithmus sollte der der Karte - * entsprechen. - * - * @param width die Breite (der Karte). - * @param height die Höhe (der Karte). - */ - public void setSize(int width, int height); - - /** - * Starts the algorithm. - * - */ - public abstract void startNodePlacer(); - - /** - * Stops the algorithm - * - */ - public abstract void stopNodePlacer(); - - /** - * - * @param pause - */ - public abstract void pauseNodePlacer(boolean pause); - - /** - * - * @return - */ - public boolean isPaused(); - - /** - * Adds a handler for node updates. - * @param handler - */ - public void addNodeUpdateHandler(NodeUpdateHandler handler); - - public NodeMetricManager getMetricManager(); - - public void updateNode(Node node, int type, Object data); - static final class NodeHandlerFactory { - - public final HashMap<Integer, NodeUpdateHandler> handlerMap; - - public NodeHandlerFactory() { - this.handlerMap = new HashMap<Integer, NodeUpdateHandler>(); - } - - public void addNodeUpdateHandler(NodeUpdateHandler handler){ - this.handlerMap.put(handler.getType(), handler); - } - - /** - * - * @param node - * @param type - * @param data - * @param placer - * @return - */ - public boolean handleNodeUpdated(Node node, int type, Object data, INodePlacer placer){ - NodeUpdateHandler handler = getHandler(type); - if (handler != null) { - handler.handleNodeUpdated(node, type, data, placer); - return true; - } - return false; - } - - public NodeUpdateHandler getHandler(int type){ - return this.handlerMap.get(type); - } - } - public void clear();; -} Copied: branches/info/magicmapclient/src/net/sf/magicmap/client/model/location/INodePlacer.java (from rev 706, trunk/magicmapclient/src/net/sf/magicmap/client/model/location/INodePlacer.java) =================================================================== --- branches/info/magicmapclient/src/net/sf/magicmap/client/model/location/INodePlacer.java (rev 0) +++ branches/info/magicmapclient/src/net/sf/magicmap/client/model/location/INodePlacer.java 2008-01-01 23:14:33 UTC (rev 708) @@ -0,0 +1,155 @@ + +package net.sf.magicmap.client.model.location; + +import java.util.HashMap; + +import net.sf.magicmap.client.algorithms.NodeMetricManager; +import net.sf.magicmap.client.model.node.IMagicEdge; +import net.sf.magicmap.client.model.node.Node; + +/** + * Berechnet die Orte von Knoten. Um einem Model ein INodePlacer hinzuzfügen + * muss man nur + * </ul> + * <li>das Model dem Konstruktor übergeben (wenn der OPlacer dies unterstüzt) oder</li> + * <li>Den Nodeplacer zusätzlich das ModelListener Interface implementieren lassen und + * sich beim Model registrieren.</li> + * </ul> + * @author Jan Friderici + * + */ +public interface INodePlacer extends Iterable<IMagicEdge>{ + + /** + * Fügt einen neuen Knoten ein. + * + * @param node der neue Knoten. + */ + void insertNode(Node node); + + /** + * Löscht einen Knoten. + * @param node + */ + void deleteNode(Node node); + + /** + * Legt eine gerichtete Kante zwischen den beiden Knoten an. + * + * @param n1 die Quelle der Kante + * @param n2 das Ziel der Kante + * @return + */ + IMagicEdge addEdge(Node n1, Node n2); + + /** + * <p>Find the ege connecting the two given nodes.</p> + * @param n1 first node + * @param n2 secnd node + * @return the connecting edge or null. + */ + IMagicEdge getEdge(Node n1, Node n2); + + /** + * Löscht eine gerichtete Kante. (also nur eine Richtung). + * @param n1 first node + * @param n2 second node + */ + void removeEdge(Node n1, Node n2); + + /** + * Die Größe des Layoutalgorithmus sollte der der Karte + * entsprechen. + * + * @param width die Breite (der Karte). + * @param height die Höhe (der Karte). + */ + void setSize(int width, int height); + + /** + * Starts the algorithm. + * + */ + void startNodePlacer(); + + /** + * Stops the algorithm + * + */ + void stopNodePlacer(); + + /** + * + * @param pause + */ + void pauseNodePlacer(boolean pause); + + /** + * + * @return + */ + boolean isPaused(); + + /** + * Adds a handler for node updates. + * @param handler + */ + void addNodeUpdateHandler(NodeUpdateHandler handler); + + /** + * + * @return the metric manager for this layout. + */ + NodeMetricManager getMetricManager(); + + /** + * + * @param node + * @param type + * @param data + */ + void updateNode(Node node, int type, Object data); + + + /** + * + */ + static final class NodeHandlerFactory { + + public final HashMap<Integer, NodeUpdateHandler> handlerMap; + + public NodeHandlerFactory() { + this.handlerMap = new HashMap<Integer, NodeUpdateHandler>(); + } + + public void addNodeUpdateHandler(NodeUpdateHandler handler){ + this.handlerMap.put(handler.getType(), handler); + } + + /** + * + * @param node + * @param type + * @param data + * @param placer + * @return + */ + public boolean handleNodeUpdated(Node node, int type, Object data, INodePlacer placer){ + NodeUpdateHandler handler = getHandler(type); + if (handler != null) { + handler.handleNodeUpdated(node, type, data, placer); + return true; + } + return false; + } + + public NodeUpdateHandler getHandler(int type){ + return this.handlerMap.get(type); + } + } + + /** + * <p>Remove all nodes and edges...</p> + */ + void clear(); +} Deleted: branches/info/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java =================================================================== --- trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java 2007-12-21 12:06:47 UTC (rev 704) +++ branches/info/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java 2008-01-01 23:14:33 UTC (rev 708) @@ -1,402 +0,0 @@ - -package net.sf.magicmap.client.model.location.jung; - -import java.awt.Dimension; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import net.sf.magicmap.client.algorithms.MagicMetric; -import net.sf.magicmap.client.algorithms.NodeMetricManager; -import net.sf.magicmap.client.algorithms.NodeModelMetric; -import net.sf.magicmap.client.controller.Controller; -import net.sf.magicmap.client.model.location.INodePlacer; -import net.sf.magicmap.client.model.location.NodeUpdateHandler; -import net.sf.magicmap.client.model.location.jung.handler.AccessPointHiddenStateHandler; -import net.sf.magicmap.client.model.location.jung.handler.CalculationStateHandler; -import net.sf.magicmap.client.model.location.jung.handler.FixStateHandler; -import net.sf.magicmap.client.model.location.jung.handler.LabelChangeHandler; -import net.sf.magicmap.client.model.location.jung.handler.NotSeeAccessPointHandler; -import net.sf.magicmap.client.model.location.jung.handler.PositionUpdateHandler; -import net.sf.magicmap.client.model.location.jung.handler.SeeAccessPointHandler; -import net.sf.magicmap.client.model.node.ClientNode; -import net.sf.magicmap.client.model.node.IMagicEdge; -import net.sf.magicmap.client.model.node.LocationNode; -import net.sf.magicmap.client.model.node.MapNode; -import net.sf.magicmap.client.model.node.Node; -import net.sf.magicmap.client.model.node.NodeModelConstants; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import edu.uci.ics.jung.graph.Edge; -import edu.uci.ics.jung.graph.Vertex; -import edu.uci.ics.jung.graph.decorators.StringLabeller; -import edu.uci.ics.jung.graph.impl.DirectedSparseGraph; -import edu.uci.ics.jung.graph.impl.DirectedSparseVertex; -import edu.uci.ics.jung.utils.UserData; -import edu.uci.ics.jung.visualization.SpringLayout; - -/** - * Dieses Model benutzt die Layoutfunktionen von Jung und einige Angepasste - * Layoutalgorithmen um die Knotenposition zu berechnen. - * - * @author Jan - * - */ -public class JungNodePlacer extends DirectedSparseGraph implements INodePlacer, NodeModelConstants { - - /** - * Logger - */ - private static final Log log = LogFactory.getLog(JungNodePlacer.class); - - /** - * Used to find the Vertex representing a node. - */ - private final Map<Node, Vertex> nodeVertexMapping = new HashMap<Node, Vertex>(); - - /** - * - */ - private final SpringLayout layout; - - /** - * Calculates the layout in a background thread. - */ - private final LayoutWorker worker; - - private boolean workerPaused; - - private boolean workerRunning; - - /** - * Werden f\xFCr die Handler ben\xF6tigt - */ - private HashMap<ClientNode, HashSet<LocationNode>> clientLocationMap; - - /** - * Werden f\xFCr die Handler ben\xF6tigt - */ - private HashMap<LocationNode, HashSet<LocationNode>> locationLocationMap; - - /** - * Werden f\xFCr die Handler ben\xF6tigt - */ - private StringLabeller labeller; - - /** - * A Factory for the NodeUpdateHandler. - * @see NodeUpdateHandler - */ - private final NodeHandlerFactory nodeHandler = new NodeHandlerFactory(); - - private final NodeMetricManager metricManager; - - private final Object edgeLock = new Object(); - private final Object vertexLock = new Object(); - - public JungNodePlacer() { - this(new MagicMetric()); - } - - /** - * - * @return - */ - public NodeMetricManager getMetricManager(){ - return metricManager; - } - - /** - * - * @param settings - * @param metric - */ - public JungNodePlacer(NodeModelMetric metric) { - super(); - this.metricManager = new NodeMetricManager(metric); - this.clientLocationMap = new HashMap<ClientNode, HashSet<LocationNode>>(); - this.locationLocationMap = new HashMap<LocationNode, HashSet<LocationNode>>(); - this.layout = new MagicLayout(this, metricManager); - this.worker = new LayoutWorker(this.layout, new Dimension(800, 600)); - this.workerRunning = false; - this.workerPaused = false; - - this.labeller = StringLabeller.getLabeller(this); - - initNodeHandler(); - } - - /** - * Initilisiert die Handler - * - */ - private void initNodeHandler(){ - addNodeUpdateHandler(new FixStateHandler(this.nodeVertexMapping, this.layout)); - addNodeUpdateHandler(new LabelChangeHandler(this.labeller, this.nodeVertexMapping)); - addNodeUpdateHandler(new PositionUpdateHandler(this.nodeVertexMapping, this.layout)); - addNodeUpdateHandler(new SeeAccessPointHandler(this.clientLocationMap, this.locationLocationMap)); - addNodeUpdateHandler(new NotSeeAccessPointHandler(this.clientLocationMap, this.locationLocationMap)); - addNodeUpdateHandler(new CalculationStateHandler(this.nodeVertexMapping, this.layout)); - addNodeUpdateHandler(new AccessPointHiddenStateHandler()); - } - - /** - * Den Hintergrundthread zum Berechnen der Positionen starten! ;-) - * - */ - private void start(){ - this.worker.init(); - this.workerRunning = true; - this.workerPaused = false; - } - - /** - * Sets the size of our layout. should be the same as the current map. - * @param width shoulde be the maps width. - * @param height - */ - public void setSize(int width, int height){ - this.layout.resize(new Dimension(width, height)); - } - - /** - * F\xFCgt einen neuen Knoten ein. - */ - public void insertNode(Node node){ - if (node.getClass().equals(MapNode.class)) return; - - Vertex v = addVertex(node); - if (v != null) { - if (node.isFix()) - this.layout.setFix(v); - else - this.layout.unsetFix(v); - } - - } - - public void deleteNode(Node node){ - removeVertex(node); - } - - public SpringLayout getLayout(){ - return this.layout; - } - - /** - * Reagiert auf ver\xE4nderungen in den Knoten oder im Model. - * Leitet die Anfragen an einen nodeHandler weiter. Wird vom NodeModel aufgerufen. - * - * @param node der neue oder ge\xE4nderte Knoten - * @param type der Typ des Events. (Enum nutzen)? - * @param data ---? - * @see NodeModelListener, INodeModel, NodeModel - */ - public void updateNode(Node node, int type, Object data){ - // first try if we have a handler for this event. - if (!this.nodeHandler.handleNodeUpdated(node, type, data, this)) { - if (type == NodeModelConstants.UPDATE_CLEAR) { - this.worker.suspend(); // stopGraph(); - // this.CALIBRATION_FACTOR_AP = 1.0; - // this.CALIBRATION_FACTOR_LC = 1.0; - this.clientLocationMap.clear(); - this.removeAllEdges(); - this.removeAllVertices(); - this.layout.update(); - this.nodeVertexMapping.clear(); - this.worker.unsuspend(); - } else if (type == NodeModelConstants.UPDATE_RESCAN) - this.layout.update(); - else - JungNodePlacer.log.debug("Event von typ: " + type + " ist unbekannt"); - } - } - - public Vertex findVertex(Node node){ - return this.nodeVertexMapping.get(node); - } - - /** - * Verwandelt Node in Vertex und fuegt diesen in den Graphen ein. Es wird - * keine Ruecksicht auf den Typ des Knotens genommen. Eventuelle implizite - * Kanten muss der Aufrufer erstellen. - * - * @param node - * @return - */ - private Vertex addVertex(Node node){ - if (findVertex(node) == null) { - - log.debug("Adding " + node.getDisplayName()); - - Vertex v = new DirectedSparseVertex(); - synchronized (vertexLock) { - this.worker.suspend(); - this.nodeVertexMapping.put(node, v); - v.addUserDatum(LayoutSettings.NODE_KEY, node, UserData.SHARED); - - addVertex(v); - - ((SpringLayout) this.worker.getGraphLayout()).update(); - if (node.getX() >= 0 && node.getY() >= 0) this.layout.forceMove(v, node.getX(), node.getY()); - this.worker.unsuspend(); - - } - log.debug("Added " + node.getDisplayName()); - return v; - } else { - System.err.print("Vertex exists:"); - return null; - } - - } - - /** - * - */ - public void startNodePlacer(){ - start(); - } - - /** - * - */ - public void stopNodePlacer(){ - this.worker.stop(); - - } - - /** - * - */ - public void pauseNodePlacer(boolean pause){ - if (pause && !isPaused()) { - this.worker.suspend(); - this.workerPaused = true; - } else if (!pause && isPaused()) { - this.worker.unsuspend(); - this.workerPaused = false; - - } - } - - public boolean isPaused(){ - return this.workerRunning && this.workerPaused; - } - - /** - * F\xFCgt eine gerichtete Kante von Knoten node1 zu node2 hinzu. - * - * Das Gewicht der Kante - * @param node1 - * @param node2 - * @return - */ - public IMagicEdge addEdge(Node node1, Node node2){ - if (node1 == node2) return null; - Vertex v = findVertex(node1); - Vertex w = findVertex(node2); - - return addEdge(v, w); - } - - /** - * F\xFCgt eine Jungkante hinzu. wird intern verwendet. - * - * @param v1 - * @param v2 - * @return - */ - private IMagicEdge addEdge(Vertex v1, Vertex v2){ - log.debug("Adding Edge : " + v1 + " -> " + v2); - if (v1 == v2) return null; - synchronized (edgeLock) { - Edge e = v1.findEdge(v2); - if (e != null) - return (IMagicEdge) e; - else { - JungEdge edge = new JungEdge(v1, v2); - this.worker.suspend(); // stopGraph(); - addEdge(edge); - this.layout.update(); - ((SpringLayout) this.worker.getGraphLayout()).update(); - this.worker.unsuspend(); // resumeGraph(); - - return edge; - } - - } - } - - /** - * L\xF6scht eine Kantew zwischen den beiden Knoten. - * @param node1 Quelle der Kante. - * @param node2 Ziel der Kante. - */ - public void removeEdge(Node node1, Node node2){ - Vertex v = findVertex(node1); - Vertex w = findVertex(node2); - if (v != null && w != null) { - this.worker.suspend(); - Set edges = getEdges(); - for (Object edge : edges) { - Edge e = (Edge) edge; - if (e.getIncidentVertices().contains(v) && e.getIncidentVertices().contains(w)) { - removeEdge(e); - break; - } - } - this.layout.update(); - this.worker.unsuspend(); // resumeGraph(); - } - } - - /** - * Entfernt Knoten aus dem Graph und eventuelle Kanten - * - * @param node - */ - private void removeVertex(Node node){ - Vertex v = findVertex(node); - if (v != null) { - this.worker.suspend(); - Set edges = getEdges(); - // Kein Iterator direkt auf die Sets des - // Graphen => Concurrent modification! - ArrayList list = new ArrayList(edges); - for (Object aList : list) { - Edge e = (Edge) aList; - if (e.getIncidentVertices().contains(v)) { - super.removeEdge(e); - } - } - nodeVertexMapping.remove(node); - this.labeller.removeLabel(node.getDisplayName()); - super.removeVertex(v); - this.layout.update(); - this.worker.unsuspend(); - } - } - - /** - * - * @param handler - */ - - public void addNodeUpdateHandler(NodeUpdateHandler handler){ - this.nodeHandler.addNodeUpdateHandler(handler); - - } - - public void clear(){ - stopNodePlacer(); - this.removeAllEdges(); - this.removeAllVertices(); - nodeVertexMapping.clear(); - } - -} Copied: branches/info/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java (from rev 706, trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java) =================================================================== --- branches/info/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java (rev 0) +++ branches/info/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java 2008-01-01 23:14:33 UTC (rev 708) @@ -0,0 +1,424 @@ + +package net.sf.magicmap.client.model.location.jung; + +import edu.uci.ics.jung.graph.Edge; +import edu.uci.ics.jung.graph.Vertex; +import edu.uci.ics.jung.graph.decorators.StringLabeller; +import edu.uci.ics.jung.graph.impl.DirectedSparseGraph; +import edu.uci.ics.jung.graph.impl.DirectedSparseVertex; +import edu.uci.ics.jung.utils.UserData; +import edu.uci.ics.jung.visualization.SpringLayout; +import net.sf.magicmap.client.algorithms.MagicMetric; +import net.sf.magicmap.client.algorithms.NodeMetricManager; +import net.sf.magicmap.client.algorithms.NodeModelMetric; +import net.sf.magicmap.client.model.location.INodePlacer; +import net.sf.magicmap.client.model.location.NodeUpdateHandler; +import net.sf.magicmap.client.model.location.jung.handler.*; +import net.sf.magicmap.client.model.node.*; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.awt.*; +import java.util.*; + +/** + * Dieses Model benutzt die Layoutfunktionen von Jung und einige Angepasste + * Layoutalgorithmen um die Knotenposition zu berechnen. + * + * @author Jan Friderici + * + */ +public class JungNodePlacer extends DirectedSparseGraph implements INodePlacer, NodeModelConstants { + + /** + * Logger + */ + private static final Log log = LogFactory.getLog(JungNodePlacer.class); + + /** + * Used to find the Vertex representing a node. + */ + private final Map<Node, Vertex> nodeVertexMapping = new HashMap<Node, Vertex>(); + + /** + * + */ + private final SpringLayout layout; + + /** + * Calculates the layout in a background thread. + */ + private final LayoutWorker worker; + + private boolean workerPaused; + + private boolean workerRunning; + + /** + * Werden f\xFCr die Handler ben\xF6tigt + */ + private HashMap<ClientNode, HashSet<LocationNode>> clientLocationMap; + + /** + * Werden f\xFCr die Handler ben\xF6tigt + */ + private HashMap<LocationNode, HashSet<LocationNode>> locationLocationMap; + + /** + * Werden f\xFCr die Handler ben\xF6tigt + */ + private StringLabeller labeller; + + /** + * A Factory for the NodeUpdateHandler. + * @see NodeUpdateHandler + */ + private final NodeHandlerFactory nodeHandler = new NodeHandlerFactory(); + + private final NodeMetricManager metricManager; + + private final Object edgeLock = new Object(); + private final Object vertexLock = new Object(); + + private final Map<Edge, IMagicEdge> magicEdges = new HashMap<Edge, IMagicEdge>(); + + public JungNodePlacer() { + this(new MagicMetric()); + } + + /** + * + * @return + */ + public NodeMetricManager getMetricManager(){ + return metricManager; + } + + /** + * + * @param metric the metrics to use. + */ + public JungNodePlacer(NodeModelMetric metric) { + super(); + this.metricManager = new NodeMetricManager(metric); + this.clientLocationMap = new HashMap<ClientNode, HashSet<LocationNode>>(); + this.locationLocationMap = new HashMap<LocationNode, HashSet<LocationNode>>(); + this.layout = new MagicLayout(this, metricManager); + this.worker = new LayoutWorker(this.layout, new Dimension(800, 600)); + this.workerRunning = false; + this.workerPaused = false; + + this.labeller = StringLabeller.getLabeller(this); + + initNodeHandler(); + } + + /** + * Initilisiert die Handler + * + */ + private void initNodeHandler(){ + addNodeUpdateHandler(new FixStateHandler(this.nodeVertexMapping, this.layout)); + addNodeUpdateHandler(new LabelChangeHandler(this.labeller, this.nodeVertexMapping)); + addNodeUpdateHandler(new PositionUpdateHandler(this.nodeVertexMapping, this.layout)); + addNodeUpdateHandler(new SeeAccessPointHandler(this.clientLocationMap, this.locationLocationMap)); + addNodeUpdateHandler(new NotSeeAccessPointHandler(this.clientLocationMap, this.locationLocationMap)); + addNodeUpdateHandler(new CalculationStateHandler(this.nodeVertexMapping, this.layout)); + addNodeUpdateHandler(new AccessPointHiddenStateHandler()); + } + + /** + * Den Hintergrundthread zum Berechnen der Positionen starten! ;-) + * + */ + private void start(){ + this.worker.init(); + this.workerRunning = true; + this.workerPaused = false; + } + + /** + * Sets the size of our layout. should be the same as the current map. + * @param width shoulde be the maps width. + * @param height + */ + public void setSize(int width, int height){ + this.layout.resize(new Dimension(width, height)); + } + + /** + * F\xFCgt einen neuen Knoten ein. + */ + public void insertNode(Node node){ + if (node.getClass().equals(MapNode.class)) return; + + Vertex v = addVertex(node); + if (v != null) { + if (node.isFix()) + this.layout.setFix(v); + else + this.layout.unsetFix(v); + } + + } + + /** + * + * @param node + */ + public void deleteNode(Node node){ + removeVertex(node); + } + + /** + * + * @return + */ + public SpringLayout getLayout(){ + return this.layout; + } + + /** + * Reagiert auf ver\xE4nderungen in den Knoten oder im Model. + * Leitet die Anfragen an einen nodeHandler weiter. Wird vom NodeModel aufgerufen. + * + * @param node der neue oder ge\xE4nderte Knoten + * @param type der Typ des Events. (Enum nutzen)? + * @param data ---? + * @see net.sf.magicmap.client.interfaces.NodeModelListener , INodeModel, NodeModel + */ + public void updateNode(Node node, int type, Object data){ + // first try if we have a handler for this event. + if (!this.nodeHandler.handleNodeUpdated(node, type, data, this)) { + if (type == NodeModelConstants.UPDATE_CLEAR) { + this.worker.suspend(); // stopGraph(); + // this.CALIBRATION_FACTOR_AP = 1.0; + // this.CALIBRATION_FACTOR_LC = 1.0; + this.clientLocationMap.clear(); + this.removeAllEdges(); + this.removeAllVertices(); + this.layout.update(); + this.nodeVertexMapping.clear(); + this.worker.unsuspend(); + } else if (type == NodeModelConstants.UPDATE_RESCAN) + this.layout.update(); + else + JungNodePlacer.log.debug("Event von typ: " + type + " ist unbekannt"); + } + } + + /** + * + * @param node + * @return + */ + public Vertex findVertex(Node node){ + return this.nodeVertexMapping.get(node); + } + + /** + * Verwandelt Node in Vertex und fuegt diesen in den Graphen ein. Es wird + * keine Ruecksicht auf den Typ des Knotens genommen. Eventuelle implizite + * Kanten muss der Aufrufer erstellen. + * + * @param node + * @return + */ + private Vertex addVertex(Node node){ + if (findVertex(node) == null) { + + log.debug("Adding " + node.getDisplayName()); + + Vertex v = new DirectedSparseVertex(); + synchronized (vertexLock) { + this.worker.suspend(); + this.nodeVertexMapping.put(node, v); + v.addUserDatum(LayoutSettings.NODE_KEY, node, UserData.SHARED); + + addVertex(v); + + ((SpringLayout) this.worker.getGraphLayout()).update(); + if (node.getX() >= 0 && node.getY() >= 0) this.layout.forceMove(v, node.getX(), node.getY()); + this.worker.unsuspend(); + + } + log.debug("Added " + node.getDisplayName()); + return v; + } else { + System.err.print("Vertex exists:"); + return null; + } + + } + + /** + * + */ + public void startNodePlacer(){ + start(); + } + + /** + * + */ + public void stopNodePlacer(){ + this.worker.stop(); + + } + + /** + * + */ + public void pauseNodePlacer(boolean pause){ + if (pause && !isPaused()) { + this.worker.suspend(); + this.workerPaused = true; + } else if (!pause && isPaused()) { + this.worker.unsuspend(); + this.workerPaused = false; + + } + } + + public boolean isPaused(){ + return this.workerRunning && this.workerPaused; + } + + /** + * F\xFCgt eine gerichtete Kante von Knoten node1 zu node2 hinzu. + * + * Das Gewicht der Kante + * @param node1 first node. + * @param node2 second node. + * @return a new or old edge between the two nodes. + */ + public IMagicEdge addEdge(Node node1, Node node2){ + if (node1 == node2) return null; + Vertex v = findVertex(node1); + Vertex w = findVertex(node2); + + return addEdge(v, w); + } + + /** + * F\xFCgt eine Jungkante hinzu. wird intern verwendet. + * + * @param v1 first vertex + * @param v2 second vertex. + * @return + */ + private IMagicEdge addEdge(Vertex v1, Vertex v2){ + log.debug("Adding Edge : " + v1 + " -> " + v2); + if (v1 == v2) return null; + synchronized (edgeLock) { + Edge e = v1.findEdge(v2); + if (e != null) + return (IMagicEdge) e; + else { + JungEdge edge = new JungEdge(v1, v2); + this.worker.suspend(); // stopGraph(); + addEdge(edge); + this.layout.update(); + ((SpringLayout) this.worker.getGraphLayout()).update(); + this.worker.unsuspend(); // resumeGraph(); + + magicEdges.put(e,edge); + return edge; + } + + } + } + + /** + * @see INodePlacer + * @param n1 first node. + * @param n2 second node. + * @return an JungEdge or null. + */ + public JungEdge getEdge(Node n1, Node n2){ + Vertex v = findVertex(n1); + Vertex w = findVertex(n2); + if (v != null && w != null) { + return (JungEdge)v.findEdge(w); + } + else return null; + + } + + /** + * L\xF6scht eine Kantew zwischen den beiden Knoten. + * @param node1 Quelle der Kante. + * @param node2 Ziel der Kante. + */ + public void removeEdge(Node node1, Node node2){ + Vertex v = findVertex(node1); + Vertex w = findVertex(node2); + if (v != null && w != null) { + this.worker.suspend(); + Set edges = getEdges(); + for (Object edge : edges) { + Edge e = (Edge) edge; + if (e.getIncidentVertices().contains(v) && e.getIncidentVertices().contains(w)) { + removeEdge(e); + magicEdges.remove(e); + break; + } + } + this.layout.update(); + this.worker.unsuspend(); // resumeGraph(); + } + } + + /** + * Entfernt Knoten aus dem Graph und eventuelle Kanten + * + * @param node + */ + private void removeVertex(Node node){ + Vertex v = findVertex(node); + if (v != null) { + this.worker.suspend(); + // Kein Iterator direkt auf die Sets des + // Graphen => Concurrent modification! + ArrayList<Edge> list = new ArrayList<Edge>(getEdges()); + for (Edge e : list) { + if (e.getIncidentVertices().contains(v)) { + super.removeEdge(e); + } + } + nodeVertexMapping.remove(node); + this.labeller.removeLabel(node.getDisplayName()); + super.removeVertex(v); + this.layout.update(); + this.worker.unsuspend(); + } + } + + /** + * + * @param handler + */ + + public void addNodeUpdateHandler(NodeUpdateHandler handler){ + this.nodeHandler.addNodeUpdateHandler(handler); + + } + + public void clear(){ + stopNodePlacer(); + this.removeAllEdges(); + this.removeAllVertices(); + nodeVertexMapping.clear(); + } + + /** + * + * @return + */ + public Iterator<IMagicEdge> iterator() { + synchronized (edgeLock) { + ArrayList<IMagicEdge> edgeCopy = new ArrayList<IMagicEdge>(magicEdges.values()); + return edgeCopy.iterator(); + } + } +} Deleted: branches/info/magicmapclient/src/net/sf/magicmap/client/model/node/IMagicEdge.java =================================================================== --- trunk/magicmapclient/src/net/sf/magicmap/client/model/node/IMagicEdge.java 2007-12-21 12:06:47 UTC (rev 704) +++ branches/info/magicmapclient/src/net/sf/magicmap/client/model/node/IMagicEdge.java 2008-01-01 23:14:33 UTC (rev 708) @@ -1,18 +0,0 @@ -package net.sf.magicmap.client.model.node; - - -/** - * An edge connects two Nodes. - * - * - * @author Jan Friderici - * - */ -public interface IMagicEdge { - public Node getSourceNode(); - public Node getTargetNode(); - - public enum EdgeType{ - NONE, PARENT_EDGE, DISTANCE_EDGE; - } -} Copied: branches/info/magicmapclient/src/net/sf/magicmap/client/model/node/IMagicEdge.java (from rev 705, trunk/magicmapclient/src/net/sf/magicmap/client/model/node/IMagicEdge.java) =================================================================== --- branches/info/magicmapclient/src/net/sf/magicmap/client/model/node/IMagicEdge.java (rev 0) +++ branches/info/magicmapclient/src/net/sf/magicmap/client/model/node/IMagicEdge.java 2008-01-01 23:14:33 UTC (rev 708) @@ -0,0 +1,31 @@ +package net.sf.magicmap.client.model.node; + + +/** + * An edge connects two Nodes. + * + * + * @author Jan Friderici + * + */ +public interface IMagicEdge { + + /** + * + * @return + */ + Node getSourceNode(); + + /** + * + * @return + */ + Node getTargetNode(); + + /** + * + */ + public enum EdgeType{ + NONE, PARENT_EDGE, DISTANCE_EDGE; + } +} Modified: branches/info/magicmapclient/src/net/sf/magicmap/client/model/node/INode.java =================================================================== --- trunk/magicmapclient/src/net/sf/magicmap/client/model/node/INode.java 2007-12-21 12:06:47 UTC (rev 704) +++ branches/info/magicmapclient/src/net/sf/magicmap/client/model/node/INode.java 2008-01-01 23:14:33 UTC (rev 708) @@ -3,15 +3,19 @@ import java.util.List; /** - * Created by IntelliJ IDEA. - * User: Jan - * Date: 08.02.2007 - * Time: 09:22:33 - * To change this template use File | Settings | File Templates. + * <p> + * Interface for all nodes. + * </p> + * @author Jan Friderici */ public interface INode { - String getDisplayName(); + /** + * + * @return + */ + String getDisplayName(); + void setDisplayName(String displayName); boolean isUpdate(); Modified: branches/info/magicmapclient/src/net/sf/magicmap/client/model/node/INodeModel.java =================================================================== --- trunk/magicmapclient/src/net/sf/magicmap/client/model/node/INodeModel.java 2007-12-21 12:06:47 UTC (rev 704) +++ branches/info/magicmapclient/src/net/sf/magicmap/client/model/node/INodeModel.java 2008-01-01 23:14:33 UTC (rev 708) @@ -24,13 +24,13 @@ * * @param node the node to add */ - public abstract void addNode(Node node); + void addNode(Node node); /** * Remove a node * @param node removes a node from the model */ - public abstract void removeNode(Node node); + void removeNode(Node node); /** * Notifies all listeners that the state of a given node @@ -42,7 +42,7 @@ * @param data new data, may be null. * @see NodeModelListener */ - public abstract void updateNode(Node node, int type, Object data); + void updateNode(Node node, int type, Object data); /** * Aktualisiert den Hash-Schl\xFCssel f\xFCr einen Knoten. @@ -51,7 +51,7 @@ * @param node Knoten der aktualisiert werden soll * @param name Alter Hash-Wert */ - public abstract void rehashNode(Node node, String name); + void rehashNode(Node node, String name); /** * returns all neighbours for the given node. @@ -59,7 +59,7 @@ * @param node the node * @return all neighbours of the given node. */ - public abstract ArrayList<? extends Node> findNeighbors(Node node); + ArrayList<? extends Node> findNeighbors(Node node); /** * what for? @@ -67,27 +67,27 @@ * @return */ @Deprecated - public abstract ArrayList<? extends ... [truncated message content] |