Search in sources :

Example 16 with CyGroup

use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.

the class GroupViewCollapseHandler method handleEvent.

/**
 * If a group is destroyed, and it's a compound node, we need to fix up a
 * bunch of things.
 */
@Override
public void handleEvent(GroupAboutToBeDestroyedEvent e) {
    getServices();
    CyGroup group = e.getGroup();
    GroupViewType groupViewType = cyGroupSettings.getGroupViewType(group);
    if (groupViewType.equals(GroupViewType.COMPOUND)) {
        removeCompoundNode(group);
        return;
    }
    // for this group
    if (cyGroupSettings.getUseNestedNetworks(group)) {
        // First, we need to make sure the group is expanded
        for (CyNetwork net : group.getNetworkSet()) {
            group.expand(net);
        }
        CyNetwork nn = group.getGroupNetwork();
        if (cyNetworkViewManager.viewExists(nn)) {
            // Destroy the view(s)
            for (CyNetworkView v : cyNetworkViewManager.getNetworkViews(nn)) {
                cyNetworkViewManager.destroyNetworkView(v);
            }
        }
        // Now, remove the network
        cyNetworkManager.destroyNetwork(nn);
        group.getGroupNode().setNetworkPointer(null);
    }
}
Also used : CyGroup(org.cytoscape.group.CyGroup) GroupViewType(org.cytoscape.group.CyGroupSettingsManager.GroupViewType) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 17 with CyGroup

use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.

the class NodeChangeListener method getGroupForNode.

private CyGroup getGroupForNode(CyNode node, CyNetworkView networkView) {
    CyGroup group = null;
    List<CyGroup> groupList = cyGroupManager.getGroupsForNode(node);
    if (groupList == null || groupList.size() == 0)
        // Shouldn't happen!
        return null;
    Set<CyNode> groupNodes = groupMap.get(networkView);
    for (CyGroup g : groupList) {
        if (groupNodes.contains(g.getGroupNode())) {
            group = g;
        }
    }
    return group;
}
Also used : CyGroup(org.cytoscape.group.CyGroup) CyNode(org.cytoscape.model.CyNode)

Example 18 with CyGroup

use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.

the class NodeChangeListener method addGroup.

public void addGroup(CyGroup group, CyNetworkView networkView) {
    if (!groupMap.containsKey(networkView))
        groupMap.put(networkView, new HashSet<CyNode>());
    groupMap.get(networkView).add(group.getGroupNode());
    if (!nodeMap.containsKey(networkView))
        nodeMap.put(networkView, new HashSet<CyNode>());
    if (!node2GroupMap.containsKey(networkView))
        node2GroupMap.put(networkView, new HashMap<CyNode, CyGroup>());
    Map<CyNode, CyGroup> node2Group = node2GroupMap.get(networkView);
    for (CyNode node : group.getNodeList()) {
        // another one
        if (!node2Group.containsKey(node)) {
            nodeMap.get(networkView).add(node);
            node2Group.put(node, group);
        }
    }
}
Also used : CyGroup(org.cytoscape.group.CyGroup) HashMap(java.util.HashMap) CyNode(org.cytoscape.model.CyNode) HashSet(java.util.HashSet)

Example 19 with CyGroup

use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.

the class CyGroupManagerImpl method updateGroupAttribute.

private void updateGroupAttribute(CyGroup group) {
    CyRootNetwork rootNet = group.getRootNetwork();
    // Get the network row
    CyRow rhRow = rootNet.getRow(rootNet, CyNetwork.HIDDEN_ATTRS);
    if (rhRow.getTable().getColumn(GROUP_LIST_ATTRIBUTE) == null) {
        rhRow.getTable().createListColumn(GROUP_LIST_ATTRIBUTE, Long.class, false);
    }
    List<Long> groupSUIDs = new ArrayList<Long>();
    for (CyGroup g : getGroupSet(rootNet)) {
        groupSUIDs.add(g.getGroupNode().getSUID());
    }
    rhRow.set(GROUP_LIST_ATTRIBUTE, groupSUIDs);
}
Also used : CyGroup(org.cytoscape.group.CyGroup) ArrayList(java.util.ArrayList) CyRow(org.cytoscape.model.CyRow) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 20 with CyGroup

use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.

the class GroupIO method writeLockedVisualPropertiesMap.

private void writeLockedVisualPropertiesMap(final File file, final Set<CyGroup> groups) throws JsonGenerationException, JsonMappingException, IOException {
    final CyNetworkViewManager netViewMgr = groupMgr.getService(CyNetworkViewManager.class);
    final Set<CyIdentifiable> grElements = new HashSet<>();
    for (final CyGroup gr : groups) {
        final Set<CyNetworkView> netViews = new HashSet<>();
        final Set<CyNetwork> networks = gr.getNetworkSet();
        for (final CyNetwork net : networks) {
            if (netViewMgr.viewExists(net))
                netViews.addAll(netViewMgr.getNetworkViews(net));
        }
        if (netViews.isEmpty())
            continue;
        grElements.add(gr.getGroupNode());
        grElements.addAll(gr.getRootNetwork().getAdjacentEdgeList(gr.getGroupNode(), CyEdge.Type.ANY));
        grElements.addAll(gr.getNodeList());
        grElements.addAll(gr.getExternalEdgeList());
        grElements.addAll(gr.getInternalEdgeList());
        for (final CyIdentifiable element : grElements) lvpMgr.saveLockedValues(element, netViews);
    }
    final Map<Key, Map<VisualProperty<?>, Object>> map = lvpMgr.getLockedVisualPropertiesMap();
    if (map != null)
        mapper.writeValue(file, map);
}
Also used : CyGroup(org.cytoscape.group.CyGroup) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Key(org.cytoscape.group.internal.LockedVisualPropertiesManager.Key) CyIdentifiable(org.cytoscape.model.CyIdentifiable) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

CyGroup (org.cytoscape.group.CyGroup)60 CyNode (org.cytoscape.model.CyNode)33 CyNetwork (org.cytoscape.model.CyNetwork)26 ArrayList (java.util.ArrayList)22 CyEdge (org.cytoscape.model.CyEdge)12 CyNetworkView (org.cytoscape.view.model.CyNetworkView)10 HashSet (java.util.HashSet)8 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)7 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)7 List (java.util.List)6 GroupViewType (org.cytoscape.group.CyGroupSettingsManager.GroupViewType)6 CyGroupManager (org.cytoscape.group.CyGroupManager)5 CyRow (org.cytoscape.model.CyRow)5 TaskIterator (org.cytoscape.work.TaskIterator)5 CyGroupImpl (org.cytoscape.group.internal.CyGroupImpl)4 Dimension (java.awt.Dimension)3 LinkedHashSet (java.util.LinkedHashSet)3 CyEventHelper (org.cytoscape.event.CyEventHelper)3 GroupCollapsedEvent (org.cytoscape.group.events.GroupCollapsedEvent)3 FuzzyNodeCluster (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.FuzzyNodeCluster)2