Author: scooter
Date: 2012-07-19 19:04:26 -0700 (Thu, 19 Jul 2012)
New Revision: 29935
Modified:
core3/impl/trunk/group-view-impl/src/main/java/org/cytoscape/group/view/internal/GroupViewCollapseHandler.java
Log:
Add some sanity checking and testing
Modified:
core3/impl/trunk/group-view-impl/src/main/java/org/cytoscape/group/view/internal/GroupViewCollapseHandler.java
===================================================================
---
core3/impl/trunk/group-view-impl/src/main/java/org/cytoscape/group/view/internal/GroupViewCollapseHandler.java
2012-07-20 02:03:42 UTC (rev 29934)
+++
core3/impl/trunk/group-view-impl/src/main/java/org/cytoscape/group/view/internal/GroupViewCollapseHandler.java
2012-07-20 02:04:26 UTC (rev 29935)
@@ -108,21 +108,26 @@
CyNetworkView view = null;
if(views.size() != 0)
view = views.iterator().next();
+
+ if (view == null)
+ return;
if (e.collapsing()) {
// Calculate the center position of all of the
// member nodes
Dimension center = calculateCenter(view,
group.getNodeList());
- // Save it in the groupNode attribute
- updateGroupLocation(rootNetwork, group.getGroupNode(),
center);
+ if (center != null) {
+ // Save it in the groupNode attribute
+ updateGroupLocation(rootNetwork,
group.getGroupNode(), center);
- // For each member node,
- // calculate the offset for each member node from
the center
- // save it in the node's attribute
- for (CyNode node: group.getNodeList()) {
- Dimension offset = calculateOffset(center,
view, node);
- updateNodeOffset(rootNetwork, node, offset);
+ // For each member node,
+ // calculate the offset for each member
node from the center
+ // save it in the node's attribute
+ for (CyNode node: group.getNodeList()) {
+ Dimension offset =
calculateOffset(center, view, node);
+ updateNodeOffset(rootNetwork, node,
offset);
+ }
}
} else {
// Get the current position of the groupNode
@@ -141,6 +146,9 @@
CyNetworkView view = null;
if(views.size() != 0)
view = views.iterator().next();
+
+ if (view == null)
+ return;
CyRootNetwork rootNetwork = group.getRootNetwork();
VisualStyle viewStyle = cyStyleManager.getVisualStyle(view);
@@ -193,6 +201,7 @@
for (CyNode node: nodeList) {
View<CyNode>nView = view.getNodeView(node);
+ if (nView == null) continue;
double x = nView.getVisualProperty(xLoc);
double y = nView.getVisualProperty(yLoc);
xCenter += (nView.getVisualProperty(xLoc)) /
nodeList.size();
--
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.