use of org.cytoscape.task.internal.export.ViewWriter in project cytoscape-impl by cytoscape.
the class ExportNetworkImageTaskFactoryImpl method createTaskIterator.
@Override
public TaskIterator createTaskIterator(CyNetworkView view) {
// Get the rendering engine
RenderingEngine<?> engine = serviceRegistrar.getService(CyApplicationManager.class).getCurrentRenderingEngine();
// Now get the rendering engine for this view and use this one if we can
String engineId = view.getRendererId();
RenderingEngineManager engineManager = serviceRegistrar.getService(RenderingEngineManager.class);
for (RenderingEngine<?> e : engineManager.getRenderingEngines(view)) {
if (engineId.equals(e.getRendererId())) {
engine = e;
break;
}
}
return new TaskIterator(2, new ViewWriter(view, engine, serviceRegistrar));
}
use of org.cytoscape.task.internal.export.ViewWriter 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.task.internal.export.ViewWriter in project cytoscape-impl by cytoscape.
the class ExportNetworkImageTaskFactoryTest method testExportNetworkImageTaskFactory.
@Test
public void testExportNetworkImageTaskFactory() throws Exception {
final ExportNetworkImageTaskFactoryImpl factory = new ExportNetworkImageTaskFactoryImpl(serviceRegistrar);
final CyNetworkView view = mock(CyNetworkView.class);
final CyNetwork network = mock(CyNetwork.class);
final CyRow row = mock(CyRow.class);
when(view.getModel()).thenReturn(network);
when(network.getRow(network)).thenReturn(row);
final TaskIterator itr = factory.createTaskIterator(view);
assertNotNull(itr);
assertTrue(itr.hasNext());
final Task task = itr.next();
assertTrue(task instanceof ViewWriter);
}
Aggregations