Search in sources :

Example 31 with CyNetworkManager

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

the class CyApplicationManagerImpl method selectNetworks.

private Set<CyNetwork> selectNetworks(final Collection<CyNetwork> networks) {
    final CyNetworkManager networkManager = serviceRegistrar.getService(CyNetworkManager.class);
    final Set<CyNetwork> selectedNetworks = new HashSet<>();
    final Set<CyNetwork> allNetworks = networkManager.getNetworkSet();
    for (final CyNetwork n : allNetworks) {
        final boolean selected = networks != null && networks.contains(n);
        final CyRow row = n.getRow(n);
        row.set(CyNetwork.SELECTED, selected);
        if (selected)
            selectedNetworks.add(n);
    }
    return selectedNetworks;
}
Also used : CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyNetwork(org.cytoscape.model.CyNetwork) CyRow(org.cytoscape.model.CyRow) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 32 with CyNetworkManager

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

the class CyApplicationManagerImpl method internalSetCurrentNetworkView.

private void internalSetCurrentNetworkView(final CyNetworkView view, List<CyEvent<?>> eventsToFire) {
    final CyNetworkManager networkManager = serviceRegistrar.getService(CyNetworkManager.class);
    if (view != null && !networkManager.networkExists(view.getModel().getSUID()))
        throw new IllegalArgumentException("network is not recognized by this ApplicationManager");
    boolean changed = (view == null && currentNetworkView != null) || (view != null && !view.equals(currentNetworkView));
    if (changed) {
        currentNetworkView = view;
        eventsToFire.add(new SetCurrentNetworkViewEvent(this, currentNetworkView));
    }
}
Also used : SetCurrentNetworkViewEvent(org.cytoscape.application.events.SetCurrentNetworkViewEvent) CyNetworkManager(org.cytoscape.model.CyNetworkManager)

Example 33 with CyNetworkManager

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

the class StringToModelImpl method getNetworkView.

// @Override
public CyNetworkView getNetworkView(String strNet) {
    if (strNet == null || strNet.length() == 0 || strNet.equalsIgnoreCase(CURRENT))
        return serviceRegistrar.getService(CyApplicationManager.class).getCurrentNetworkView();
    // Look for any special prefix
    final CyNetworkManager netMgr = serviceRegistrar.getService(CyNetworkManager.class);
    final CyNetworkViewManager netViewMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
    String[] splitString = strNet.split(":");
    if (splitString.length > 1) {
        if (SUID.equalsIgnoreCase(splitString[0])) {
            Long suid = getLong(splitString[1]);
            if (suid == null)
                return null;
            for (CyNetworkView view : netViewMgr.getNetworkViewSet()) {
                if (view.getSUID().equals(suid))
                    return view;
            }
            return null;
        }
        if (NAME.equalsIgnoreCase(splitString[0]))
            strNet = splitString[1];
    }
    for (CyNetwork net : netMgr.getNetworkSet()) {
        if (strNet.equalsIgnoreCase(net.getRow(net).get(CyNetwork.NAME, String.class))) {
            if (netViewMgr.viewExists(net)) {
                for (CyNetworkView view : netViewMgr.getNetworkViews(net)) {
                    // Just return the first view
                    return view;
                }
            }
        }
    }
    return null;
}
Also used : CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 34 with CyNetworkManager

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

the class StringToModelImpl method getNetwork.

@Override
public CyNetwork getNetwork(String strNet) {
    if (strNet == null || strNet.length() == 0 || strNet.equalsIgnoreCase(CURRENT))
        return serviceRegistrar.getService(CyApplicationManager.class).getCurrentNetwork();
    // Look for any special prefix
    final CyNetworkManager netMgr = serviceRegistrar.getService(CyNetworkManager.class);
    String[] splitString = strNet.split(":");
    if (splitString.length > 1) {
        if (SUID.equalsIgnoreCase(splitString[0])) {
            Long suid = getLong(splitString[1]);
            if (suid == null)
                return null;
            return netMgr.getNetwork(suid);
        }
        if (NAME.equalsIgnoreCase(splitString[0]))
            strNet = splitString[1];
    }
    for (CyNetwork net : netMgr.getNetworkSet()) {
        if (strNet.equalsIgnoreCase(net.getRow(net).get(CyNetwork.NAME, String.class)))
            return net;
    }
    return null;
}
Also used : CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyNetwork(org.cytoscape.model.CyNetwork)

Example 35 with CyNetworkManager

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

the class DestroyNetworkTask method run.

@Override
public void run(TaskMonitor tm) {
    int i = 0;
    int networkCount;
    if (destroyCurrentNetwork) {
        tm.setProgress(0.0);
        CyNetworkManager netManager = serviceRegistrar.getService(CyNetworkManager.class);
        if (localNets == null || localNets.isEmpty()) {
            if (network == null) {
                tm.showMessage(TaskMonitor.Level.ERROR, "Need to specify network to destroy");
                return;
            } else {
                localNets = Collections.singletonList(network);
            }
        }
        networkCount = localNets.size();
        for (CyNetwork n : localNets) {
            destroyNetwork(n, netManager);
            i++;
            tm.setProgress((i / (double) networkCount));
        }
        tm.setProgress(1.0);
    }
}
Also used : CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyNetwork(org.cytoscape.model.CyNetwork)

Aggregations

CyNetworkManager (org.cytoscape.model.CyNetworkManager)49 CyNetwork (org.cytoscape.model.CyNetwork)28 CyApplicationManager (org.cytoscape.application.CyApplicationManager)14 Test (org.junit.Test)14 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)12 CyNode (org.cytoscape.model.CyNode)9 ArrayList (java.util.ArrayList)8 CyGroupManager (org.cytoscape.group.CyGroupManager)8 CyNetworkFactory (org.cytoscape.model.CyNetworkFactory)8 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)7 CyNetworkViewFactory (org.cytoscape.view.model.CyNetworkViewFactory)7 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)7 CyTableManager (org.cytoscape.model.CyTableManager)6 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)6 CyNetworkView (org.cytoscape.view.model.CyNetworkView)6 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)6 TaskIterator (org.cytoscape.work.TaskIterator)6 CyEventHelper (org.cytoscape.event.CyEventHelper)5 CyLayoutAlgorithmManager (org.cytoscape.view.layout.CyLayoutAlgorithmManager)5 UndoSupport (org.cytoscape.work.undo.UndoSupport)5