use of org.cytoscape.model.CyNetworkManager in project cytoscape-impl by cytoscape.
the class CyApplicationManagerImpl method selectNetworks.
private Set<CyNetwork> selectNetworks(final Collection<CyNetwork> networks) {
final CyNetworkManager networkManager = serviceRegistrar.getService(CyNetworkManager.class);
final Set<CyNetwork> selectedNetworks = new HashSet<>();
final Set<CyNetwork> allNetworks = networkManager.getNetworkSet();
for (final CyNetwork n : allNetworks) {
final boolean selected = networks != null && networks.contains(n);
final CyRow row = n.getRow(n);
row.set(CyNetwork.SELECTED, selected);
if (selected)
selectedNetworks.add(n);
}
return selectedNetworks;
}
use of org.cytoscape.model.CyNetworkManager in project cytoscape-impl by cytoscape.
the class CyApplicationManagerImpl method internalSetCurrentNetworkView.
private void internalSetCurrentNetworkView(final CyNetworkView view, List<CyEvent<?>> eventsToFire) {
final CyNetworkManager networkManager = serviceRegistrar.getService(CyNetworkManager.class);
if (view != null && !networkManager.networkExists(view.getModel().getSUID()))
throw new IllegalArgumentException("network is not recognized by this ApplicationManager");
boolean changed = (view == null && currentNetworkView != null) || (view != null && !view.equals(currentNetworkView));
if (changed) {
currentNetworkView = view;
eventsToFire.add(new SetCurrentNetworkViewEvent(this, currentNetworkView));
}
}
use of org.cytoscape.model.CyNetworkManager in project cytoscape-impl by cytoscape.
the class StringToModelImpl method getNetworkView.
// @Override
public CyNetworkView getNetworkView(String strNet) {
if (strNet == null || strNet.length() == 0 || strNet.equalsIgnoreCase(CURRENT))
return serviceRegistrar.getService(CyApplicationManager.class).getCurrentNetworkView();
// Look for any special prefix
final CyNetworkManager netMgr = serviceRegistrar.getService(CyNetworkManager.class);
final CyNetworkViewManager netViewMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
String[] splitString = strNet.split(":");
if (splitString.length > 1) {
if (SUID.equalsIgnoreCase(splitString[0])) {
Long suid = getLong(splitString[1]);
if (suid == null)
return null;
for (CyNetworkView view : netViewMgr.getNetworkViewSet()) {
if (view.getSUID().equals(suid))
return view;
}
return null;
}
if (NAME.equalsIgnoreCase(splitString[0]))
strNet = splitString[1];
}
for (CyNetwork net : netMgr.getNetworkSet()) {
if (strNet.equalsIgnoreCase(net.getRow(net).get(CyNetwork.NAME, String.class))) {
if (netViewMgr.viewExists(net)) {
for (CyNetworkView view : netViewMgr.getNetworkViews(net)) {
// Just return the first view
return view;
}
}
}
}
return null;
}
use of org.cytoscape.model.CyNetworkManager in project cytoscape-impl by cytoscape.
the class StringToModelImpl method getNetwork.
@Override
public CyNetwork getNetwork(String strNet) {
if (strNet == null || strNet.length() == 0 || strNet.equalsIgnoreCase(CURRENT))
return serviceRegistrar.getService(CyApplicationManager.class).getCurrentNetwork();
// Look for any special prefix
final CyNetworkManager netMgr = serviceRegistrar.getService(CyNetworkManager.class);
String[] splitString = strNet.split(":");
if (splitString.length > 1) {
if (SUID.equalsIgnoreCase(splitString[0])) {
Long suid = getLong(splitString[1]);
if (suid == null)
return null;
return netMgr.getNetwork(suid);
}
if (NAME.equalsIgnoreCase(splitString[0]))
strNet = splitString[1];
}
for (CyNetwork net : netMgr.getNetworkSet()) {
if (strNet.equalsIgnoreCase(net.getRow(net).get(CyNetwork.NAME, String.class)))
return net;
}
return null;
}
use of org.cytoscape.model.CyNetworkManager in project cytoscape-impl by cytoscape.
the class DestroyNetworkTask method run.
@Override
public void run(TaskMonitor tm) {
int i = 0;
int networkCount;
if (destroyCurrentNetwork) {
tm.setProgress(0.0);
CyNetworkManager netManager = serviceRegistrar.getService(CyNetworkManager.class);
if (localNets == null || localNets.isEmpty()) {
if (network == null) {
tm.showMessage(TaskMonitor.Level.ERROR, "Need to specify network to destroy");
return;
} else {
localNets = Collections.singletonList(network);
}
}
networkCount = localNets.size();
for (CyNetwork n : localNets) {
destroyNetwork(n, netManager);
i++;
tm.setProgress((i / (double) networkCount));
}
tm.setProgress(1.0);
}
}
Aggregations