Search in sources :

Example 1 with CyLayoutAlgorithmManager

use of org.cytoscape.view.layout.CyLayoutAlgorithmManager in project cytoscape-impl by cytoscape.

the class CyActivator method start.

@Override
public void start(BundleContext bc) {
    CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
    CyEventHelper cyEventHelperRef = getService(bc, CyEventHelper.class);
    CyNetworkNaming cyNetworkNamingServiceRef = getService(bc, CyNetworkNaming.class);
    UndoSupport undoSupportServiceRef = getService(bc, UndoSupport.class);
    CyNetworkViewFactory cyNetworkViewFactoryServiceRef = getService(bc, CyNetworkViewFactory.class);
    CyNetworkFactory cyNetworkFactoryServiceRef = getService(bc, CyNetworkFactory.class);
    CyRootNetworkManager cyRootNetworkFactoryServiceRef = getService(bc, CyRootNetworkManager.class);
    VisualMappingManager visualMappingManagerServiceRef = getService(bc, VisualMappingManager.class);
    CyNetworkViewWriterManager networkViewWriterManagerServiceRef = getService(bc, CyNetworkViewWriterManager.class);
    CyNetworkManager cyNetworkManagerServiceRef = getService(bc, CyNetworkManager.class);
    CyNetworkViewManager cyNetworkViewManagerServiceRef = getService(bc, CyNetworkViewManager.class);
    CyApplicationManager cyApplicationManagerServiceRef = getService(bc, CyApplicationManager.class);
    CySessionManager cySessionManagerServiceRef = getService(bc, CySessionManager.class);
    CyTableFactory cyTableFactoryServiceRef = getService(bc, CyTableFactory.class);
    CyTableManager cyTableManagerServiceRef = getService(bc, CyTableManager.class);
    CyLayoutAlgorithmManager cyLayoutsServiceRef = getService(bc, CyLayoutAlgorithmManager.class);
    CyTableWriterManager cyTableWriterManagerRef = getService(bc, CyTableWriterManager.class);
    SynchronousTaskManager<?> synchronousTaskManagerServiceRef = getService(bc, SynchronousTaskManager.class);
    TunableSetter tunableSetterServiceRef = getService(bc, TunableSetter.class);
    CyRootNetworkManager rootNetworkManagerServiceRef = getService(bc, CyRootNetworkManager.class);
    CyNetworkTableManager cyNetworkTableManagerServiceRef = getService(bc, CyNetworkTableManager.class);
    RenderingEngineManager renderingEngineManagerServiceRef = getService(bc, RenderingEngineManager.class);
    CyNetworkViewFactory nullNetworkViewFactory = getService(bc, CyNetworkViewFactory.class, "(id=NullCyNetworkViewFactory)");
    CyGroupManager cyGroupManager = getService(bc, CyGroupManager.class);
    CyGroupFactory cyGroupFactory = getService(bc, CyGroupFactory.class);
    {
        DynamicTaskFactoryProvisionerImpl factory = new DynamicTaskFactoryProvisionerImpl(serviceRegistrar);
        registerAllServices(bc, factory);
    }
    createPreferencesTaskFactories(bc, serviceRegistrar);
    createFilterTaskFactories(bc, serviceRegistrar);
    createTableTaskFactories(bc, serviceRegistrar, undoSupportServiceRef, cyNetworkManagerServiceRef, cyApplicationManagerServiceRef, cyTableFactoryServiceRef, cyTableManagerServiceRef, cyTableWriterManagerRef, tunableSetterServiceRef, rootNetworkManagerServiceRef, cyNetworkTableManagerServiceRef);
    createNetworkTaskFactories(bc, serviceRegistrar, cyEventHelperRef, cyNetworkNamingServiceRef, undoSupportServiceRef, cyNetworkViewFactoryServiceRef, cyNetworkFactoryServiceRef, cyRootNetworkFactoryServiceRef, visualMappingManagerServiceRef, cyNetworkManagerServiceRef, cyNetworkViewManagerServiceRef, cyApplicationManagerServiceRef, synchronousTaskManagerServiceRef, rootNetworkManagerServiceRef, cyNetworkTableManagerServiceRef, renderingEngineManagerServiceRef, nullNetworkViewFactory, cyGroupManager, cyGroupFactory, networkViewWriterManagerServiceRef, tunableSetterServiceRef);
    createViewTaskFactories(bc, cyEventHelperRef, undoSupportServiceRef, visualMappingManagerServiceRef, networkViewWriterManagerServiceRef, cyNetworkViewManagerServiceRef, cyApplicationManagerServiceRef, cyLayoutsServiceRef, tunableSetterServiceRef, renderingEngineManagerServiceRef, cyNetworkManagerServiceRef, cySessionManagerServiceRef, serviceRegistrar);
    createVizmapTaskFactories(bc, serviceRegistrar);
    createSessionTaskFactories(bc, serviceRegistrar);
    createGroupTaskFactories(bc, undoSupportServiceRef, cyApplicationManagerServiceRef, cyGroupManager, cyGroupFactory, serviceRegistrar);
    createNodeEdgeTaskFactories(bc, serviceRegistrar, cyEventHelperRef, undoSupportServiceRef, cyNetworkViewManagerServiceRef, tunableSetterServiceRef, cyApplicationManagerServiceRef, cyTableManagerServiceRef, renderingEngineManagerServiceRef, visualMappingManagerServiceRef);
    createLayoutTaskFactories(bc, serviceRegistrar);
    createHelpTaskFactories(bc, serviceRegistrar);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) CyTableWriterManager(org.cytoscape.io.write.CyTableWriterManager) UndoSupport(org.cytoscape.work.undo.UndoSupport) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyTableFactory(org.cytoscape.model.CyTableFactory) TunableSetter(org.cytoscape.work.TunableSetter) CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyNetworkViewFactory(org.cytoscape.view.model.CyNetworkViewFactory) CyTableManager(org.cytoscape.model.CyTableManager) CyLayoutAlgorithmManager(org.cytoscape.view.layout.CyLayoutAlgorithmManager) CyNetworkNaming(org.cytoscape.session.CyNetworkNaming) CyNetworkViewWriterManager(org.cytoscape.io.write.CyNetworkViewWriterManager) CySessionManager(org.cytoscape.session.CySessionManager) CyNetworkFactory(org.cytoscape.model.CyNetworkFactory) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) CyGroupFactory(org.cytoscape.group.CyGroupFactory) CyGroupManager(org.cytoscape.group.CyGroupManager)

