Search in sources :

Example 1 with CyGroup

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

the class AbstractSessionReader method cleanUp.

/**
 * Use this methods to dispose temporary resources.
 * This method must always be invoked, even if this task is cancelled.
 */
protected void cleanUp(TaskMonitor tm) {
    try {
        ((ReusableInputStream) sourceInputStream).reallyClose();
    } catch (Exception e) {
        logger.error("Error closing source input stream.", e);
    }
    if (cancelled) {
        // Destroy groups
        final Set<CyGroup> groups = groupUtil.getGroups(cache.getNetworks());
        groupUtil.destroyGroups(groups);
        // Dispose CyNetworkViews and CyNetworks
        for (final CyNetworkView view : networkViews) view.dispose();
        final CyRootNetworkManager rootNetworkManager = serviceRegistrar.getService(CyRootNetworkManager.class);
        final Set<CyRootNetwork> rootNetworks = new HashSet<>();
        // such as group networks.
        for (final CyNetwork net : cache.getNetworks()) {
            net.dispose();
            rootNetworks.add(rootNetworkManager.getRootNetwork(net));
        }
        for (final CyRootNetwork rootNet : rootNetworks) rootNet.dispose();
        networkViews.clear();
        networks.clear();
    }
    cache.dispose();
    SessionUtil.setReadingSessionFile(false);
}
Also used : CyGroup(org.cytoscape.group.CyGroup) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView) IOException(java.io.IOException) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 2 with CyGroup

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

the class UnGroupNodesTaskFactoryImpl method createTaskIterator.

public TaskIterator createTaskIterator(CyNetworkView netView) {
    CyNetwork net = netView.getModel();
    final List<CyNode> selNodes = CyTableUtil.getNodesInState(net, CyNetwork.SELECTED, true);
    Set<CyGroup> groups = getGroups(net, selNodes);
    return new TaskIterator(new UnGroupNodesTask(undoSupport, netView.getModel(), factory, groups, mgr, netView));
}
Also used : CyGroup(org.cytoscape.group.CyGroup) TaskIterator(org.cytoscape.work.TaskIterator) CyNetwork(org.cytoscape.model.CyNetwork) CyNode(org.cytoscape.model.CyNode)

Example 3 with CyGroup

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

the class GroupNodeContextTaskFactoryImpl method createTaskIterator.

@Override
public TaskIterator createTaskIterator(View<CyNode> nodeView, CyNetworkView netView) {
    List<CyGroup> groups = new ArrayList<CyGroup>();
    final List<CyNode> selNodes = CyTableUtil.getNodesInState(netView.getModel(), CyNetwork.SELECTED, true);
    if (collapse) {
        // Always add the context node, whether it's selected or not
        groups.add(getExpandedGroupForNode(nodeView.getModel(), netView));
        for (CyNode node : selNodes) {
            CyGroup g = getExpandedGroupForNode(node, netView);
            if (g != null)
                groups.add(g);
        }
    } else {
        groups.add(mgr.getGroup(nodeView.getModel(), netView.getModel()));
        for (CyNode node : selNodes) {
            CyGroup g = mgr.getGroup(node, netView.getModel());
            if (g != null)
                groups.add(g);
        }
    }
    return new TaskIterator(new CollapseGroupTask(netView.getModel(), groups, mgr, collapse));
}
Also used : CyGroup(org.cytoscape.group.CyGroup) TaskIterator(org.cytoscape.work.TaskIterator) ArrayList(java.util.ArrayList) CyNode(org.cytoscape.model.CyNode)

Example 4 with CyGroup

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

the class AbstractGroupTask method getGroupSetString.

protected String getGroupSetString(Collection<CyGroup> groups) {
    StringBuilder buffer = new StringBuilder();
    StringJoiner joiner = new StringJoiner(",");
    for (CyGroup group : groups) joiner.add(group.getGroupNode().getSUID().toString());
    return joiner.toString();
}
Also used : CyGroup(org.cytoscape.group.CyGroup) StringJoiner(java.util.StringJoiner)

Example 5 with CyGroup

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

the class AbstractGroupTask method getGroup.

protected CyGroup getGroup(String groupName) {
    CyRootNetwork rootNet = ((CySubNetwork) net).getRootNetwork();
    Set<CyGroup> allGroups = groupMgr.getGroupSet(net);
    for (CyGroup group : allGroups) {
        CyRow groupRow = rootNet.getRow(group.getGroupNode(), CyRootNetwork.SHARED_ATTRS);
        if (groupName.length() > 5 && groupName.substring(0, 5).equalsIgnoreCase("suid:")) {
            String suidString = groupRow.get(CyNetwork.SUID, Long.class).toString();
            if (suidString != null && groupName.substring(5).equals(suidString))
                return group;
        } else if (groupName.equals(groupRow.get(CyRootNetwork.SHARED_NAME, String.class)))
            return group;
    }
    return null;
}
Also used : CyGroup(org.cytoscape.group.CyGroup) CyRow(org.cytoscape.model.CyRow) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

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