use of org.cytoscape.model.CyEdge in project cytoscape-impl by cytoscape.
the class SelectAdjacentEdgesTask method run.
@Override
public void run(final TaskMonitor tm) {
tm.setTitle("Select Adjacent Edges");
tm.setProgress(0.0);
final Collection<CyNetworkView> views = networkViewManager.getNetworkViews(network);
CyNetworkView view = null;
if (views.size() != 0)
view = views.iterator().next();
undoSupport.postEdit(new SelectionEdit(eventHelper, "Select Adjacent Edges", network, view, SelectionEdit.SelectionFilter.EDGES_ONLY));
tm.setStatusMessage("Selecting Edges...");
tm.setProgress(0.2);
final Set<CyEdge> edgeSet = new HashSet<>();
// Get the list of selected nodes
for (CyNode node : CyTableUtil.getNodesInState(network, CyNetwork.SELECTED, true)) {
// Get the list of edges connected to this node
edgeSet.addAll(network.getAdjacentEdgeList(node, CyEdge.Type.ANY));
}
tm.setProgress(0.3);
selectUtils.setSelectedEdges(network, edgeSet, true);
tm.setStatusMessage("Updating View...");
tm.setProgress(0.9);
updateView();
tm.setProgress(1.0);
}
use of org.cytoscape.model.CyEdge in project cytoscape-impl by cytoscape.
the class HideFromSelectionTask method run.
@Override
public void run(final TaskMonitor tm) {
tm.setProgress(0.0);
final CyNetwork network = view.getModel();
final List<CyIdentifiable> elements = new ArrayList<>();
List<CyNode> nodes = null;
List<CyEdge> edges = null;
if (hideNodes) {
nodes = CyTableUtil.getNodesInState(network, CyNetwork.SELECTED, selectionValue);
elements.addAll(nodes);
}
tm.setProgress(0.1);
if (hideEdges) {
edges = CyTableUtil.getEdgesInState(network, CyNetwork.SELECTED, selectionValue);
elements.addAll(edges);
}
final UndoSupport undoSupport = serviceRegistrar.getService(UndoSupport.class);
final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
final VisualMappingManager vmMgr = serviceRegistrar.getService(VisualMappingManager.class);
undoSupport.postEdit(new HideEdit(description, view, elements, false, eventHelper, vmMgr));
tm.setProgress(0.4);
if (nodes != null)
HideUtils.setVisibleNodes(nodes, false, view);
tm.setProgress(0.6);
if (edges != null)
HideUtils.setVisibleEdges(edges, false, view);
tm.setProgress(0.8);
VisualStyle style = vmMgr.getVisualStyle(view);
for (CyIdentifiable e : elements) {
View<? extends CyIdentifiable> ev = null;
if (e instanceof CyNode)
ev = view.getNodeView((CyNode) e);
else if (e instanceof CyEdge)
ev = view.getEdgeView((CyEdge) e);
if (ev != null)
style.apply(network.getRow(e), ev);
}
view.updateView();
tm.setProgress(1.0);
}
use of org.cytoscape.model.CyEdge in project cytoscape-impl by cytoscape.
the class RenameEdgeTask method run.
@Override
public void run(final TaskMonitor taskMonitor) {
if (network == null) {
taskMonitor.showMessage(TaskMonitor.Level.ERROR, "Network must be specified");
return;
}
if (edge == null) {
taskMonitor.showMessage(TaskMonitor.Level.ERROR, "Edge name or suid must be specified");
return;
}
if (newName == null) {
taskMonitor.showMessage(TaskMonitor.Level.ERROR, "New name must be specified");
return;
}
CyEdge renamedEdge = getEdge(network, edge);
network.getRow(renamedEdge).set(CyNetwork.NAME, newName);
taskMonitor.showMessage(TaskMonitor.Level.INFO, "Edge " + renamedEdge + " renamed to " + newName);
}
use of org.cytoscape.model.CyEdge 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.model.CyEdge in project cytoscape-impl by cytoscape.
the class NetworkLineParser method parseEntry.
public void parseEntry(final String[] parts) {
final CyNode source = createNode(parts, mapping.getSourceIndex());
final CyNode target = createNode(parts, mapping.getTargetIndex());
final SourceColumnSemantic[] types = mapping.getTypes();
final List<Integer> srcAttrIdxs = new ArrayList<>();
final List<Integer> tgtAttrIdxs = new ArrayList<>();
final List<Integer> edgeAttrIdxs = new ArrayList<>();
for (int i = 0; i < types.length; i++) {
if (types[i] == SourceColumnSemantic.SOURCE_ATTR)
srcAttrIdxs.add(i);
else if (types[i] == SourceColumnSemantic.TARGET_ATTR)
tgtAttrIdxs.add(i);
else if (types[i] == SourceColumnSemantic.EDGE_ATTR || types[i] == SourceColumnSemantic.ATTR)
edgeAttrIdxs.add(i);
}
if (source != null)
addAttributes(source, parts, srcAttrIdxs);
if (target != null)
addAttributes(target, parts, tgtAttrIdxs);
// Single column nodes list. Just add nodes.
if (source == null || target == null)
return;
final String interaction;
if ((mapping.getInteractionIndex() == -1) || (mapping.getInteractionIndex() > (parts.length - 1)) || (parts[mapping.getInteractionIndex()] == null)) {
interaction = mapping.getDefaultInteraction();
} else {
interaction = parts[mapping.getInteractionIndex()];
}
final CyEdge edge = network.addEdge(source, target, true);
network.getRow(edge).set(CyEdge.INTERACTION, interaction);
String edgeName = network.getRow(source).get(CyNetwork.NAME, String.class) + " (" + interaction + ") " + network.getRow(target).get(CyNetwork.NAME, String.class);
network.getRow(edge).set(CyNetwork.NAME, edgeName);
edgeList.add(edge.getSUID());
if (edge != null)
addAttributes(edge, parts, edgeAttrIdxs);
}
Aggregations