Author: scooter
Date: 2011-06-22 19:02:50 -0700 (Wed, 22 Jun 2011)
New Revision: 25894
Modified:
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/MetaNodeGroupViewer.java
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNode.java
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNodeManager.java
Log:
Do a better job of handling metanode creation when a node already exists. We
may need
to handle existing edges.
Modified:
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/MetaNodeGroupViewer.java
===================================================================
---
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/MetaNodeGroupViewer.java
2011-06-23 00:40:52 UTC (rev 25893)
+++
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/MetaNodeGroupViewer.java
2011-06-23 02:02:50 UTC (rev 25894)
@@ -37,6 +37,7 @@
import java.util.List;
import java.util.Map;
+import cytoscape.CyEdge;
import cytoscape.CyNetwork;
import cytoscape.CyNode;
import cytoscape.Cytoscape;
@@ -143,14 +144,14 @@
* @param group the CyGroup that was just created
*/
public void groupCreated(CyGroup group) {
- // logger.debug("groupCreated("+group+")");
+ logger.debug("groupCreated("+group+")");
if (MetaNodeManager.getMetaNode(group) == null) {
MetaNode newNode =
MetaNodeManager.createMetaNode(group, false);
}
// Update the attributes of the group node
logger.info("updating group panel for new group: "+group);
updateGroupPanel();
- // logger.debug("done");
+ logger.debug("done");
}
/**
@@ -165,31 +166,24 @@
* @param view the CyNetworkView that is being created
*/
public void groupCreated(CyGroup group, CyNetworkView myview) {
- // logger.debug("groupCreated("+group+", view)");
+ logger.debug("groupCreated("+group+", view)");
if (MetaNodeManager.getMetaNode(group) == null) {
// Have we already been here?
if (MetaNodeManager.getMetaNodeCount() == 0) {
- initializeGroups(myview);
- return;
- }
- MetaNode newNode =
MetaNodeManager.createMetaNode(group, true);
-
- // We need to be a little tricky if we are restoring a
collapsed
- // metaNode from XGMML. We essentially need to
"recollapse" it,
- // but we need to save the old hints
- if (group.getState() == MetaNodePlugin2.COLLAPSED) {
- // We are, we need to "fix up" the network
- newNode.recollapse(myview);
+ // No, get all of our groups and create
metanodes for them
+ List<CyGroup> metaGroups =
CyGroupManager.getGroupList(this);
+ if (metaGroups != null) {
+ for (CyGroup mg: metaGroups) {
+ createMetaNode(mg, myview);
+ }
+ }
} else {
- CyNetwork network = myview.getNetwork();
- network.hideNode(group.getGroupNode());
+ // Yes, just handle this group
+ createMetaNode(group, myview);
}
}
-
- // logger.debug("registering");
logger.info("updating group panel for new group: "+group);
updateGroupPanel();
- // logger.debug("done");
}
/**
@@ -320,23 +314,31 @@
return;
}
- // This method is called on the first notification that we have a group.
- private void initializeGroups(CyNetworkView view) {
- List<CyGroup> metaGroups = CyGroupManager.getGroupList(this);
- if (metaGroups != null) {
- for (CyGroup group: metaGroups) {
- // Create the metanode
- MetaNode newNode =
MetaNodeManager.createMetaNode(group, true);
- if (group.getState() ==
MetaNodePlugin2.COLLAPSED) {
- newNode.recollapse(view);
- } else {
- CyNetwork network = view.getNetwork();
- network.hideNode(group.getGroupNode());
- }
+ // This method is called to create a single metanode
+ private void createMetaNode(CyGroup group, CyNetworkView view) {
+ // Create the metanode
+ MetaNode newNode = MetaNodeManager.createMetaNode(group, true);
+
+ // Get the group node
+ CyNode groupNode = group.getGroupNode();
+ // Grab any edges it currently has
+ List edgeList =
view.getNetwork().getAdjacentEdgesList(groupNode, true, true, true);
+ // Add them to the "metaedge" list, if they are not already
+ if (edgeList != null && edgeList.size() > 0) {
+ for (Object e: edgeList) {
+ newNode.addMetaEdge((CyEdge)e);
}
}
- logger.info("updating group panel");
- updateGroupPanel();
+
+ // We need to be a little tricky if we are restoring a collapsed
+ // metaNode from XGMML. We essentially need to "recollapse" it,
+ // but we need to save the old hints
+ if (group.getState() == MetaNodePlugin2.COLLAPSED) {
+ newNode.recollapse(view);
+ } else {
+ CyNetwork network = view.getNetwork();
+ network.hideNode(group.getGroupNode());
+ }
}
/**
Modified:
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNode.java
===================================================================
---
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNode.java
2011-06-23 00:40:52 UTC (rev 25893)
+++
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNode.java
2011-06-23 02:02:50 UTC (rev 25894)
@@ -106,7 +106,7 @@
metaGroup = group;
logger = CyLogger.getLogger(MetaNode.class);
- // logger.debug("Creating new metanode:
"+group.getGroupNode()+", ignoreMetaEdges = "+ignoreMetaEdges);
+ logger.debug("Creating new metanode: "+group.getGroupNode()+",
ignoreMetaEdges = "+ignoreMetaEdges);
// This method does most of the work.
updateMetaEdges(ignoreMetaEdges);
@@ -125,7 +125,7 @@
* @param node the CyNode that was added
*/
public void nodeAdded(CyNode node) {
- // logger.debug("node added "+metaGroup);
+ logger.debug("node "+node+" added to "+metaGroup);
// Recreate our meta-edges. There might be more efficient ways
of doing this
// than recreating everything, but the performance of
updateMetaEdges isn't too
// bad, and the complexity of managing the state necessary to
update meta-edges
@@ -150,7 +150,7 @@
* @param node the CyNode that was removed
*/
public void nodeRemoved(CyNode node) {
- // logger.debug("node removed "+metaGroup);
+ logger.debug("node removed "+metaGroup);
// First step, we need to remove any new meta-edges
updateMetaEdges(false);
// Now, remove our member edge (if there is one)
@@ -167,7 +167,7 @@
* @param view the view to use
*/
public void recollapse(CyNetworkView view) {
- // logger.debug("recollapse "+metaGroup);
+ logger.debug("recollapse "+metaGroup);
if (view == null)
view =
Cytoscape.getNetworkView(metaGroup.getNetwork().getIdentifier());
else
@@ -184,7 +184,7 @@
* @param updateNetwork if 'true', actually update the network
*/
public void collapse(CyNetworkView view) {
- // logger.debug("collapse "+metaGroup+": isCollapsed =
"+isCollapsed()+" isHidden = "+isHidden()+" state = "+metaGroup.getState());
+ logger.debug("collapse "+metaGroup+": isCollapsed =
"+isCollapsed()+" isHidden = "+isHidden()+" state = "+metaGroup.getState());
if (isCollapsed())
return;
@@ -216,7 +216,7 @@
* @param update update the display?
*/
public void expand(CyNetworkView view) {
- // logger.debug("expand "+metaGroup+": isCollapsed =
"+isCollapsed()+" isHidden = "+isHidden()+" state = "+metaGroup.getState());
+ logger.debug("expand "+metaGroup+": isCollapsed =
"+isCollapsed()+" isHidden = "+isHidden()+" state = "+metaGroup.getState());
if (!isCollapsed())
return;
@@ -525,13 +525,20 @@
continue;
}
+ CyNode groupNode = metaGroup.getGroupNode();
+
+ // If the edge is already on our group node, don't
create a metaedge for it
+ if (edge.getSource() == groupNode || edge.getTarget()
== groupNode)
+ continue;
+
+
// Create the meta-edge to the external node, but
maintain the directionality of the
// original edge
CyEdge metaEdge = null;
if (isIncoming(edge))
- metaEdge = createMetaEdge(edge.getIdentifier(),
node, metaGroup.getGroupNode());
+ metaEdge = createMetaEdge(edge.getIdentifier(),
node, groupNode);
else
- metaEdge = createMetaEdge(edge.getIdentifier(),
metaGroup.getGroupNode(), node);
+ metaEdge = createMetaEdge(edge.getIdentifier(),
groupNode, node);
MetaNode metaPartner =
MetaNodeManager.getMetaNode(node);
if (metaPartner != null &&
metaPartner.metaGroup.getNetwork().equals(metaGroup.getNetwork())) {
Modified:
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNodeManager.java
===================================================================
---
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNodeManager.java
2011-06-23 00:40:52 UTC (rev 25893)
+++
csplugins/trunk/ucsf/scooter/metaNodePlugin2/src/metaNodePlugin2/model/MetaNodeManager.java
2011-06-23 02:02:50 UTC (rev 25894)
@@ -34,6 +34,7 @@
import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import cytoscape.CyNetwork;
@@ -105,7 +106,11 @@
*/
static public MetaNode createMetaNode(CyGroup metaGroup, boolean
ignoreMetaEdges) {
+ if (metaGroup.getNetwork() == null) {
+ metaGroup.setNetwork(Cytoscape.getCurrentNetwork(),
false);
+ }
MetaNode mn = new MetaNode(metaGroup, ignoreMetaEdges);
+
metaMap.put(metaGroup.getGroupNode(), mn);
mn.setUseNestedNetworks(useNestedNetworksDefault);
mn.setHideMetaNode(hideMetanodeDefault);
@@ -113,9 +118,6 @@
mn.setChartType(chartTypeDefault);
mn.setNodeChartAttribute(nodeChartAttributeDefault);
mn.setAttributeManager(new
AttributeManager(defaultAttributeManager));
- if (metaGroup.getNetwork() == null) {
- metaGroup.setNetwork(Cytoscape.getCurrentNetwork(),
false);
- }
return mn;
}
--
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.