Search in sources :

Example 6 with GroupViewType

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);
        }
    }
}
Also used : GroupViewType(org.cytoscape.group.CyGroupSettingsManager.GroupViewType) CyGroup(org.cytoscape.group.CyGroup) CyGroupImpl(org.cytoscape.group.internal.CyGroupImpl) CyNetwork(org.cytoscape.model.CyNetwork)

Aggregations

CyGroup (org.cytoscape.group.CyGroup)6 GroupViewType (org.cytoscape.group.CyGroupSettingsManager.GroupViewType)6 CyNetwork (org.cytoscape.model.CyNetwork)6 CyGroupImpl (org.cytoscape.group.internal.CyGroupImpl)4 CyNetworkView (org.cytoscape.view.model.CyNetworkView)4 CyNode (org.cytoscape.model.CyNode)3 Dimension (java.awt.Dimension)2 GroupCollapsedEvent (org.cytoscape.group.events.GroupCollapsedEvent)2 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)2 CyEventHelper (org.cytoscape.event.CyEventHelper)1 CyEdge (org.cytoscape.model.CyEdge)1 CyRow (org.cytoscape.model.CyRow)1 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)1 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)1