svn commit: r14658 - trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2008-05-07 15:41:40-0700
New Revision: 14658

Modified:
   trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java

Log:
If FigNode is a FigEdgePort then make sure port is the same

Modified: trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java?view=diff&rev=14658&p1=trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java&p2=trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java&r1=14657&r2=14658
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java	2008-05-07 15:41:40-0700
@@ -208,7 +208,7 @@
 
         setCommonAttrs(f, attrList);
 
-        String href = attrList.getValue("href");
+        final String href = attrList.getValue("href");
         if (href != null && !href.equals("")) {
             Object modelElement = findOwner(href);
             if (modelElement == null) {
@@ -329,9 +329,6 @@
             EdgeData edgeData = (EdgeData) it.next();
             FigEdge edge = edgeData.getFigEdge();
             
-            LOG.info("Connecting nodes for " + edge);
-
-            
             Fig sourcePortFig = null;
             Fig destPortFig = null;
             FigNode sourceFigNode = null;
@@ -342,6 +339,14 @@
             sourceFigNode = getFigNode(edgeData.getSourceFigNodeId());
             destFigNode = getFigNode(edgeData.getDestFigNodeId());
             
+            if (sourceFigNode instanceof FigEdgePort) {
+                sourcePortFig = sourceFigNode;
+            }
+            
+            if (destFigNode instanceof FigEdgePort) {
+                destPortFig = destFigNode;
+            }
+            
             if (sourcePortFig == null && sourceFigNode != null) {
                 sourcePortFig = getPortFig(sourceFigNode);
             }
@@ -374,7 +379,6 @@
         // positions instead.
         for (Object edge : d.getLayer().getContentsEdgesOnly()) {
             FigEdge figEdge = (FigEdge) edge;
-            LOG.info("Computing route for for " + edge);
             figEdge.computeRouteImpl();
         }
     }
@@ -408,29 +412,30 @@
      *              if the figId supplied is not of a FigNode
      */
     private FigNode getFigNode(String figId) throws IllegalStateException {
-        if (figId.indexOf('.') < 0) {
+        if (figId.contains(".")) {
+            // If the id does not look like a top-level Fig then we can assume
+            // that this is an id of a FigEdgePort inside some FigEdge.
+            // So extract the FigEdgePort from the FigEdge and return that as
+            // the FigNode.
+            figId = figId.substring(0, figId.indexOf('.'));
+            FigEdgeModelElement edge = (FigEdgeModelElement) findFig(figId);
+            if (edge == null) {
+                throw new IllegalStateException(
+                        "Can't find a FigNode with id " + figId);
+            }
+            edge.makeEdgePort();
+            return edge.getEdgePort();
+        } else {
             // If there is no dot then this must be a top level Fig and can be
             // assumed to be a FigNode.
             Fig f = findFig(figId);
             if (f instanceof FigNode) {
                 return (FigNode) f;
             } else {
-        	LOG.error("FigID " + figId + " is not a node, edge ignored");
+                LOG.error("FigID " + figId + " is not a node, edge ignored");
                 return null;
             }
         }
-        // If the id does not look like a top-level Fig then we can assume that
-        // this is an id of a FigEdgePort inside some FigEdge.
-        // So extract the FigEdgePort from the FigEdge and return that as
-        // the FigNode.
-        figId = figId.substring(0, figId.indexOf('.'));
-        FigEdgeModelElement edge = (FigEdgeModelElement) findFig(figId);
-        if (edge == null) {
-            throw new IllegalStateException(
-                    "Can't find a FigNode with id " + figId);
-        }
-        edge.makeEdgePort();
-        return edge.getEdgePort();
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.