use of org.cytoscape.model.CyEdge in project cytoscape-impl by cytoscape.
the class CySubNetworkTest method testAddNewEdgeEventBeforeNetworkAdd.
@Test
public void testAddNewEdgeEventBeforeNetworkAdd() {
CySubNetwork sub = root.addSubNetwork();
CyNode nx1 = sub.addNode();
CyNode nx2 = sub.addNode();
CyEdge ex1 = sub.addEdge(nx1, nx2, false);
Object payload = deh.getLastPayload();
assertNull(payload);
}
use of org.cytoscape.model.CyEdge in project cytoscape-impl by cytoscape.
the class VizMapperMediator method createPreviewNetworkView.
private void createPreviewNetworkView() {
// Create dummy view first
final CyNetwork net = servicesUtil.get(CyNetworkFactory.class).createNetworkWithPrivateTables(SavePolicy.DO_NOT_SAVE);
final CyNode source = net.addNode();
final CyNode target = net.addNode();
net.getRow(source).set(CyNetwork.NAME, "Source");
net.getRow(target).set(CyNetwork.NAME, "Target");
final CyEdge edge = net.addEdge(source, target, true);
net.getRow(edge).set(CyNetwork.NAME, "Source (interaction) Target");
net.getRow(net).set(CyNetwork.NAME, "Default Appearance");
final CyNetworkView view = servicesUtil.get(CyNetworkViewFactory.class).createNetworkView(net);
// Set node locations
view.getNodeView(source).setVisualProperty(NODE_X_LOCATION, 0d);
view.getNodeView(source).setVisualProperty(NODE_Y_LOCATION, 0d);
view.getNodeView(target).setVisualProperty(NODE_X_LOCATION, 150d);
view.getNodeView(target).setVisualProperty(NODE_Y_LOCATION, 20d);
previewNetView = view;
}
use of org.cytoscape.model.CyEdge in project cytoscape-impl by cytoscape.
the class GetGroupTask method groupJSON.
public String groupJSON(CyNetwork network, CyGroup group) {
this.jsonUtil = serviceRegistrar.getService(CyJSONUtil.class);
long suid = group.getGroupNode().getSUID();
List<CyNode> nodes = group.getNodeList();
List<CyEdge> internalEdges = group.getInternalEdgeList();
Set<CyEdge> externalEdges = group.getExternalEdgeList();
CyRow groupRow = ((CySubNetwork) net).getRootNetwork().getRow(group.getGroupNode(), CyRootNetwork.SHARED_ATTRS);
String name = groupRow.get(CyRootNetwork.SHARED_NAME, String.class);
String result = "{\"group\":" + suid + "," + "\"name\":\"" + name + "\",";
result += "\"nodes\":" + jsonUtil.cyIdentifiablesToJson(nodes) + ",";
result += "\"internalEdges\":" + jsonUtil.cyIdentifiablesToJson(internalEdges) + ",";
result += "\"externalEdges\":" + jsonUtil.cyIdentifiablesToJson(externalEdges) + ",";
result += "\"collapsed\":";
if (group.isCollapsed(network))
result += "true";
else
result += "false";
result += "}";
return result;
}
use of org.cytoscape.model.CyEdge in project cytoscape-impl by cytoscape.
the class GroupEdit method createShadowGroup.
private void createShadowGroup(CyGroup group) {
// Get the nodes, edges, and external edges
nodeMap.put(group, group.getNodeList());
List<CyEdge> edgesList = new ArrayList<CyEdge>(group.getInternalEdgeList());
edgesList.addAll(group.getExternalEdgeList());
edgesMap.put(group, edgesList);
// Get the networks
networkMap.put(group, new ArrayList<CyNetwork>(group.getNetworkSet()));
// Get the collapse set
List<CyNetwork> collapseList = new ArrayList<CyNetwork>();
for (CyNetwork net : group.getNetworkSet()) {
if (group.isCollapsed(net)) {
collapseList.add(net);
}
}
collapseMap.put(group, collapseList);
}
use of org.cytoscape.model.CyEdge in project cytoscape-impl by cytoscape.
the class RemoveFromGroupTask method run.
@Override
public void run(TaskMonitor tm) throws Exception {
net = nodesAndEdges.getNetwork();
if (groupName == null) {
tm.showMessage(TaskMonitor.Level.ERROR, "Group must be specified");
return;
}
CyGroup grp = getGroup(groupName);
if (grp == null) {
tm.showMessage(TaskMonitor.Level.ERROR, "Can't find group '" + groupName + "' in network: " + net.toString());
return;
}
List<CyEdge> edgeList = nodesAndEdges.getEdgeList(false);
List<CyNode> nodeList = nodesAndEdges.getNodeList(false);
if (edgeList == null && nodeList == null) {
tm.showMessage(TaskMonitor.Level.ERROR, "Nothing to remove");
return;
}
int edges = 0;
if (edgeList != null)
edges = edgeList.size();
int nodes = 0;
if (nodeList != null)
nodes = nodeList.size();
tm.showMessage(TaskMonitor.Level.INFO, "Removing " + nodes + " nodes and " + edges + " edges from group " + getGroupDesc(grp));
if (edgeList != null && edgeList.size() > 0) {
grp.removeEdges(edgeList);
}
if (nodeList != null && nodeList.size() > 0) {
grp.removeNodes(nodeList);
}
tm.showMessage(TaskMonitor.Level.INFO, "Removed " + nodes + " nodes and " + edges + " edges from group " + getGroupDesc(grp));
}
Aggregations