use of org.cytoscape.view.model.events.NetworkViewAboutToBeDestroyedEvent in project cytoscape-impl by cytoscape.
the class CyNetworkViewManagerImpl method destroyNetworkView.
@Override
public void destroyNetworkView(CyNetworkView view) {
if (view == null) {
// Do nothing if view is null.
logger.warn("Network view is null.");
return;
}
final CyNetwork network = view.getModel();
// do this outside of the lock to fail early
synchronized (lock) {
if (!networkViewMap.containsKey(network))
throw new IllegalArgumentException("network view is not recognized by this NetworkManager");
viewsAboutToBeDestroyed.add(view);
}
// let everyone know!
fireEvent(new NetworkViewAboutToBeDestroyedEvent(this, view));
synchronized (lock) {
// do this again within the lock to be safe
if (!networkViewMap.containsKey(network))
throw new IllegalArgumentException("network view is not recognized by this NetworkManager");
final Collection<CyNetworkView> views = networkViewMap.get(network);
views.remove(view);
networkViewMap.put(network, views);
viewsAboutToBeDestroyed.remove(view);
view.dispose();
}
fireEvent(new NetworkViewDestroyedEvent(this));
view = null;
}
Aggregations