Search in sources :

Example 1 with ViewWriter

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));
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) TaskIterator(org.cytoscape.work.TaskIterator) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) ViewWriter(org.cytoscape.task.internal.export.ViewWriter)

Example 2 with ViewWriter

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);
}
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 3 with ViewWriter

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);
}
Also used : Task(org.cytoscape.work.Task) TaskIterator(org.cytoscape.work.TaskIterator) CyNetwork(org.cytoscape.model.CyNetwork) CyRow(org.cytoscape.model.CyRow) CyNetworkView(org.cytoscape.view.model.CyNetworkView) ViewWriter(org.cytoscape.task.internal.export.ViewWriter) Test(org.junit.Test)

Aggregations

ViewWriter (org.cytoscape.task.internal.export.ViewWriter)3 CyApplicationManager (org.cytoscape.application.CyApplicationManager)2 CyNetwork (org.cytoscape.model.CyNetwork)2 CyRow (org.cytoscape.model.CyRow)2 CyNetworkView (org.cytoscape.view.model.CyNetworkView)2 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)2 TaskIterator (org.cytoscape.work.TaskIterator)2 ArrayList (java.util.ArrayList)1 CyFileFilter (org.cytoscape.io.CyFileFilter)1 CyWriter (org.cytoscape.io.write.CyWriter)1 PresentationWriterManager (org.cytoscape.io.write.PresentationWriterManager)1 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)1 RenderingEngine (org.cytoscape.view.presentation.RenderingEngine)1 Task (org.cytoscape.work.Task)1 Before (org.junit.Before)1 Test (org.junit.Test)1