Example 2 with CyLayoutAlgorithmManager

use of org.cytoscape.view.layout.CyLayoutAlgorithmManager in project cytoscape-impl by cytoscape.

the class NewNetworkSelectedNodesEdgesTaskFactoryTest 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);
    NewNetworkSelectedNodesEdgesTaskFactoryImpl factory = new NewNetworkSelectedNodesEdgesTaskFactoryImpl(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)

Example 3 with CyLayoutAlgorithmManager

use of org.cytoscape.view.layout.CyLayoutAlgorithmManager in project cytoscape-impl by cytoscape.

the class SetPreferredLayoutTask method run.

@Override
public void run(TaskMonitor tm) {
    final CyLayoutAlgorithmManager layoutManager = serviceRegistrar.getService(CyLayoutAlgorithmManager.class);
    final String prefName = preferredLayout.getSelectedValue();
    final CyLayoutAlgorithm prefLayout = layoutManager.getLayout(prefName);
    if (prefLayout != null) {
        layoutManager.setDefaultLayout(prefLayout);
        tm.showMessage(TaskMonitor.Level.INFO, "Preferred layout set to " + prefName);
    } else {
        tm.showMessage(TaskMonitor.Level.WARN, "Can't set preferred layout -- invalid layout name");
    }
}
Also used : CyLayoutAlgorithmManager(org.cytoscape.view.layout.CyLayoutAlgorithmManager) CyLayoutAlgorithm(org.cytoscape.view.layout.CyLayoutAlgorithm)

Example 4 with CyLayoutAlgorithmManager

use of org.cytoscape.view.layout.CyLayoutAlgorithmManager in project cytoscape-impl by cytoscape.

the class LayoutSettingsDialog method getPrefAlgorithmCmb.

