use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.
the class DestroyNetworkTask method destroyNetwork.
private void destroyNetwork(final CyNetwork net, CyNetworkManager netManager) {
CyRootNetwork rootNet = null;
CySubNetwork parentNet = null;
if (net instanceof CySubNetwork) {
rootNet = ((CySubNetwork) net).getRootNetwork();
final Long suid = DataUtils.getParentNetworkSUID((CySubNetwork) net);
if (suid != null && netManager.getNetwork(suid) instanceof CySubNetwork)
parentNet = (CySubNetwork) netManager.getNetwork(suid);
}
netManager.destroyNetwork(net);
if (net instanceof CySubNetwork)
updateParentNetworkData(net.getSUID(), rootNet, (parentNet != null ? parentNet.getSUID() : null));
}
use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.
the class GroupViewCollapseHandler method addMemberEdges.
private void addMemberEdges(CyGroup group, CyNetwork network) {
CyRootNetwork rootNetwork = ((CySubNetwork) network).getRootNetwork();
CyNode groupNode = group.getGroupNode();
List<CyEdge> newEdges = new ArrayList<CyEdge>();
for (CyNode node : group.getNodeList()) {
if (!network.containsEdge(groupNode, node)) {
CyEdge edge = network.addEdge(groupNode, node, true);
CyRow edgeRow = network.getRow(edge);
CyRow edgeRootRow = rootNetwork.getRow(edge, CyRootNetwork.SHARED_ATTRS);
// Add a name
String name = getNodeName(groupNode, network) + " (member) " + getNodeName(node, network);
edgeRow.set(CyNetwork.NAME, name);
edgeRootRow.set(CyRootNetwork.SHARED_NAME, name);
// Set the interaction
edgeRow.set(CyEdge.INTERACTION, "member");
edgeRootRow.set(CyRootNetwork.SHARED_INTERACTION, "member");
newEdges.add(edge);
}
}
if (newEdges.size() > 0)
group.addEdges(newEdges);
}
use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.
the class GroupViewCollapseHandler method handleEvent.
@Override
public void handleEvent(GroupAboutToCollapseEvent e) {
getServices();
CyNetwork network = e.getNetwork();
CyGroup group = e.getSource();
CyRootNetwork rootNetwork = group.getRootNetwork();
final Collection<CyNetworkView> views = cyNetworkViewManager.getNetworkViews(network);
CyNetworkView view = null;
if (views.size() == 0)
return;
for (CyNetworkView v : views) {
if (v.getRendererId().equals("org.cytoscape.ding")) {
view = v;
}
}
if (view == null)
return;
GroupViewType groupViewType = cyGroupSettings.getGroupViewType(group);
if (e.collapsing()) {
// Calculate the center position of all of the
// member nodes
Dimension center = ViewUtils.calculateCenter(view, group.getNodeList());
if (center != null) {
// Save it in the groupNode attribute
ViewUtils.updateGroupLocation(network, group, center);
// save it in the node's attribute
for (CyNode node : group.getNodeList()) {
if (!network.containsNode(node))
continue;
Dimension offset = ViewUtils.calculateOffset(center, view, node);
ViewUtils.updateNodeOffset(network, group, node, offset);
}
}
} else {
// Get the current position of the groupNode
View<CyNode> nView = view.getNodeView(group.getGroupNode());
if (nView == null)
return;
double x = nView.getVisualProperty(xLoc);
double y = nView.getVisualProperty(yLoc);
// Save it in the groupNode attribute
ViewUtils.updateGroupLocation(network, group, x, y);
}
}
use of org.cytoscape.model.subnetwork.CyRootNetwork in project cytoscape-impl by cytoscape.
the class GroupViewDoubleClickListener method getGroupName.
String getGroupName(CyGroup group) {
CyRootNetwork rootNetwork = group.getRootNetwork();
String name = rootNetwork.getRow(group.getGroupNode(), CyRootNetwork.SHARED_ATTRS).get(CyRootNetwork.SHARED_NAME, String.class);
return name;
}
use of org.cytoscape.model.subnetwork.CyRootNetwork 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);
}
Aggregations