use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.
the class CoSELayoutAlgorithmTask method traverseLNodeTree.
private void traverseLNodeTree(final LayoutNode layoutNode, final LGraph graph, final CoSELayout cose, final Map<CyNode, LNode> lNodeMap, final Map<CyNode, LayoutNode> layoutNodeMap, final CyGroupManager groupManager) {
if (lNodeMap.containsKey(layoutNode.getNode()))
// This node has already been visited!
return;
final LNode ln = createLNode(layoutNode, graph, cose, lNodeMap);
if (groupManager.isGroup(layoutNode.getNode(), networkView.getModel())) {
final CyGroup group = groupManager.getGroup(layoutNode.getNode(), networkView.getModel());
if (group != null) {
final LGraphManager gm = cose.getGraphManager();
final LGraph subGraph = gm.add(cose.newGraph("G" + group.getGroupNetwork().getSUID()), ln);
for (CyNode childNode : group.getNodeList()) {
final LayoutNode childLayoutNode = layoutNodeMap.get(childNode);
if (childLayoutNode != null)
traverseLNodeTree(childLayoutNode, subGraph, cose, lNodeMap, layoutNodeMap, groupManager);
}
}
}
}
use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.
the class CloneNetworkTask method cloneGroups.
private void cloneGroups(final CyNetwork origNet, final CyNetwork newNet) {
// Get all of the groups in our original network
Set<CyGroup> origGroups = groupMgr.getGroupSet(origNet);
// edges
for (CyGroup origGroup : origGroups) {
if (origGroup.isCollapsed(origNet)) {
for (CyNode origNode : origGroup.getNodeList()) {
// add the node back into the network
((CySubNetwork) origNet).addNode(origNode);
cloneNode(origNet, newNet, origNode);
}
}
}
// Now, we can clone the group itself
for (CyGroup origGroup : origGroups) {
cloneGroup(origNet, newNet, origGroup);
}
}
use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.
the class CloneNetworkTask method cloneGroup.
private CyGroup cloneGroup(final CyNetwork origNet, final CyNetwork newNet, final CyGroup origGroup) {
List<CyNode> nodeList = new ArrayList<CyNode>();
List<CyEdge> edgeList = new ArrayList<CyEdge>();
// Check to see if the group node is already in the network
boolean groupNodeExists = origNet.containsNode(origGroup.getGroupNode());
boolean collapsed = origGroup.isCollapsed(origNet);
if (collapsed)
origGroup.expand(origNet);
else {
// If we're not collapsed, we need to clone the group node and it's edges
CyNode groupNode = origGroup.getGroupNode();
// If the node already exists, we shouldn't need to do anything
if (!groupNodeExists) {
((CySubNetwork) origNet).addNode(groupNode);
cloneNode(origNet, newNet, groupNode);
// Now remove it
((CySubNetwork) origNet).removeNodes(Collections.singletonList(groupNode));
// TODO: What about non-meta edges?
}
}
// Get the list of nodes for the group
for (CyNode node : origGroup.getNodeList()) {
nodeList.add(orig2NewNodeMap.get(node));
}
for (CyEdge iEdge : origGroup.getInternalEdgeList()) {
cloneEdge(origNet, newNet, iEdge);
}
for (CyEdge eEdge : origGroup.getExternalEdgeList()) {
cloneEdge(origNet, newNet, eEdge);
}
// Get the group node
CyNode newNode = orig2NewNodeMap.get(origGroup.getGroupNode());
// Copy our metaEdge information (if any), which is stored in the root network hidden table
cloneMetaEdgeInfo(origNet, newNet, origGroup);
// Create the group
CyGroup newGroup = groupFactory.createGroup(newNet, newNode, nodeList, null, true);
// We need to update all of our positions hints
cloneGroupTables(origNet, newNet, origGroup, newGroup);
if (!groupNodeExists) {
// Because we're providing a group node with a network pointer, the groups code
// is going to think we're coming from a session. We need to remove the group node
newNet.removeNodes(Collections.singletonList(newNode));
}
if (collapsed) {
// ...and collapse it...
origGroup.collapse(origNet);
newGroup.collapse(newNet);
}
return newGroup;
}
use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.
the class AbstractGroupTask method getGroupList.
protected List<CyGroup> getGroupList(TaskMonitor tm, String groupList) {
Set<CyGroup> allGroups = groupMgr.getGroupSet(net);
if (groupList.equalsIgnoreCase("all")) {
return new ArrayList<CyGroup>(allGroups);
} else if (groupList.equalsIgnoreCase("selected")) {
return getSelectedGroups();
} else if (groupList.equalsIgnoreCase("unselected")) {
return getUnselectedGroups();
}
String[] groups = DataUtils.getCSV(groupList);
List<CyGroup> returnGroups = new ArrayList<CyGroup>();
for (String groupName : groups) {
CyGroup group = getGroup(groupName);
if (group != null) {
returnGroups.add(group);
} else {
tm.showMessage(TaskMonitor.Level.ERROR, "Unable to find group '" + groupName + "' in network " + net);
return null;
}
}
return returnGroups;
}
use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.
the class ListGroupsTask method run.
public void run(TaskMonitor tm) throws Exception {
if (network == null) {
network = appMgr.getCurrentNetwork();
}
net = network;
groups = getGroupList(tm, "all");
if (groups == null)
return;
tm.showMessage(TaskMonitor.Level.INFO, "Groups in network: " + network);
for (CyGroup group : groups) {
tm.showMessage(TaskMonitor.Level.INFO, " " + getGroupDesc(group));
}
tm.setProgress(1.0d);
}
Aggregations