Search in sources :

Example 66 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class DestroyNetworkViewsAction method updateEnableState.

@Override
public void updateEnableState() {
    final List<CyNetwork> networks = serviceRegistrar.getService(CyApplicationManager.class).getSelectedNetworks();
    final CyNetworkViewManager netViewManager = serviceRegistrar.getService(CyNetworkViewManager.class);
    int count = 0;
    for (CyNetwork n : networks) count += netViewManager.getNetworkViews(n).size();
    if (count > 0)
        setName("Destroy " + count + " View" + (count == 1 ? "" : "s"));
    else
        setName("Destroy Views");
    setEnabled(count > 0);
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) CyNetwork(org.cytoscape.model.CyNetwork)

Example 67 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class SessionHandler method postLoading.

private final void postLoading(final CySession sess) {
    NetworkList netList = null;
    final Map<String, List<File>> filesMap = sess.getAppFileListMap();
    if (filesMap != null) {
        final List<File> files = filesMap.get(APP_NAME);
        if (files != null) {
            SessionState sessState = null;
            for (File f : files) {
                if (f.getName().endsWith(SESSION_STATE_FILENAME))
                    sessState = sessionIO.read(f, SessionState.class);
                else if (f.getName().endsWith(NETWORK_LIST_FILENAME))
                    netList = sessionIO.read(f, NetworkList.class);
            }
            if (sessState != null)
                setCytoPanelStates(sessState.getCytopanels());
        }
    }
    if (netList == null) {
        // Probably a Cy2 session file, which does not provide a separate "network_list" file
        // so let's get the orders from the networks in the CySession file
        // (we just assume the Session Reader sent the networks in the correct order in a LinkedHashSet)
        final Set<CyNetwork> netSet = sess.getNetworks();
        final Map<Long, Integer> netOrder = new HashMap<>();
        int count = 0;
        for (CyNetwork n : netSet) netOrder.put(n.getSUID(), count++);
        setSessionNetworks(netOrder);
    } else {
        setSessionNetworks(netList.getNetwork(), sess);
    }
}
Also used : SessionState(org.cytoscape.internal.io.sessionstate.SessionState) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) CyNetwork(org.cytoscape.model.CyNetwork) NetworkList(org.cytoscape.internal.io.networklist.NetworkList) ArrayList(java.util.ArrayList) List(java.util.List) NetworkList(org.cytoscape.internal.io.networklist.NetworkList) File(java.io.File)

Example 68 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class SessionHandler method setSessionNetworks.

private void setSessionNetworks(final List<Network> netInfoList, final CySession sess) {
    final Map<Long, Integer> netOrder = new HashMap<>();
    for (final Network n : netInfoList) {
        // in order to retrieve the new SUID
        final CyNetwork net = sess.getObject(n.getId(), CyNetwork.class);
        if (net != null)
            netOrder.put(net.getSUID(), n.getOrder());
    }
    setSessionNetworks(netOrder);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Network(org.cytoscape.internal.io.networklist.Network) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyNetwork(org.cytoscape.model.CyNetwork) CyNetwork(org.cytoscape.model.CyNetwork)

Example 69 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class SelectFirstNeighborsNodeViewTask method run.

public void run(TaskMonitor tm) throws Exception {
    tm.setProgress(0.0);
    if (nodeView == null)
        throw new NullPointerException("node view is null");
    if (netView == null)
        throw new NullPointerException("network view is null");
    final Set<CyNode> selNodes = new HashSet<CyNode>();
    final CyNode node = nodeView.getModel();
    final CyNetwork net = netView.getModel();
    tm.setProgress(0.1d);
    selNodes.add(node);
    tm.setProgress(0.4d);
    selNodes.addAll(net.getNeighborList(node, direction));
    tm.setProgress(0.6d);
    selectUtils.setSelectedNodes(net, selNodes, true);
    tm.setProgress(0.8d);
    netView.updateView();
    tm.setProgress(1.0d);
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) CyNode(org.cytoscape.model.CyNode) HashSet(java.util.HashSet)

Example 70 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class AbstractOpenSessionTask method disposeCancelledSession.

protected void disposeCancelledSession(Exception e, CySessionManager sessionManager) {
    if (reader == null)
        return;
    final CySession newSession = reader.getSession();
    if (newSession != null) {
        // Destroy any new views and networks
        for (CyNetworkView view : newSession.getNetworkViews()) view.dispose();
        CyRootNetworkManager rootNetManager = serviceRegistrar.getService(CyRootNetworkManager.class);
        final Set<CyRootNetwork> rootNetworks = new HashSet<>();
        for (CyNetwork net : newSession.getNetworks()) rootNetworks.add(rootNetManager.getRootNetwork(net));
        for (CyRootNetwork rootNet : rootNetworks) rootNet.dispose();
    }
    // Reset the Group Manager, because groups can be registered by the reader
    // TODO Remove this after groups no longer registered inside the IO bundle.
    serviceRegistrar.getService(CyGroupManager.class).reset();
    // Destroy any global tables registered by the reader
    serviceRegistrar.getService(CyTableManager.class).reset();
    // Set a new, empty session
    sessionManager.setCurrentSession(null, null);
}
Also used : CySession(org.cytoscape.session.CySession) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyTableManager(org.cytoscape.model.CyTableManager) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyGroupManager(org.cytoscape.group.CyGroupManager) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork) HashSet(java.util.HashSet)

Aggregations

CyNetwork (org.cytoscape.model.CyNetwork)517 CyNode (org.cytoscape.model.CyNode)183 CyNetworkView (org.cytoscape.view.model.CyNetworkView)129 CyEdge (org.cytoscape.model.CyEdge)108 Test (org.junit.Test)107 ArrayList (java.util.ArrayList)87 CyTable (org.cytoscape.model.CyTable)75 CyApplicationManager (org.cytoscape.application.CyApplicationManager)70 CyIdentifiable (org.cytoscape.model.CyIdentifiable)57 CyRow (org.cytoscape.model.CyRow)48 HashSet (java.util.HashSet)45 CyNetworkManager (org.cytoscape.model.CyNetworkManager)40 HashMap (java.util.HashMap)35 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)35 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)32 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)31 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)30 AbstractNetworkReaderTest (org.cytoscape.io.internal.read.AbstractNetworkReaderTest)27 TaskIterator (org.cytoscape.work.TaskIterator)27 List (java.util.List)26