Search in sources :

Example 1 with NetworkViewAboutToBeDestroyedEvent

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;
}
Also used : NetworkViewDestroyedEvent(org.cytoscape.view.model.events.NetworkViewDestroyedEvent) NetworkViewAboutToBeDestroyedEvent(org.cytoscape.view.model.events.NetworkViewAboutToBeDestroyedEvent) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Aggregations

CyNetwork (org.cytoscape.model.CyNetwork)1 CyNetworkView (org.cytoscape.view.model.CyNetworkView)1 NetworkViewAboutToBeDestroyedEvent (org.cytoscape.view.model.events.NetworkViewAboutToBeDestroyedEvent)1 NetworkViewDestroyedEvent (org.cytoscape.view.model.events.NetworkViewDestroyedEvent)1