Author: scooter
Date: 2010-09-24 16:23:29 -0700 (Fri, 24 Sep 2010)
New Revision: 22055

Modified:
   
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/view/NestedNetworkView.java
   
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/view/ViewUtils.java
Log:
Update network network handling


Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/view/NestedNetworkView.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/view/NestedNetworkView.java
        2010-09-24 23:22:09 UTC (rev 22054)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/view/NestedNetworkView.java
        2010-09-24 23:23:29 UTC (rev 22055)
@@ -48,6 +48,9 @@
                // Get the network
                CyNetwork nn = group.getGraphPerspective();
 
+               // Give it a reasonable title
+               nn.setTitle(group.toString());
+
                // Create the view
                CyNetworkView nnView = Cytoscape.createNetworkView(nn, 
group.toString());
 
@@ -57,17 +60,26 @@
                // Move the nodes around
                Dimension boundingBox = ViewUtils.restoreNodes(group, nn, 
nnView, position, Cytoscape.getNodeAttributes(), null);
 
+               System.out.println("Bounding box for "+group.toString()+" is 
"+boundingBox.getWidth()+"x"+boundingBox.getHeight());
+
                // Add it to the network map as a child of the group's network
                CyNetwork network = group.getNetwork();
+
+               Cytoscape.addNetwork(nn, group.toString(), network, false);
+
+/*
                // We do this by firing a NETWORK_CREATED event with the parent 
network as the old value
                // and our new network as the new value
-               Cytoscape.firePropertyChange(Cytoscape.NETWORK_CREATED, 
nn.getIdentifier(), network.getIdentifier());
+               Cytoscape.firePropertyChange(Cytoscape.NETWORK_CREATED, 
network.getIdentifier(), nn.getIdentifier());
+*/
 
                // Set it as a nested network
                group.getGroupNode().setNestedNetwork(nn);
 
                // Update the size of our group node to match the bounding box
-               ViewUtils.setNodeSize(group.getGroupNode(), view, boundingBox);
+               // Actually, this doesn't work.  If our bounding box is not 
square
+               // the resulting network image in the node is really skewed
+               // ViewUtils.setNodeSize(group.getGroupNode(), view, 
boundingBox);
 
                // Remember that we did it
                nnMap.put(group, nnView);
@@ -89,6 +101,6 @@
                Cytoscape.destroyNetworkView(nnView);
 
                // Remove the graph perspective from our list
-               Cytoscape.firePropertyChange(Cytoscape.NETWORK_DESTROYED, 
group.getGraphPerspective().getIdentifier(), null);
+               Cytoscape.firePropertyChange(Cytoscape.NETWORK_DESTROYED, null, 
group.getGraphPerspective().getIdentifier());
        }
 }

Modified: 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/view/ViewUtils.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/view/ViewUtils.java
        2010-09-24 23:22:09 UTC (rev 22054)
+++ 
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/view/ViewUtils.java
        2010-09-24 23:23:29 UTC (rev 22055)
@@ -206,11 +206,19 @@
                        Dimension offset = getAttributes(node, nodeAttributes);
                        // offset might be null if we've just added the node
                        if (offset != null) {
+                               System.out.println("Offset for 
"+node.toString()+" is "+offset.getWidth()+"x"+offset.getHeight());
                                net.restoreNode(node);
-                               minX = Math.min(minX, offset.getWidth());
-                               maxX = Math.max(maxX, offset.getWidth());
-                               minY = Math.min(minY, offset.getHeight());
-                               maxY = Math.max(maxY, offset.getHeight());
+                               NodeView nView = view.getNodeView(node);
+                               double nodeWidth = 0.0;
+                               double nodeHeight = 0.0;
+                               if (nView != null) {
+                                       nodeWidth = nView.getWidth()/2;
+                                       nodeHeight = nView.getHeight()/2;
+                               }
+                               minX = Math.min(minX, 
offset.getWidth()-nodeWidth);
+                               maxX = Math.max(maxX, 
offset.getWidth()+nodeWidth);
+                               minY = Math.min(minY, 
offset.getHeight()-nodeHeight);
+                               maxY = Math.max(maxY, 
offset.getHeight()+nodeHeight);
                                offset.setSize(centerX-offset.getWidth(), 
centerY-offset.getHeight());
                                setPosition(node, view, offset);
                        }

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to