use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class DestroyNetworkViewsAction method updateEnableState.
@Override
public void updateEnableState() {
final List<CyNetwork> networks = serviceRegistrar.getService(CyApplicationManager.class).getSelectedNetworks();
final CyNetworkViewManager netViewManager = serviceRegistrar.getService(CyNetworkViewManager.class);
int count = 0;
for (CyNetwork n : networks) count += netViewManager.getNetworkViews(n).size();
if (count > 0)
setName("Destroy " + count + " View" + (count == 1 ? "" : "s"));
else
setName("Destroy Views");
setEnabled(count > 0);
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class SessionHandler method postLoading.
private final void postLoading(final CySession sess) {
NetworkList netList = null;
final Map<String, List<File>> filesMap = sess.getAppFileListMap();
if (filesMap != null) {
final List<File> files = filesMap.get(APP_NAME);
if (files != null) {
SessionState sessState = null;
for (File f : files) {
if (f.getName().endsWith(SESSION_STATE_FILENAME))
sessState = sessionIO.read(f, SessionState.class);
else if (f.getName().endsWith(NETWORK_LIST_FILENAME))
netList = sessionIO.read(f, NetworkList.class);
}
if (sessState != null)
setCytoPanelStates(sessState.getCytopanels());
}
}
if (netList == null) {
// Probably a Cy2 session file, which does not provide a separate "network_list" file
// so let's get the orders from the networks in the CySession file
// (we just assume the Session Reader sent the networks in the correct order in a LinkedHashSet)
final Set<CyNetwork> netSet = sess.getNetworks();
final Map<Long, Integer> netOrder = new HashMap<>();
int count = 0;
for (CyNetwork n : netSet) netOrder.put(n.getSUID(), count++);
setSessionNetworks(netOrder);
} else {
setSessionNetworks(netList.getNetwork(), sess);
}
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class SessionHandler method setSessionNetworks.
private void setSessionNetworks(final List<Network> netInfoList, final CySession sess) {
final Map<Long, Integer> netOrder = new HashMap<>();
for (final Network n : netInfoList) {
// in order to retrieve the new SUID
final CyNetwork net = sess.getObject(n.getId(), CyNetwork.class);
if (net != null)
netOrder.put(net.getSUID(), n.getOrder());
}
setSessionNetworks(netOrder);
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class SelectFirstNeighborsNodeViewTask method run.
public void run(TaskMonitor tm) throws Exception {
tm.setProgress(0.0);
if (nodeView == null)
throw new NullPointerException("node view is null");
if (netView == null)
throw new NullPointerException("network view is null");
final Set<CyNode> selNodes = new HashSet<CyNode>();
final CyNode node = nodeView.getModel();
final CyNetwork net = netView.getModel();
tm.setProgress(0.1d);
selNodes.add(node);
tm.setProgress(0.4d);
selNodes.addAll(net.getNeighborList(node, direction));
tm.setProgress(0.6d);
selectUtils.setSelectedNodes(net, selNodes, true);
tm.setProgress(0.8d);
netView.updateView();
tm.setProgress(1.0d);
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class AbstractOpenSessionTask method disposeCancelledSession.
protected void disposeCancelledSession(Exception e, CySessionManager sessionManager) {
if (reader == null)
return;
final CySession newSession = reader.getSession();
if (newSession != null) {
// Destroy any new views and networks
for (CyNetworkView view : newSession.getNetworkViews()) view.dispose();
CyRootNetworkManager rootNetManager = serviceRegistrar.getService(CyRootNetworkManager.class);
final Set<CyRootNetwork> rootNetworks = new HashSet<>();
for (CyNetwork net : newSession.getNetworks()) rootNetworks.add(rootNetManager.getRootNetwork(net));
for (CyRootNetwork rootNet : rootNetworks) rootNet.dispose();
}
// Reset the Group Manager, because groups can be registered by the reader
// TODO Remove this after groups no longer registered inside the IO bundle.
serviceRegistrar.getService(CyGroupManager.class).reset();
// Destroy any global tables registered by the reader
serviceRegistrar.getService(CyTableManager.class).reset();
// Set a new, empty session
sessionManager.setCurrentSession(null, null);
}
Aggregations