Author: scooter
Date: 2012-09-07 14:48:13 -0700 (Fri, 07 Sep 2012)
New Revision: 30336
Modified:
core3/impl/trunk/group-impl/src/main/java/org/cytoscape/group/internal/CyGroupImpl.java
Log:
Add special case to handle XGMML insertion of external edges.
Modified:
core3/impl/trunk/group-impl/src/main/java/org/cytoscape/group/internal/CyGroupImpl.java
===================================================================
---
core3/impl/trunk/group-impl/src/main/java/org/cytoscape/group/internal/CyGroupImpl.java
2012-09-07 17:27:16 UTC (rev 30335)
+++
core3/impl/trunk/group-impl/src/main/java/org/cytoscape/group/internal/CyGroupImpl.java
2012-09-07 21:48:13 UTC (rev 30336)
@@ -263,16 +263,20 @@
*/
@Override
public synchronized void addEdges(List<CyEdge> edges) {
+ boolean updateMeta = false;
for (CyEdge edge: edges) {
CyNode source = edge.getSource();
CyNode target = edge.getTarget();
if(getGroupNetwork().containsNode(source) &&
getGroupNetwork().containsNode(target))
getGroupNetwork().addEdge(edge);
- else if (getGroupNetwork().containsNode(source) ||
getGroupNetwork().containsNode(target))
+ else if (getGroupNetwork().containsNode(source) ||
getGroupNetwork().containsNode(target)) {
externalEdges.add(edge);
- else
+ updateMeta = true;
+ } else
throwIllegalArgumentException("Attempted to add
an edge that has no node in the group");
}
+ if (updateMeta)
+ updateMetaEdges(true);
cyEventHelper.fireEvent(new
GroupEdgesAddedEvent(CyGroupImpl.this, edges));
}
@@ -567,6 +571,17 @@
if (edge.getSource() == groupNode || edge.getTarget()
== groupNode)
continue;
+ // If our group node already points to this node, and
we're collapsed, we may
+ // be adding a new edge from the XGMML reader. Not a
clean special case,
+ // but there you have it...
+ if (rootNetwork.containsEdge(edge.getSource(),
groupNode)
+ && metaAlreadyExists(edge.getSource(),
groupNode))
+ continue;
+
+ if (rootNetwork.containsEdge(groupNode,
edge.getTarget())
+ && metaAlreadyExists(groupNode,
edge.getTarget()))
+ continue;
+
// Create the meta-edge to the external node, but
maintain the directionality
// of the original edge
CyEdge metaEdge = createMetaEdge(edge, node, groupNode);
@@ -744,4 +759,14 @@
}
groupRow.set(DESCENDENTS_ATTR, nDescendents);
}
+
+ public boolean metaAlreadyExists(CyNode source, CyNode target) {
+ List<CyEdge> edges = rootNetwork.getConnectingEdgeList(source,
target, CyEdge.Type.OUTGOING);
+ for (CyEdge groupEdge: edges) {
+ if (isMeta(groupEdge)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
--
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.