use of org.cytoscape.internal.view.SubNetworkPanel in project cytoscape-impl by cytoscape.
the class SessionHandler method setSessionNetworks.
/**
* @param netOrder Maps CyNetwork SUID to the network position
*/
private void setSessionNetworks(final Map<Long, Integer> netOrder) {
final CyNetworkManager netMgr = serviceRegistrar.getService(CyNetworkManager.class);
final List<CySubNetwork> sortedNetworks = new ArrayList<>();
for (CyNetwork n : netMgr.getNetworkSet()) {
if (n instanceof CySubNetwork && netMgr.networkExists(n.getSUID()))
sortedNetworks.add((CySubNetwork) n);
}
Collections.sort(sortedNetworks, new Comparator<CySubNetwork>() {
@Override
public int compare(final CySubNetwork n1, final CySubNetwork n2) {
try {
Integer o1 = netOrder.get(n1.getSUID());
Integer o2 = netOrder.get(n2.getSUID());
if (o1 == null)
o1 = -1;
if (o2 == null)
o2 = -1;
return o1.compareTo(o2);
} catch (final Exception e) {
logger.error("Cannot sort networks", e);
}
return 0;
}
});
final CyApplicationManager applicationMgr = serviceRegistrar.getService(CyApplicationManager.class);
final CyNetworkViewManager netViewMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
final List<CyNetwork> selectedNetworks = applicationMgr.getSelectedNetworks();
final List<CyNetworkView> selectedViews = applicationMgr.getSelectedNetworkViews();
invokeOnEDT(() -> {
netPanel.setNetworks(sortedNetworks);
for (SubNetworkPanel snp : netPanel.getAllSubNetworkItems()) {
final int count = netViewMgr.getNetworkViews(snp.getModel().getNetwork()).size();
snp.getModel().setViewCount(count);
}
netPanel.setSelectedNetworks(selectedNetworks);
netViewMediator.getNetworkViewMainPanel().setSelectedNetworkViews(selectedViews);
});
}
Aggregations