Search in sources :

Example 6 with CyNetworkViewFactory

use of org.cytoscape.view.model.CyNetworkViewFactory in project cytoscape-impl by cytoscape.

the class LayoutEdgeTest method testLayoutEdgeConstructor2.

@Test
public void testLayoutEdgeConstructor2() {
    CyNetworkFactory nFactory = support.getNetworkFactory();
    CyNetwork newNetwork = nFactory.createNetwork();
    CyNode s = newNetwork.addNode();
    CyNode t = newNetwork.addNode();
    CyEdge e = newNetwork.addEdge(s, t, true);
    final CyNetworkViewFactory viewFactory = support.getNetworkViewFactory();
    CyNetworkView newView = viewFactory.createNetworkView(newNetwork);
    final View<CyNode> sourceView = newView.getNodeView(s);
    final View<CyNode> targetView = newView.getNodeView(t);
    assertNotNull(sourceView);
    assertNotNull(targetView);
    CyRow sRow = newNetwork.getRow(s);
    CyRow tRow = newNetwork.getRow(t);
    final LayoutNode layoutNodeS = new LayoutNode(sourceView, 0, sRow);
    final LayoutNode layoutNodeT = new LayoutNode(targetView, 1, tRow);
    final LayoutEdge layoutEdge2 = new LayoutEdge(e, layoutNodeS, layoutNodeT, newNetwork.getRow(e));
    assertNotNull(layoutEdge2);
}
Also used : CyNetworkViewFactory(org.cytoscape.view.model.CyNetworkViewFactory) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkFactory(org.cytoscape.model.CyNetworkFactory) CyNode(org.cytoscape.model.CyNode) CyRow(org.cytoscape.model.CyRow) CyEdge(org.cytoscape.model.CyEdge) CyNetworkView(org.cytoscape.view.model.CyNetworkView) Test(org.junit.Test)

Example 7 with CyNetworkViewFactory

use of org.cytoscape.view.model.CyNetworkViewFactory in project cytoscape-impl by cytoscape.

the class OBOReader method buildCyNetworkView.

@Override
public CyNetworkView buildCyNetworkView(final CyNetwork net) {
    final CyNetworkViewFactory netViewFactory = serviceRegistrar.getService(CyApplicationManager.class).getDefaultNetworkViewRenderer().getNetworkViewFactory();
    final CyNetworkView view = netViewFactory.createNetworkView(ontologyDAG);
    return view;
}
Also used : CyNetworkViewFactory(org.cytoscape.view.model.CyNetworkViewFactory) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 8 with CyNetworkViewFactory

use of org.cytoscape.view.model.CyNetworkViewFactory in project cytoscape-impl by cytoscape.

the class DefaultNetworkViewFactory method createNetworkView.

@Override
public CyNetworkView createNetworkView(CyNetwork network) {
    NetworkViewRenderer renderer = applicationManager.getDefaultNetworkViewRenderer();
    CyNetworkViewFactory viewFactory = renderer.getNetworkViewFactory();
    return viewFactory.createNetworkView(network);
}
Also used : CyNetworkViewFactory(org.cytoscape.view.model.CyNetworkViewFactory) NetworkViewRenderer(org.cytoscape.application.NetworkViewRenderer)

Example 9 with CyNetworkViewFactory

use of org.cytoscape.view.model.CyNetworkViewFactory in project cytoscape-impl by cytoscape.

the class LayoutEdgeTest method createLayoutNodes.

private void createLayoutNodes() {
    CyNetworkFactory nFactory = support.getNetworkFactory();
    CyNetwork newNetwork = nFactory.createNetwork();
    CyNode s = newNetwork.addNode();
    CyNode t = newNetwork.addNode();
    final CyNetworkViewFactory viewFactory = support.getNetworkViewFactory();
    CyNetworkView newView = viewFactory.createNetworkView(newNetwork);
    final View<CyNode> sourceView = newView.getNodeView(s);
    final View<CyNode> targetView = newView.getNodeView(t);
    CyRow sRow = newNetwork.getRow(s);
    CyRow tRow = newNetwork.getRow(t);
    layoutNodeS = new LayoutNode(sourceView, 0, sRow);
    layoutNodeT = new LayoutNode(targetView, 1, tRow);
}
Also used : CyNetworkViewFactory(org.cytoscape.view.model.CyNetworkViewFactory) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkFactory(org.cytoscape.model.CyNetworkFactory) CyNode(org.cytoscape.model.CyNode) CyRow(org.cytoscape.model.CyRow) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 10 with CyNetworkViewFactory

use of org.cytoscape.view.model.CyNetworkViewFactory in project cytoscape-impl by cytoscape.

the class AbstractNetworkFromSelectionTask method run.

