Catch event in Cytoscape

20 views
Skip to first unread message

Lionel

unread,
Mar 26, 2012, 5:20:04 AM3/26/12
to cytoscap...@googlegroups.com
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

Alexander Pico

unread,
Mar 30, 2012, 4:28:07 PM3/30/12
to cytoscape-discuss
Hi Alexander,

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

cheers
Lionel

----- Mail original -----
De: "Alexander Pico" <ap...@gladstone.ucsf.edu>
À: "Lionel" <lionel....@gmail.com>
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
Cytoscape.SESSION_CLOSED
http://chianti.ucsd.edu/Cyto-2_8_2/javadoc/cytoscape/Cytoscape.html#SESSION_CLOSED

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
Reply all
Reply to author
Forward
0 new messages