private JComboBox<CyLayoutAlgorithm> getPrefAlgorithmCmb() {
    if (prefAlgorithmCmb == null) {
        prefAlgorithmCmb = new JComboBox<CyLayoutAlgorithm>();
        prefAlgorithmCmb.setModel(new DefaultComboBoxModel<CyLayoutAlgorithm>());
        prefAlgorithmCmb.setRenderer(new LayoutAlgorithmListCellRenderer("-- Select preferred algorithm --"));
        prefAlgorithmCmb.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {
                if (initializing)
                    return;
                final CyLayoutAlgorithmManager layoutAlgorithmMgr = serviceRegistrar.getService(CyLayoutAlgorithmManager.class);
                final CyLayoutAlgorithm layout = (CyLayoutAlgorithm) prefAlgorithmCmb.getSelectedItem();
                if (layout != null && !layout.equals(layoutAlgorithmMgr.getDefaultLayout()))
                    layoutAlgorithmMgr.setDefaultLayout(layout);
            }
        });
    }
    return prefAlgorithmCmb;
}
Also used : ItemEvent(java.awt.event.ItemEvent) CyLayoutAlgorithmManager(org.cytoscape.view.layout.CyLayoutAlgorithmManager) CyLayoutAlgorithm(org.cytoscape.view.layout.CyLayoutAlgorithm) ItemListener(java.awt.event.ItemListener)

Example 5 with CyLayoutAlgorithmManager

use of org.cytoscape.view.layout.CyLayoutAlgorithmManager in project cytoscape-impl by cytoscape.

the class ApplyPreferredLayoutTask method run.

@Override
public void run(TaskMonitor tm) {
    tm.setProgress(0.0d);
    tm.setStatusMessage("Applying Default Layout...");
    final CyNetworkViewManager viewMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
    Collection<CyNetworkView> views = networkViews;
    if (networkSelected != null)
        views = viewMgr.getNetworkViews(networkSelected);
    final CyLayoutAlgorithmManager layoutMgr = serviceRegistrar.getService(CyLayoutAlgorithmManager.class);
    final CyLayoutAlgorithm layout = layoutMgr.getDefaultLayout();
    tm.setProgress(0.2);
    int i = 0;
    int viewCount = views.size();
    for (final CyNetworkView view : views) {
        if (layout != null) {
            // clearEdgeBends(view);
            final TaskIterator itr = layout.createTaskIterator(view, layout.getDefaultLayoutContext(), CyLayoutAlgorithm.ALL_NODE_VIEWS, "");
            if (// For unit tests...
            itr != null)
                insertTasksAfterCurrentTask(itr);
        } else {
            throw new IllegalArgumentException("Couldn't find default layout algorithm");
        }
        i++;
        tm.setProgress((i / (double) viewCount));
    }
    tm.setProgress(1.0);
}
Also used : TaskIterator(org.cytoscape.work.TaskIterator) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) CyLayoutAlgorithmManager(org.cytoscape.view.layout.CyLayoutAlgorithmManager) CyLayoutAlgorithm(org.cytoscape.view.layout.CyLayoutAlgorithm) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Aggregations

CyLayoutAlgorithmManager (org.cytoscape.view.layout.CyLayoutAlgorithmManager)8 CyLayoutAlgorithm (org.cytoscape.view.layout.CyLayoutAlgorithm)6 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)6 CyApplicationManager (org.cytoscape.application.CyApplicationManager)5 CyEventHelper (org.cytoscape.event.CyEventHelper)5 CyNetworkManager (org.cytoscape.model.CyNetworkManager)5 CyNetworkViewFactory (org.cytoscape.view.model.CyNetworkViewFactory)5 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)5 CyGroupManager (org.cytoscape.group.CyGroupManager)4 CyNetworkFactory (org.cytoscape.model.CyNetworkFactory)4 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)4 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)4 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)4 UndoSupport (org.cytoscape.work.undo.UndoSupport)4 CyNode (org.cytoscape.model.CyNode)3 TaskIterator (org.cytoscape.work.TaskIterator)3 CyNetworkNaming (org.cytoscape.session.CyNetworkNaming)2 CyNetworkView (org.cytoscape.view.model.CyNetworkView)2 TaskManager (org.cytoscape.work.TaskManager)2 ItemEvent (java.awt.event.ItemEvent)1