Search in sources :

Example 6 with RenderingEngineManager

use of org.cytoscape.view.presentation.RenderingEngineManager in project cytoscape-impl by cytoscape.

the class CloneNetworkTaskTest method runTest.

@Test
public void runTest() {
    final CyNetworkManager netmgr = mock(CyNetworkManager.class);
    final CyNetworkViewManager networkViewManager = mock(CyNetworkViewManager.class);
    final CyNetworkViewFactory netViewFactory = mock(CyNetworkViewFactory.class);
    final RenderingEngineManager reManager = mock(RenderingEngineManager.class);
    final CyNetworkNaming naming = mock(CyNetworkNaming.class);
    final TaskMonitor tm = mock(TaskMonitor.class);
}
Also used : CyNetworkManager(org.cytoscape.model.CyNetworkManager) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) CyNetworkViewFactory(org.cytoscape.view.model.CyNetworkViewFactory) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) TaskMonitor(org.cytoscape.work.TaskMonitor) CyNetworkNaming(org.cytoscape.session.CyNetworkNaming) Test(org.junit.Test)

Example 7 with RenderingEngineManager

use of org.cytoscape.view.presentation.RenderingEngineManager 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 RenderingEngineManager

use of org.cytoscape.view.presentation.RenderingEngineManager in project cytoscape-impl by cytoscape.

the class ViewWriter method setView.

public void setView(CyNetworkView view) {
    this.view = view;
    if (view != null) {
        // 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;
            }
        }
        this.re = engine;
    }
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager)

Example 9 with RenderingEngineManager

use of org.cytoscape.view.presentation.RenderingEngineManager in project cytoscape-impl by cytoscape.

the class VisualStyleSerializer method createVizmap.

/**
 * This method creates a serializable Vizmap object based on the provided collection of visual styles.
 * @param styles The collection of VisualStyles that you wish to convert into a serializable object.
 * @return A Vizmap object that contains a representation of the collection of visual styles.
 */
public Vizmap createVizmap(final Collection<VisualStyle> styles) {
    final Vizmap vizmap = new Vizmap();
    final RenderingEngineManager renderingEngineManager = serviceRegistrar.getService(RenderingEngineManager.class);
    lexicon = renderingEngineManager.getDefaultVisualLexicon();
    if (styles != null) {
        for (VisualStyle style : styles) {
            org.cytoscape.io.internal.util.vizmap.model.VisualStyle vsModel = new org.cytoscape.io.internal.util.vizmap.model.VisualStyle();
            vizmap.getVisualStyle().add(vsModel);
            vsModel.setName(style.getTitle());
            vsModel.setNetwork(new Network());
            vsModel.setNode(new Node());
            vsModel.setEdge(new Edge());
            createVizmapProperties(style, BasicVisualLexicon.NETWORK, vsModel.getNetwork().getVisualProperty());
            createVizmapProperties(style, BasicVisualLexicon.NODE, vsModel.getNode().getVisualProperty());
            createVizmapProperties(style, BasicVisualLexicon.EDGE, vsModel.getEdge().getVisualProperty());
            // Create Dependencies
            createDependencies(style, vsModel);
        }
    }
    return vizmap;
}
Also used : RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) CyNode(org.cytoscape.model.CyNode) Node(org.cytoscape.io.internal.util.vizmap.model.Node) Vizmap(org.cytoscape.io.internal.util.vizmap.model.Vizmap) CyNetwork(org.cytoscape.model.CyNetwork) Network(org.cytoscape.io.internal.util.vizmap.model.Network) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) Edge(org.cytoscape.io.internal.util.vizmap.model.Edge) CyEdge(org.cytoscape.model.CyEdge)

Example 10 with RenderingEngineManager

use of org.cytoscape.view.presentation.RenderingEngineManager in project cytoscape-impl by cytoscape.

the class SessionXGMMLNetworkViewWriter method writeRootElementAtributes.

@Override
protected void writeRootElementAtributes() throws IOException {
    writeAttributePair("id", networkView.getSUID());
    writeAttributePair("label", getLabel(networkView));
    writeAttributePair("cy:view", ObjectTypeMap.toXGMMLBoolean(true));
    writeAttributePair("cy:networkId", network.getSUID());
    if (visualStyle != null)
        writeAttributePair("cy:visualStyle", visualStyle.getTitle());
    final RenderingEngineManager renderingEngineMgr = serviceRegistrar.getService(RenderingEngineManager.class);
    final Collection<RenderingEngine<?>> renderingEngines = renderingEngineMgr.getRenderingEngines(networkView);
    if (renderingEngines != null && !renderingEngines.isEmpty())
        writeAttributePair("cy:rendererId", renderingEngines.iterator().next().getRendererId());
}
Also used : RenderingEngine(org.cytoscape.view.presentation.RenderingEngine) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager)

Aggregations

RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)19 CyApplicationManager (org.cytoscape.application.CyApplicationManager)10 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)8 CyNetwork (org.cytoscape.model.CyNetwork)7 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)7 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)7 CyNetworkManager (org.cytoscape.model.CyNetworkManager)6 CyNetworkViewFactory (org.cytoscape.view.model.CyNetworkViewFactory)6 CyEventHelper (org.cytoscape.event.CyEventHelper)5 CyGroupManager (org.cytoscape.group.CyGroupManager)5 CyNetworkFactory (org.cytoscape.model.CyNetworkFactory)5 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)5 CyLayoutAlgorithmManager (org.cytoscape.view.layout.CyLayoutAlgorithmManager)5 RenderingEngine (org.cytoscape.view.presentation.RenderingEngine)5 TaskIterator (org.cytoscape.work.TaskIterator)5 TaskMonitor (org.cytoscape.work.TaskMonitor)5 NetworkViewTestSupport (org.cytoscape.ding.NetworkViewTestSupport)4 CyNode (org.cytoscape.model.CyNode)4 NetworkTestSupport (org.cytoscape.model.NetworkTestSupport)4 CyNetworkNaming (org.cytoscape.session.CyNetworkNaming)4