@Override
public void run(TaskMonitor tm) {
    if (parentNetwork == null) {
        tm.showMessage(TaskMonitor.Level.ERROR, "Source network must be specified.");
        return;
    }
    tm.setProgress(0.0);
    final Collection<CyNetworkView> views = networkViewManager.getNetworkViews(parentNetwork);
    CyNetworkView sourceView = null;
    if (views.size() != 0)
        sourceView = views.iterator().next();
    tm.setProgress(0.1);
    // Get the selected nodes
    final Set<CyNode> nodes = getNodes(parentNetwork);
    tm.setProgress(0.2);
    if (// return;
    nodes.size() <= 0)
        throw new IllegalArgumentException("No nodes are selected.");
    // create subnetwork and add selected nodes and appropriate edges
    newNet = rootNetMgr.getRootNetwork(parentNetwork).addSubNetwork();
    // We need to cpy the columns to local tables, since copying them to default table will duplicate the virtual columns.
    addColumns(parentNetwork.getTable(CyNode.class, CyNetwork.LOCAL_ATTRS), newNet.getTable(CyNode.class, CyNetwork.LOCAL_ATTRS));
    addColumns(parentNetwork.getTable(CyEdge.class, CyNetwork.LOCAL_ATTRS), newNet.getTable(CyEdge.class, CyNetwork.LOCAL_ATTRS));
    addColumns(parentNetwork.getTable(CyNetwork.class, CyNetwork.LOCAL_ATTRS), newNet.getTable(CyNetwork.class, CyNetwork.LOCAL_ATTRS));
    tm.setProgress(0.3);
    for (final CyNode node : nodes) {
        newNet.addNode(node);
        cloneRow(parentNetwork.getRow(node), newNet.getRow(node));
        // Set rows and edges to not selected state to avoid conflicts with table browser
        newNet.getRow(node).set(CyNetwork.SELECTED, false);
        if (groupMgr.isGroup(node, parentNetwork)) {
            CyGroup group = groupMgr.getGroup(node, parentNetwork);
            GroupUtils.addGroupToNetwork(group, parentNetwork, newNet);
        }
    }
    tm.setProgress(0.4);
    for (final CyEdge edge : getEdges(parentNetwork)) {
        newNet.addEdge(edge);
        cloneRow(parentNetwork.getRow(edge), newNet.getRow(edge));
        // Set rows and edges to not selected state to avoid conflicts with table browser
        newNet.getRow(edge).set(CyNetwork.SELECTED, false);
    }
    tm.setProgress(0.5);
    newNet.getRow(newNet).set(CyNetwork.NAME, getNetworkName());
    DataUtils.saveParentNetworkSUID(newNet, parentNetwork.getSUID());
    networkManager.addNetwork(newNet, false);
    tm.setProgress(0.6);
    // create the view in a separate task
    final Set<CyNetwork> networks = new HashSet<CyNetwork>();
    networks.add(newNet);
    // Pick a CyNetworkViewFactory that is appropriate for the sourceView
    CyNetworkViewFactory sourceViewFactory = viewFactory;
    if (sourceView != null) {
        NetworkViewRenderer networkViewRenderer = appMgr.getNetworkViewRenderer(sourceView.getRendererId());
        if (networkViewRenderer != null) {
            sourceViewFactory = networkViewRenderer.getNetworkViewFactory();
        }
    }
    final CreateNetworkViewTask createViewTask = new CreateNetworkViewTask(undoSupport, networks, sourceViewFactory, networkViewManager, networkManager, null, eventHelper, vmMgr, renderingEngineMgr, appMgr, sourceView, serviceRegistrar);
    insertTasksAfterCurrentTask(createViewTask);
    /*
		insertTasksAfterCurrentTask(createViewTask, new AbstractTask() {
			@Override
			@SuppressWarnings("unchecked")
			public void run(final TaskMonitor tm) throws Exception {
				// Select the new view
				tm.setProgress(0.0);
				final List<CyNetworkView> createdViews = (List<CyNetworkView>) createViewTask.getResults(List.class);
				
				if (!createdViews.isEmpty()) {
					CyNetworkView nv = createdViews.get(createdViews.size() - 1);

					if (nv != null) {
						insertTasksAfterCurrentTask(new RegisterNetworkTask(nv, null, networkManager, vmMgr, appMgr, networkViewManager));
						return;
					}
				}
				insertTasksAfterCurrentTask(new RegisterNetworkTask(newNet, networkManager, vmMgr, appMgr, networkViewManager));
				
				tm.setProgress(1.0);
			}
		});
		*/
    tm.setProgress(1.0);
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) CyEdge(org.cytoscape.model.CyEdge) CyGroup(org.cytoscape.group.CyGroup) CyNetworkViewFactory(org.cytoscape.view.model.CyNetworkViewFactory) CreateNetworkViewTask(org.cytoscape.task.internal.view.CreateNetworkViewTask) CyNode(org.cytoscape.model.CyNode) CyNetworkView(org.cytoscape.view.model.CyNetworkView) HashSet(java.util.HashSet) NetworkViewRenderer(org.cytoscape.application.NetworkViewRenderer)

Aggregations

CyNetworkViewFactory (org.cytoscape.view.model.CyNetworkViewFactory)14 CyNetwork (org.cytoscape.model.CyNetwork)7 CyNetworkFactory (org.cytoscape.model.CyNetworkFactory)7 CyNetworkManager (org.cytoscape.model.CyNetworkManager)7 CyNode (org.cytoscape.model.CyNode)7 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)7 CyApplicationManager (org.cytoscape.application.CyApplicationManager)6 CyNetworkView (org.cytoscape.view.model.CyNetworkView)6 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)6 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)6 CyEventHelper (org.cytoscape.event.CyEventHelper)5 CyGroupManager (org.cytoscape.group.CyGroupManager)5 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)5 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)5 CyLayoutAlgorithmManager (org.cytoscape.view.layout.CyLayoutAlgorithmManager)5 NetworkViewRenderer (org.cytoscape.application.NetworkViewRenderer)4 CyEdge (org.cytoscape.model.CyEdge)4 CyNetworkNaming (org.cytoscape.session.CyNetworkNaming)4 UndoSupport (org.cytoscape.work.undo.UndoSupport)4 Test (org.junit.Test)4