Search in sources :

Example 6 with CyApplicationManager

use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.

the class CyNetworkViewWriterTest method setUp.

@Before
public void setUp() throws Exception {
    writerManager = mock(CyNetworkViewWriterManager.class);
    cyApplicationManager = mock(CyApplicationManager.class);
    view = viewSupport.getNetworkView();
    final List<CyFileFilter> filters = new ArrayList<CyFileFilter>();
    final CyFileFilter dummyFilter = mock(CyFileFilter.class);
    filters.add(dummyFilter);
    when(dummyFilter.getDescription()).thenReturn("dummy description");
    when(dummyFilter.getExtensions()).thenReturn(Collections.singleton("dummy"));
    when(writerManager.getAvailableWriterFilters()).thenReturn(filters);
    final CyNetworkViewWriter writer = new CyNetworkViewWriter(writerManager, cyApplicationManager, view);
    this.cyWriter = writer;
    when(writerManager.getWriter(eq(view), eq(dummyFilter), any(File.class))).thenReturn(writer, writer);
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyFileFilter(org.cytoscape.io.CyFileFilter) ArrayList(java.util.ArrayList) CyNetworkViewWriterManager(org.cytoscape.io.write.CyNetworkViewWriterManager) File(java.io.File) Before(org.junit.Before)

Example 7 with CyApplicationManager

use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.

the class ViewWriterTest method setUp.

@Before
@SuppressWarnings("rawtypes")
public void setUp() throws Exception {
    final PresentationWriterManager viewWriterMgr = mock(PresentationWriterManager.class);
    final CyApplicationManager applicationManager = mock(CyApplicationManager.class);
    final RenderingEngineManager engineManager = mock(RenderingEngineManager.class);
    final CyNetworkView view = mock(CyNetworkView.class);
    final CyNetwork network = mock(CyNetwork.class);
    final CyRow row = mock(CyRow.class);
    final RenderingEngine re = mock(RenderingEngine.class);
    final CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyApplicationManager.class)).thenReturn(applicationManager);
    when(serviceRegistrar.getService(RenderingEngineManager.class)).thenReturn(engineManager);
    when(serviceRegistrar.getService(PresentationWriterManager.class)).thenReturn(viewWriterMgr);
    fileFilter = mock(CyFileFilter.class);
    when(fileFilter.getDescription()).thenReturn("A dummy filter");
    when(fileFilter.getExtensions()).thenReturn(Collections.singleton("dummy"));
    final List<CyFileFilter> filters = new ArrayList<>();
    filters.add(fileFilter);
    when(viewWriterMgr.getAvailableWriterFilters()).thenReturn(filters);
    when(view.getModel()).thenReturn(network);
    when(network.getRow(network)).thenReturn(row);
    cyWriter = new ViewWriter(view, re, serviceRegistrar);
    final CyWriter aWriter = mock(CyWriter.class);
    when(viewWriterMgr.getWriter(eq(view), eq(re), eq(fileFilter), argThat(new AnyOutputStreamMatcher()))).thenReturn(aWriter);
}
Also used : RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) PresentationWriterManager(org.cytoscape.io.write.PresentationWriterManager) CyWriter(org.cytoscape.io.write.CyWriter) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) CyRow(org.cytoscape.model.CyRow) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) CyApplicationManager(org.cytoscape.application.CyApplicationManager) RenderingEngine(org.cytoscape.view.presentation.RenderingEngine) CyFileFilter(org.cytoscape.io.CyFileFilter) CyNetworkView(org.cytoscape.view.model.CyNetworkView) ViewWriter(org.cytoscape.task.internal.export.ViewWriter) Before(org.junit.Before)

Example 8 with CyApplicationManager

use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.

the class ExportVizmapTaskFactoryImpl method createTaskIterator.

@Override
public TaskIterator createTaskIterator() {
    final VizmapWriterManager writerManager = serviceRegistrar.getService(VizmapWriterManager.class);
    final CyApplicationManager cyApplicationManager = serviceRegistrar.getService(CyApplicationManager.class);
    return new TaskIterator(2, new VizmapWriter(writerManager, cyApplicationManager, serviceRegistrar));
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) TaskIterator(org.cytoscape.work.TaskIterator) VizmapWriterManager(org.cytoscape.io.write.VizmapWriterManager)

Example 9 with CyApplicationManager

use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.

the class CySessionManagerImpl method restoreNetworkSelection.

private void restoreNetworkSelection(final CySession sess, final List<CyNetwork> selectedNets) {
    // If the current view/network was not set, set the first selected network as current
    if (!selectedNets.isEmpty()) {
        final CyNetwork cn = selectedNets.get(0);
        final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
        appMgr.setCurrentNetwork(cn);
        // Also set the current view, if there is one
        final CyNetworkViewManager nvMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
        final Collection<CyNetworkView> cnViews = nvMgr.getNetworkViews(cn);
        final CyNetworkView cv = cnViews.isEmpty() ? null : cnViews.iterator().next();
        appMgr.setCurrentNetworkView(cv);
        // The selected networks must be set after setting the current one!
        appMgr.setSelectedNetworks(selectedNets);
    }
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 10 with CyApplicationManager

use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.

the class CySessionManagerImpl method restoreCurrentVisualStyle.

private void restoreCurrentVisualStyle() {
    // Make sure the current visual style is the one applied to the current network view
    final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
    eventHelper.flushPayloadEvents();
    final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
    final CyNetworkView cv = appMgr.getCurrentNetworkView();
    if (cv != null) {
        final VisualMappingManager vmMgr = serviceRegistrar.getService(VisualMappingManager.class);
        final VisualStyle style = vmMgr.getVisualStyle(cv);
        if (style != null && !style.equals(vmMgr.getCurrentVisualStyle()))
            vmMgr.setCurrentVisualStyle(style);
    }
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyEventHelper(org.cytoscape.event.CyEventHelper) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Aggregations

CyApplicationManager (org.cytoscape.application.CyApplicationManager)80 CyNetwork (org.cytoscape.model.CyNetwork)40 CyNetworkView (org.cytoscape.view.model.CyNetworkView)30 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)18 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)16 CyNetworkManager (org.cytoscape.model.CyNetworkManager)14 CyEventHelper (org.cytoscape.event.CyEventHelper)12 CyTable (org.cytoscape.model.CyTable)12 ArrayList (java.util.ArrayList)11 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)10 CyNode (org.cytoscape.model.CyNode)9 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)9 Test (org.junit.Test)9 HashSet (java.util.HashSet)8 CyNetworkTableManager (org.cytoscape.model.CyNetworkTableManager)8 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)8 TaskIterator (org.cytoscape.work.TaskIterator)8 HashMap (java.util.HashMap)7 CyGroupManager (org.cytoscape.group.CyGroupManager)7 CyTableManager (org.cytoscape.model.CyTableManager)7