Search in sources :

Example 11 with CyRootNetworkManager

use of org.cytoscape.model.subnetwork.CyRootNetworkManager in project cytoscape-impl by cytoscape.

the class ReadDataManager method createRootNetwork.

protected CyRootNetwork createRootNetwork() {
    if (this.rootNetwork != null)
        return this.rootNetwork;
    final CyNetworkFactory networkFactory = serviceRegistrar.getService(CyNetworkFactory.class);
    final CyNetwork baseNet = networkFactory.createNetwork();
    final CyRootNetworkManager rootNetworkManager = serviceRegistrar.getService(CyRootNetworkManager.class);
    final CyRootNetwork rootNetwork = rootNetworkManager.getRootNetwork(baseNet);
    return rootNetwork;
}
Also used : CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkFactory(org.cytoscape.model.CyNetworkFactory) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 12 with CyRootNetworkManager

use of org.cytoscape.model.subnetwork.CyRootNetworkManager in project cytoscape-impl by cytoscape.

the class CySessionManagerImpl method restoreTables.

private void restoreTables(final CySession sess) {
    final Set<CyTable> allTables = new HashSet<>();
    // Register all tables sent through the CySession, if not already registered
    for (final CyTableMetadata metadata : sess.getTables()) {
        allTables.add(metadata.getTable());
    }
    // There may be other network tables in the CyNetworkTableManager that were not serialized in the session file
    // (e.g. Table Facades), so it's necessary to add them to CyTableManager as well
    final CyNetworkTableManager netTblMgr = serviceRegistrar.getService(CyNetworkTableManager.class);
    final CyRootNetworkManager rootNetMgr = serviceRegistrar.getService(CyRootNetworkManager.class);
    for (final CyNetwork net : sess.getNetworks()) {
        allTables.addAll(netTblMgr.getTables(net, CyNetwork.class).values());
        allTables.addAll(netTblMgr.getTables(net, CyNode.class).values());
        allTables.addAll(netTblMgr.getTables(net, CyEdge.class).values());
        if (!(net instanceof CyRootNetwork)) {
            final CyRootNetwork root = rootNetMgr.getRootNetwork(net);
            allTables.addAll(netTblMgr.getTables(root, CyNetwork.class).values());
            allTables.addAll(netTblMgr.getTables(root, CyNode.class).values());
            allTables.addAll(netTblMgr.getTables(root, CyEdge.class).values());
        }
    }
    // Register all tables sent through the CySession, if not already registered
    final CyTableManager tblMgr = serviceRegistrar.getService(CyTableManager.class);
    for (final CyTable tbl : allTables) {
        if (tblMgr.getTable(tbl.getSUID()) == null)
            tblMgr.addTable(tbl);
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyTableManager(org.cytoscape.model.CyTableManager) CyTableMetadata(org.cytoscape.model.CyTableMetadata) CyNetwork(org.cytoscape.model.CyNetwork) HashSet(java.util.HashSet) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 13 with CyRootNetworkManager

use of org.cytoscape.model.subnetwork.CyRootNetworkManager in project cytoscape-impl by cytoscape.

the class NetworkCollectionHelper method init.

void init() {
    final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
    final CyRootNetworkManager rootNetMgr = serviceRegistrar.getService(CyRootNetworkManager.class);
    // initialize the network Collection
    name2RootMap = getRootNetworkMap();
    final List<String> rootNames = new ArrayList<>();
    rootNames.addAll(name2RootMap.keySet());
    if (!rootNames.isEmpty()) {
        sort(rootNames);
        rootNames.add(0, CREATE_NEW_COLLECTION_STRING);
    }
    rootNetworkList = new ListSingleSelection<>(rootNames);
    final CyNetwork net = appMgr != null ? appMgr.getCurrentNetwork() : null;
    final CyRootNetwork rootNet = net != null ? rootNetMgr.getRootNetwork(net) : null;
    final String rootNetName = rootNet != null ? rootNet.getRow(rootNet).get(CyRootNetwork.NAME, String.class) : CREATE_NEW_COLLECTION_STRING;
    if (rootNames.contains(rootNetName))
        rootNetworkList.setSelectedValue(rootNetName);
    else if (rootNames.contains(CREATE_NEW_COLLECTION_STRING))
        rootNetworkList.setSelectedValue(CREATE_NEW_COLLECTION_STRING);
    if (rootNet != null)
        targetColumnList = getTargetColumns(rootNet);
    else
        targetColumnList = new ListSingleSelection<>();
    // initialize renderer list
    final List<NetworkViewRenderer> renderers = new ArrayList<>();
    final Set<NetworkViewRenderer> rendererSet = appMgr.getNetworkViewRendererSet();
    // so the combo-box does not appear to the user, since there is nothing to select anyway.
    if (rendererSet.size() > 1) {
        renderers.addAll(rendererSet);
        Collections.sort(renderers, new Comparator<NetworkViewRenderer>() {

            @Override
            public int compare(NetworkViewRenderer r1, NetworkViewRenderer r2) {
                return r1.toString().compareToIgnoreCase(r2.toString());
            }
        });
    }
    rendererList = new ListSingleSelection<>(renderers);
    final NetworkViewRenderer defViewRenderer = appMgr.getDefaultNetworkViewRenderer();
    if (defViewRenderer != null && renderers.contains(defViewRenderer))
        rendererList.setSelectedValue(defViewRenderer);
}
Also used : CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) CyApplicationManager(org.cytoscape.application.CyApplicationManager) ListSingleSelection(org.cytoscape.work.util.ListSingleSelection) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork) NetworkViewRenderer(org.cytoscape.application.NetworkViewRenderer)

