Google Groups

Re: Catch event in Cytoscape

Alexander Pico Mar 30, 2012 1:28 PM
Posted in group: cytoscape-discuss
Hi Alexander,

Thank you for your response. You pointed me exactly to the API I


----- Mail original -----
De: "Alexander Pico" <>
À: "Lionel" <>
Envoyé: Vendredi 30 Mars 2012 04:31:43
Objet: Re: Catch event in Cytoscape

Hi Lionel,

There are some PropertyChangeEvents you can listen for. Like

However, if you want to catch the moment a new session if opened and
the current session is closing, I've found this approach effective:

if (prop.equals(Cytoscape.NETWORK_DESTROYED)) {
                        // listen for last network destroyed and check session state in
                        // order to determine if new session is being loaded... awkward!
                        if ((Cytoscape.getNetworkSet().size() <= 1) &&
(Cytoscape.getSessionstate() == Cytoscape.SESSION_OPENED)) {
                                     //clean up stuff from old session

For "View closing", you might have to listen for NETWORK_MODIFIED and
then ask if Cytoscape.viewExists(network_id). Not sure. I haven't had
to do this one.

 - Alex

On Mar 26, 2:20 am, Lionel <> wrote:
> Hi all,
> I would like to know if it is possible for a plugin to catch the following
> events from Cytoscape (2.8.2):
> - Session closing: when a user ask to open a new session (and the previous
> session must be closed) or to close the current session
> - View closing : when a user click on the cross icon to close a view
> I already note how to catch some other type of events but did not find any
> API for those two. Could you help me?
> I need those events to correctly remove from Cytoscape the objects I have
> created in views/networks in order to free memory.
> Thanks
> Cheers
> Lionel