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);
}
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);
}
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));
}
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);
}
}
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);
}
}
Aggregations