Example 14 with CyRootNetworkManager

use of org.cytoscape.model.subnetwork.CyRootNetworkManager in project cytoscape-impl by cytoscape.

the class NetworkCollectionHelper method getRootNetworkMap.

private HashMap<String, CyRootNetwork> getRootNetworkMap() {
    final HashMap<String, CyRootNetwork> name2RootMap = new HashMap<>();
    final Set<CyNetwork> networkSet = serviceRegistrar.getService(CyNetworkManager.class).getNetworkSet();
    final CyRootNetworkManager rootNetworkManager = serviceRegistrar.getService(CyRootNetworkManager.class);
    for (CyNetwork net : networkSet) {
        final CyRootNetwork rootNet = rootNetworkManager.getRootNetwork(net);
        if (!name2RootMap.containsValue(rootNet))
            name2RootMap.put(rootNet.getRow(rootNet).get(CyRootNetwork.NAME, String.class), rootNet);
    }
    return name2RootMap;
}
Also used : CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) HashMap(java.util.HashMap) CyNetwork(org.cytoscape.model.CyNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 15 with CyRootNetworkManager

use of org.cytoscape.model.subnetwork.CyRootNetworkManager in project cytoscape-impl by cytoscape.

the class NewNetworkSelectedNodesOnlyTaskFactoryTest method testObserver.

@Test
public void testObserver() throws Exception {
    NetworkViewTestSupport viewSupport = new NetworkViewTestSupport();
    NetworkTestSupport networkSupport = new NetworkTestSupport();
    CyNetworkFactory networkFactory = networkSupport.getNetworkFactory();
    UndoSupport undoSupport = mock(UndoSupport.class);
    CyRootNetworkManager crnf = new CyRootNetworkManagerImpl();
    CyNetworkViewFactory cnvf = viewSupport.getNetworkViewFactory();
    CyNetworkManager netmgr = mock(CyNetworkManager.class);
    CyNetworkViewManager networkViewManager = mock(CyNetworkViewManager.class);
    CyNetworkNaming naming = mock(CyNetworkNaming.class);
    VisualMappingManager vmm = mock(VisualMappingManager.class);
    CyApplicationManager appManager = mock(CyApplicationManager.class);
    CyEventHelper eventHelper = mock(CyEventHelper.class);
    CyGroupManager groupMgr = mock(CyGroupManager.class);
    RenderingEngineManager renderingEngineMgr = mock(RenderingEngineManager.class);
    CyLayoutAlgorithm defLayout = mock(CyLayoutAlgorithm.class);
    CyLayoutAlgorithmManager layoutMgr = mock(CyLayoutAlgorithmManager.class);
    when(layoutMgr.getDefaultLayout()).thenReturn(defLayout);
    CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyLayoutAlgorithmManager.class)).thenReturn(layoutMgr);
    NewNetworkSelectedNodesOnlyTaskFactoryImpl factory = new NewNetworkSelectedNodesOnlyTaskFactoryImpl(undoSupport, crnf, cnvf, netmgr, networkViewManager, naming, vmm, appManager, eventHelper, groupMgr, renderingEngineMgr, serviceRegistrar);
    CyNetwork network = networkFactory.createNetwork();
    CyNode node = network.addNode();
    network.getRow(node).set(CyNetwork.SELECTED, true);
    TaskObserver observer = mock(TaskObserver.class);
    TaskMonitor taskMonitor = mock(TaskMonitor.class);
    TaskIterator iterator = factory.createTaskIterator(network);
    while (iterator.hasNext()) {
        Task t = iterator.next();
        t.run(taskMonitor);
        if (t instanceof ObservableTask)
            observer.taskFinished((ObservableTask) t);
    }
    verify(observer, times(1)).taskFinished(any(ObservableTask.class));
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) Task(org.cytoscape.work.Task) ObservableTask(org.cytoscape.work.ObservableTask) CyNetwork(org.cytoscape.model.CyNetwork) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) ObservableTask(org.cytoscape.work.ObservableTask) TaskIterator(org.cytoscape.work.TaskIterator) TaskMonitor(org.cytoscape.work.TaskMonitor) CyLayoutAlgorithm(org.cytoscape.view.layout.CyLayoutAlgorithm) CyNode(org.cytoscape.model.CyNode) CyGroupManager(org.cytoscape.group.CyGroupManager) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) CyRootNetworkManagerImpl(org.cytoscape.model.internal.CyRootNetworkManagerImpl) NetworkTestSupport(org.cytoscape.model.NetworkTestSupport) NetworkViewTestSupport(org.cytoscape.ding.NetworkViewTestSupport) UndoSupport(org.cytoscape.work.undo.UndoSupport) CyApplicationManager(org.cytoscape.application.CyApplicationManager) TaskObserver(org.cytoscape.work.TaskObserver) CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyNetworkViewFactory(org.cytoscape.view.model.CyNetworkViewFactory) CyLayoutAlgorithmManager(org.cytoscape.view.layout.CyLayoutAlgorithmManager) CyNetworkNaming(org.cytoscape.session.CyNetworkNaming) CyNetworkFactory(org.cytoscape.model.CyNetworkFactory) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) Test(org.junit.Test)

Aggregations

CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)18 CyNetwork (org.cytoscape.model.CyNetwork)13 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)9 CyApplicationManager (org.cytoscape.application.CyApplicationManager)8 CyNetworkManager (org.cytoscape.model.CyNetworkManager)8 CyNetworkFactory (org.cytoscape.model.CyNetworkFactory)7 CyGroupManager (org.cytoscape.group.CyGroupManager)6 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)6 CyNetworkViewFactory (org.cytoscape.view.model.CyNetworkViewFactory)5 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)5 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)5 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)5 HashSet (java.util.HashSet)4 CyEventHelper (org.cytoscape.event.CyEventHelper)4 CyTableManager (org.cytoscape.model.CyTableManager)4 CyLayoutAlgorithmManager (org.cytoscape.view.layout.CyLayoutAlgorithmManager)4 TaskIterator (org.cytoscape.work.TaskIterator)4 UndoSupport (org.cytoscape.work.undo.UndoSupport)4 CyNetworkTableManager (org.cytoscape.model.CyNetworkTableManager)3 NetworkTestSupport (org.cytoscape.model.NetworkTestSupport)3