use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.
the class AbstractSessionReader method cleanUp.
/**
* Use this methods to dispose temporary resources.
* This method must always be invoked, even if this task is cancelled.
*/
protected void cleanUp(TaskMonitor tm) {
try {
((ReusableInputStream) sourceInputStream).reallyClose();
} catch (Exception e) {
logger.error("Error closing source input stream.", e);
}
if (cancelled) {
// Destroy groups
final Set<CyGroup> groups = groupUtil.getGroups(cache.getNetworks());
groupUtil.destroyGroups(groups);
// Dispose CyNetworkViews and CyNetworks
for (final CyNetworkView view : networkViews) view.dispose();
final CyRootNetworkManager rootNetworkManager = serviceRegistrar.getService(CyRootNetworkManager.class);
final Set<CyRootNetwork> rootNetworks = new HashSet<>();
// such as group networks.
for (final CyNetwork net : cache.getNetworks()) {
net.dispose();
rootNetworks.add(rootNetworkManager.getRootNetwork(net));
}
for (final CyRootNetwork rootNet : rootNetworks) rootNet.dispose();
networkViews.clear();
networks.clear();
}
cache.dispose();
SessionUtil.setReadingSessionFile(false);
}
use of org.cytoscape.group.CyGroup 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.group.CyGroup in project cytoscape-impl by cytoscape.
the class GroupNodeContextTaskFactoryImpl method createTaskIterator.
@Override
public TaskIterator createTaskIterator(View<CyNode> nodeView, CyNetworkView netView) {
List<CyGroup> groups = new ArrayList<CyGroup>();
final List<CyNode> selNodes = CyTableUtil.getNodesInState(netView.getModel(), CyNetwork.SELECTED, true);
if (collapse) {
// Always add the context node, whether it's selected or not
groups.add(getExpandedGroupForNode(nodeView.getModel(), netView));
for (CyNode node : selNodes) {
CyGroup g = getExpandedGroupForNode(node, netView);
if (g != null)
groups.add(g);
}
} else {
groups.add(mgr.getGroup(nodeView.getModel(), netView.getModel()));
for (CyNode node : selNodes) {
CyGroup g = mgr.getGroup(node, netView.getModel());
if (g != null)
groups.add(g);
}
}
return new TaskIterator(new CollapseGroupTask(netView.getModel(), groups, mgr, collapse));
}
use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.
the class AbstractGroupTask method getGroupSetString.
protected String getGroupSetString(Collection<CyGroup> groups) {
StringBuilder buffer = new StringBuilder();
StringJoiner joiner = new StringJoiner(",");
for (CyGroup group : groups) joiner.add(group.getGroupNode().getSUID().toString());
return joiner.toString();
}
use of org.cytoscape.group.CyGroup in project cytoscape-impl by cytoscape.
the class AbstractGroupTask method getGroup.
protected CyGroup getGroup(String groupName) {
CyRootNetwork rootNet = ((CySubNetwork) net).getRootNetwork();
Set<CyGroup> allGroups = groupMgr.getGroupSet(net);
for (CyGroup group : allGroups) {
CyRow groupRow = rootNet.getRow(group.getGroupNode(), CyRootNetwork.SHARED_ATTRS);
if (groupName.length() > 5 && groupName.substring(0, 5).equalsIgnoreCase("suid:")) {
String suidString = groupRow.get(CyNetwork.SUID, Long.class).toString();
if (suidString != null && groupName.substring(5).equals(suidString))
return group;
} else if (groupName.equals(groupRow.get(CyRootNetwork.SHARED_NAME, String.class)))
return group;
}
return null;
}
Aggregations