use of org.cytoscape.model.CyNetworkManager in project cytoscape-impl by cytoscape.
the class CyRootNetworkImpl method handleEvent.
@Override
public void handleEvent(NetworkAddedEvent e) {
if (e.getNetwork() == this || subNetworks.contains(e.getNetwork())) {
// Check if another network from this root was already registered - return if so
CyNetworkManager netManager = e.getSource();
List<CyNetwork> networks = new ArrayList<CyNetwork>();
networks.add(this);
networks.addAll(subNetworks);
networks.remove(e.getNetwork());
for (CyNetwork network : networks) {
if (netManager.networkExists(network.getSUID()))
return;
}
registerAllTables(networkTableMgr.getTables(this, CyNetwork.class).values());
registerAllTables(networkTableMgr.getTables(this, CyNode.class).values());
registerAllTables(networkTableMgr.getTables(this, CyEdge.class).values());
}
}
use of org.cytoscape.model.CyNetworkManager in project cytoscape-impl by cytoscape.
the class CyNetworkViewManagerImpl method addNetworkView.
@Override
public void addNetworkView(final CyNetworkView view, final boolean setCurrent) {
if (view == null) {
// Do nothing if view is null.
logger.warn("Network view is null.");
return;
}
final CyNetwork network = view.getModel();
final CyNetworkManager netMgr = serviceRegistrar.getService(CyNetworkManager.class);
synchronized (lock) {
if (!netMgr.networkExists(network.getSUID()))
throw new IllegalArgumentException("Network view cannot be added, because its network (" + network + ") is not registered");
Collection<CyNetworkView> existingSet = networkViewMap.get(network);
if (existingSet == null)
existingSet = new LinkedHashSet<>();
existingSet.add(view);
networkViewMap.put(network, existingSet);
}
fireEvent(new NetworkViewAddedEvent(this, view));
if (setCurrent) {
final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
if (// It may be null when running unit tests
applicationManager != null)
applicationManager.setCurrentNetworkView(view);
}
}
use of org.cytoscape.model.CyNetworkManager in project cytoscape-impl by cytoscape.
the class NetworkViewMediator method updateNetworkViewTitle.
private final void updateNetworkViewTitle(final Collection<RowSetRecord> records, final CyTable source) {
final CyNetworkManager netMgr = serviceRegistrar.getService(CyNetworkManager.class);
final CyNetworkViewManager netViewMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
for (final RowSetRecord record : records) {
if (CyNetwork.NAME.equals(record.getColumn())) {
// Assume payload collection is for same column
for (CyNetwork net : netMgr.getNetworkSet()) {
if (net.getDefaultNetworkTable() == source) {
final String name = record.getRow().get(CyNetwork.NAME, String.class);
if (name == null || name.trim().isEmpty())
continue;
final Collection<CyNetworkView> netViews = netViewMgr.getNetworkViews(net);
int count = 0;
for (CyNetworkView view : netViews) {
// TODO: Only update the view's title if the current title and the network name are in sync,
// because users can change the Network View title at any time
String title = name.trim();
title += (netViews.size() > 1 ? " (" + ++count + ")" : "");
view.setVisualProperty(BasicVisualLexicon.NETWORK_TITLE, title);
// if this visual property is locked
if (!view.isValueLocked(BasicVisualLexicon.NETWORK_TITLE)) {
invokeOnEDT(() -> {
getNetworkViewMainPanel().update(view);
});
}
}
break;
}
}
}
}
}
use of org.cytoscape.model.CyNetworkManager in project cytoscape-impl by cytoscape.
the class RootNetworkPanelModel method getSubNetworkCount.
@Override
public int getSubNetworkCount() {
int count = 0;
final CyNetworkManager netManager = serviceRegistrar.getService(CyNetworkManager.class);
// Count number of public subnetworks
for (CySubNetwork net : getNetwork().getSubNetworkList()) {
if (netManager.networkExists(net.getSUID()))
count++;
}
return count;
}
use of org.cytoscape.model.CyNetworkManager in project cytoscape-impl by cytoscape.
the class CyApplicationManagerImpl method getSelectedNetworks.
@Override
public List<CyNetwork> getSelectedNetworks() {
final CyNetworkManager networkManager = serviceRegistrar.getService(CyNetworkManager.class);
final Set<CyNetwork> allNetworks = networkManager.getNetworkSet();
final List<CyNetwork> selectedNetworks = new ArrayList<>();
for (final CyNetwork n : allNetworks) {
final CyRow row = n.getRow(n);
if (row.get(CyNetwork.SELECTED, Boolean.class, false))
selectedNetworks.add(n);
}
return selectedNetworks;
}
Aggregations