I find myself in need of what I would call a "StackWindowListener".
I have an extension to StackWindow which is used in many of my plugins - which I prefer NOT to change (but I will, if I have to). Now, I have a need for a user-level program to get a callback when the slice is changed (via the usual stack control slider). Is there a way to do that without modifying (or further extending) the existing StackWindow? =============================================== In the alternative - is there an easy way to create something like a GenericDialog which is displayed while allowing the CURRENT thread to continue. Something that would allow: dialog.show(); while(!dialog.done()){...do something interesting} // dialog done - get results I can get the desired effect by using KeyListener and having the user interact with the keyboad, but I'd like the option of a graphical dialog box which remains displayed while the main program proceeds. -- Kenneth Sloan [hidden email] Vision is the art of seeing what is invisible to others. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Kenneth,
when the user changes the stack slice and you register as ImageListener, you get an imageUpdated(imp) callback. If you are not interested in events other then changing the slice, you have to remember the slice number of the previous call. Note that ImagePlus.addImageListener is static, so you must register only once, and you get events for all windows. Don't forget to de-register with removeImageListener. Calling 'removeImageListener' too often does not hurt (it does nothing if your class is not registered), but in some cases forgetting it can cause trouble, because your plugin will still get called when all is finished. Michael ________________________________________________________________ On 24.07.20 19:33, Kenneth Sloan wrote: > I find myself in need of what I would call a "StackWindowListener". > > I have an extension to StackWindow which is used in many of my plugins - which I prefer NOT to change (but I will, if I have to). > > Now, I have a need for a user-level program to get a callback when the slice is changed (via the usual stack control slider). Is there a way to do that without modifying (or further extending) the existing StackWindow? > > =============================================== > > In the alternative - is there an easy way to create something like a GenericDialog which is displayed while allowing the CURRENT thread to continue. Something that would allow: > > dialog.show(); > while(!dialog.done()){...do something interesting} > // dialog done - get results > > > I can get the desired effect by using KeyListener and having the user interact with the keyboad, but I'd like the option of a graphical dialog box which remains displayed while the main program proceeds. > > -- > Kenneth Sloan > [hidden email] > Vision is the art of seeing what is invisible to others. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear Keneth,
Michael probably already answered your request about the stack listener and I may as well have misunderstand your GenericDialog request. But what you are asking to be able to do something while a GenericDialog is displayed, isn't it what the NonBlockingGenericDialog already ables you to do: https://imagej.nih.gov/ij/developer/api/ij/gui/NonBlockingGenericDialog.html My best regards, Philippe Philippe CARL Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie 74 route du Rhin 67401 ILLKIRCH Tel : +33(0)3 68 85 42 89 ----- Mail original ----- De: "Michael Schmid" <[hidden email]> À: "imagej" <[hidden email]> Envoyé: Vendredi 24 Juillet 2020 19:47:39 Objet: Re: StackWindowListener? Hi Kenneth, when the user changes the stack slice and you register as ImageListener, you get an imageUpdated(imp) callback. If you are not interested in events other then changing the slice, you have to remember the slice number of the previous call. Note that ImagePlus.addImageListener is static, so you must register only once, and you get events for all windows. Don't forget to de-register with removeImageListener. Calling 'removeImageListener' too often does not hurt (it does nothing if your class is not registered), but in some cases forgetting it can cause trouble, because your plugin will still get called when all is finished. Michael ________________________________________________________________ On 24.07.20 19:33, Kenneth Sloan wrote: > I find myself in need of what I would call a "StackWindowListener". > > I have an extension to StackWindow which is used in many of my plugins - which I prefer NOT to change (but I will, if I have to). > > Now, I have a need for a user-level program to get a callback when the slice is changed (via the usual stack control slider). Is there a way to do that without modifying (or further extending) the existing StackWindow? > > =============================================== > > In the alternative - is there an easy way to create something like a GenericDialog which is displayed while allowing the CURRENT thread to continue. Something that would allow: > > dialog.show(); > while(!dialog.done()){...do something interesting} > // dialog done - get results > > > I can get the desired effect by using KeyListener and having the user interact with the keyboad, but I'd like the option of a graphical dialog box which remains displayed while the main program proceeds. > > -- > Kenneth Sloan > [hidden email] > Vision is the art of seeing what is invisible to others. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Michael Schmid
Thank you for the quick (and useful) response!
This sounds like just what I need. On Fri, Jul 24, 2020 at 12:50 Michael Schmid <[hidden email]> wrote: > Hi Kenneth, > > when the user changes the stack slice and you register as ImageListener, > you get an imageUpdated(imp) callback. > If you are not interested in events other then changing the slice, you > have to remember the slice number of the previous call. > > Note that ImagePlus.addImageListener is static, so you must register > only once, and you get events for all windows. > Don't forget to de-register with removeImageListener. > Calling 'removeImageListener' too often does not hurt (it does nothing > if your class is not registered), but in some cases forgetting it can > cause trouble, because your plugin will still get called when all is > finished. > > > Michael > ________________________________________________________________ > On 24.07.20 19:33, Kenneth Sloan wrote: > > I find myself in need of what I would call a "StackWindowListener". > > > > I have an extension to StackWindow which is used in many of my plugins - > which I prefer NOT to change (but I will, if I have to). > > > > Now, I have a need for a user-level program to get a callback when the > slice is changed (via the usual stack control slider). Is there a way to > do that without modifying (or further extending) the existing StackWindow? > > > > =============================================== > > > > In the alternative - is there an easy way to create something like a > GenericDialog which is displayed while allowing the CURRENT thread to > continue. Something that would allow: > > > > dialog.show(); > > while(!dialog.done()){...do something interesting} > > // dialog done - get results > > > > > > I can get the desired effect by using KeyListener and having the user > interact with the keyboad, but I'd like the option of a graphical dialog > box which remains displayed while the main program proceeds. > > > > -- > > Kenneth Sloan > > [hidden email] > > Vision is the art of seeing what is invisible to others. > > > > -- > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -Kenneth Sloan -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |