Tagged: Java Icy Viewer
-
Frederic Marion-Poll May 16, 2019 at 5:48 pm
Hi all,
not sure this is the right forum, but I have a Java-Icy programming question. I would like to trap if a viewer is selected or deselected.In my application, I generate several kymographs from of a stack of data. I draw polyline2D lines on them (to display the upper and lower limit of a territory) and I can edit these lines. What I would like to achieve is to “unselect” the 2Dpolyline that was currently edited (and selected) so that it will be displayed as a thin line, when the user is selecting another viewer.
How can I trap this event? (view is un-selected). I suppose I should implement a Listener, but which one is the right one? (ActionListener, ChangeListener, ViewerListener, PropertyChangeListener).
Thank you in advance,
Fred- This topic was modified 5 years, 7 months ago by Frederic Marion-Poll.
Stephane Dallongeville May 20, 2019 at 2:29 pmHi Frederic,
Icy has that kind of event so you can actually listen them and react to it:
Icy.getMainInterface().addActiveViewerListener(new ActiveViewerListener() { @Override public void viewerDeactivated(Viewer viewer) { // call when viewer just has been de-activated / unfocused } @Override public void viewerActivated(Viewer viewer) { // call when viewer just has been activated / focused } @Override public void activeViewerChanged(ViewerEvent event) { // call when active/focused viewer has changed (Z/T position change for instance) } });
Hope that was what you were looking for.
Best,
– Stephane
Frederic Marion-Poll May 20, 2019 at 3:49 pmPS is there a way to trap such event for “a” or a “specific type of” view? I am using 2 types of views, which are attached to 2 different types of sequences. I would like to trap activate/deactivate only for one type of view/sequence. Currently, I am associating these sequences only with the “standard” viewer. Should I derive the standard viewer and associate a specific viewer with each of my sequence types so that it will be easier to test the type of view that is selected / unselected?
Stephane Dallongeville May 20, 2019 at 4:40 pmI guess that you use 2 separates Sequence (and so viewer) or you have many of them which can be from one type or another ? In the second case what you can do is to eventually use a specific mark in the Sequence name (or is its metadata ?) so instead of using the viewer event you directly use the sequence event.
Here’s how you can store an information in Sequence metadata (persitent with the XML file):
Node myNode = sequence.getNode(“myPluginMetadata”);
// set type
XMLUtil.setElementValue(myNode, “type”, “type1”);Then how use it for sequence activation event:
Icy.getMainInterface().addActiveSequenceListener(new ActiveSequenceListener()
{
@Override
public void sequenceDeactivated(Sequence sequence)
{
Node myNode = sequence.getNode(“myPluginMetadata”);// get sequence ‘type’
if (XMLUtil.getElementValue(myNode, “type”, “”).equals(“typeA”))
// do something
}@Override
public void sequenceActivated(Sequence sequence)
{
Node myNode = sequence.getNode(“myPluginMetadata”);// get sequence ‘type’
if (XMLUtil.getElementValue(myNode, “type”, “”).equals(“typeA”))
// do something
}@Override
public void activeSequenceChanged(SequenceEvent event)
{
// TODO Auto-generated method stub}
});- This reply was modified 5 years, 7 months ago by Stephane Dallongeville.
- This reply was modified 5 years, 7 months ago by Stephane Dallongeville.
- This reply was modified 5 years, 7 months ago by Stephane Dallongeville.
- This reply was modified 5 years, 7 months ago by Stephane Dallongeville.
- This reply was modified 5 years, 7 months ago by Stephane Dallongeville.
Frederic Marion-Poll May 20, 2019 at 6:05 pmThank you Stephane! 🙂 yes, this works.
It is quite simple indeed.
The forum ‘Icy Kernel’ is closed to new topics and replies.