use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class GetEdgePropertiesTask method run.
@Override
public void run(final TaskMonitor taskMonitor) {
edgePropertiesMap = new HashMap<CyEdge, Map<String, VisualPropertyObjectTuple>>();
CyNetwork network = edgeTunable.getNetwork();
if (propertyList == null || propertyList.length() == 0) {
taskMonitor.showMessage(TaskMonitor.Level.ERROR, "Property list must be specified");
return;
}
// Get the list of properties
String[] props = propertyList.split(",");
for (CyEdge edge : edgeTunable.getEdgeList()) {
taskMonitor.showMessage(TaskMonitor.Level.INFO, " Edge property values for edge " + DataUtils.getEdgeName(network.getDefaultEdgeTable(), edge) + ":");
Map<String, VisualPropertyObjectTuple> propertyMap = new HashMap<String, VisualPropertyObjectTuple>();
for (String property : props) {
try {
VisualProperty vp = getProperty(network, edge, property.trim());
Object value = getPropertyValue(network, edge, vp);
if (value != null) {
taskMonitor.showMessage(TaskMonitor.Level.INFO, " " + vp.getDisplayName() + "=" + value.toString());
propertyMap.put(vp.getIdString(), new VisualPropertyObjectTuple(vp, value));
}
} catch (Exception e) {
taskMonitor.showMessage(TaskMonitor.Level.ERROR, e.getMessage());
return;
}
}
edgePropertiesMap.put(edge, propertyMap);
}
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class UnGroupNodesTaskFactoryImpl method isReady.
public boolean isReady(CyNetworkView netView) {
if (netView == null) {
return false;
}
// Get all of the selected nodes
CyNetwork net = netView.getModel();
final List<CyNode> selNodes = CyTableUtil.getNodesInState(net, CyNetwork.SELECTED, true);
if (getGroups(net, selNodes).size() > 0)
return true;
return false;
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class UnGroupNodesTaskFactoryImpl method createTaskIterator.
public TaskIterator createTaskIterator(CyNetworkView netView) {
CyNetwork net = netView.getModel();
final List<CyNode> selNodes = CyTableUtil.getNodesInState(net, CyNetwork.SELECTED, true);
Set<CyGroup> groups = getGroups(net, selNodes);
return new TaskIterator(new UnGroupNodesTask(undoSupport, netView.getModel(), factory, groups, mgr, netView));
}
use of org.cytoscape.model.CyNetwork 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.CyNetwork in project cytoscape-impl by cytoscape.
the class GroupNodesTaskFactoryImpl method isReady.
public boolean isReady(View<CyNode> nodeView, CyNetworkView netView) {
if (nodeView == null || netView == null)
return false;
// Get all of the selected nodes
CyNetwork net = netView.getModel();
final List<CyNode> selNodes = CyTableUtil.getNodesInState(net, CyNetwork.SELECTED, true);
return (selNodes.size() > 1);
}
Aggregations