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