use of org.cytoscape.group.CyGroupSettingsManager.GroupViewType in project cytoscape-impl by cytoscape.
the class GroupViewCollapseHandler method handleEvent.
/**
* This is called when the user changes the view type for a particular
* group. We want to respond and change the visualization right away,
* from the old visual type to the new visual type.
*/
@Override
public void handleEvent(GroupViewTypeChangedEvent e) {
getServices();
GroupViewType oldType = e.getOldType();
GroupViewType newType = e.getNewType();
CyGroup group = e.getGroup();
if (group == null || oldType.equals(newType))
return;
if (oldType == GroupViewType.COMPOUND || oldType == GroupViewType.SINGLENODE)
removeCompoundNode(group);
else if (oldType == GroupViewType.SHOWGROUPNODE)
((CyGroupImpl) group).removeMemberEdges();
for (CyNetwork net : group.getNetworkSet()) {
// Careful -- the network set includes the root
if (net.equals(group.getRootNetwork()))
continue;
// necessary to make sure we can update other settings.
if (newType == GroupViewType.NONE) {
((CyGroupImpl) group).setGroupNodeShown(net, false);
// If we're expanded and the group node is shown, remove it
if (!group.isCollapsed(net) && net.containsNode(group.getGroupNode())) {
group.collapse(net);
// We need to do this again because our group node was "noticed" when we
// collapsed. If we remove the group node ourselves, it messes up the
// restyling
((CyGroupImpl) group).setGroupNodeShown(net, false);
}
} else {
// the group is appropriately restyled
if (!group.isCollapsed(net))
group.collapse(net);
group.expand(net);
}
}
}
Aggregations