I'm writing a Java plugin that manages 4 windows. Two of these are StackWindows.
a) Is there a way to be notified when the user changes slices using the StackWindow controls? b) If the user has turned on " play" to scroll through slices, can I turn that OFF? In a similar plugin, written in a different style, I handled this by creating a class that extended StackWindow. That implementations could tell when the slice changed, and communicate that to an object handling a paired window. With 2 windows, this seemed like a reasonable idea. With 4, it seems best to have a controller object which handles all events and pushes the results down to the individual windows (2 StackWindows, 2 single-image windows). But...I can't figure out how to be notified when the user uses the StackWindow controls to change slices (either one at a time, or by hitting the "play" button). I can live with this flaw, but I'd prefer to fix it. I have considered displaying the stacks without the StackWindow scrollbar, but that's too high a price to pay. I *want* the scrollbars, but I also want a notification when a user interaction with the scrollbar has caused the displayed slice to change. The ability to turn off "play" (in response to an event in a different window) would be nice, but it's not as important as knowing what the current slice is at all times. I have been looking at the code for Orthogonal_Views, which has a similar interface. I have found many good ideas there - but I can't find the solution to THIS problem. Help, please! -- 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 |
> On Oct 5, 2019, at 12:03 AM, Kenneth Sloan <[hidden email]> wrote:
> > I'm writing a Java plugin that manages 4 windows. Two of these are StackWindows. > > a) Is there a way to be notified when the user changes slices using the StackWindow controls? The plugin will be notified when the slice changes if it implements the ImageListener interface. For an example, see the Plugins>Utilities>Monitor events command. -wayne > b) If the user has turned on " play" to scroll through slices, can I turn that OFF? > > In a similar plugin, written in a different style, I handled this by creating a class > that extended StackWindow. That implementations could tell when the slice changed, and > communicate that to an object handling a paired window. With 2 windows, this seemed like > a reasonable idea. With 4, it seems best to have a controller object which handles all events > and pushes the results down to the individual windows (2 StackWindows, 2 single-image windows). > > But...I can't figure out how to be notified when the user uses the StackWindow controls to > change slices (either one at a time, or by hitting the "play" button). I can live with this > flaw, but I'd prefer to fix it. > > I have considered displaying the stacks without the StackWindow scrollbar, but that's too high > a price to pay. I *want* the scrollbars, but I also want a notification when a user interaction > with the scrollbar has caused the displayed slice to change. > > The ability to turn off "play" (in response to an event in a different window) would be nice, but > it's not as important as knowing what the current slice is at all times. > > I have been looking at the code for Orthogonal_Views, which has a similar interface. I have found > many good ideas there - but I can't find the solution to THIS problem. > > Help, please! > > -- > 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 |
Thanks - ImageListener worked fine.
Now, for part b) - is it possible to turn off the autoscroll? I like the idea of allowing the user to hit the "play" button, and it's not too much trouble to ask the user to turn it off when done - but I'd like to also be able to turn it off if the user uses a cursor in another window to change the current slice. Context: 2 stack windows (same dimensions, different data) and 2 single-image windows showing top-down views of the stack. The user controls a global cursor from any window (very much like Orthogonal_Views). So, moving in y in one of the top-down, single-image views will change the slice in both stacks. What I'd like to do is to STOP an ongoing animation when the user changes the slice in one of the top-down views. Orthogonal_Views appears to do this, but I can't decipher the methods used. What happens now is that when the user starts an animation, both stacks scroll together, and the global cursor is updated to indicate the current slice/y-coordinate. If the user changes the y-coordinate in a top-down view, the stacks are momentarily updated to reflect that change, but the animation (still running) then proceeds to bring the two stacks back to where the animation wants it. I'd like to be able to stop that. Not a big deal - just trying to understand all the corner cases and have as much control as possible. It's certainly usable as-is. One final piece of trivia - what is the difference between ImagePlus/getCurrentSlice() and ImagePlus/getSlice()? They appear to do the same thing. The documentation has an extra notation that getCurrentSlice() returns a 1-based index. There is no such comment on getSlice() - but it also seems to return a 1-based index. Is this a compatibility issue, or am I confused? -- 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,
concerning stopping the animation ('play') of a stack: You can simply use the Macro Recorder in 'Java' mode, it says: IJ.run("Stop Animation", ""); As for all IJ.run commands, it also has a version where you can specify the ImagePlus: IJ.run(imp, "Stop Animation", ""); Another way to stop animation is the setAnimage(boolean) method of StackWindow. StackWindow also has a setSlidersEnabled(boolean) method, which can be used to disable the sliders. Nevertheless, the user can still change the slice by various menu commands, with Image>Stacks>Set Slice being the most obvious. Note that also many commands where it is not obvious change the slice (e.g. the ROI Manager's More>>Multi Measure). If you need to disable that all, you have to lock the image, but then also your code can't change the slice. Michael ________________________________________________________________ On 05.10.19 17:45, Kenneth Sloan wrote: > Thanks - ImageListener worked fine. > > Now, for part b) - is it possible to turn off the autoscroll? I like the idea of allowing > the user to hit the "play" button, and it's not too much trouble to ask the user to turn > it off when done - but I'd like to also be able to turn it off if the user uses a cursor > in another window to change the current slice. > > Context: 2 stack windows (same dimensions, different data) and 2 single-image windows showing top-down > views of the stack. The user controls a global cursor from any window (very much like Orthogonal_Views). > So, moving in y in one of the top-down, single-image views will change the slice in both stacks. > What I'd like to do is to STOP an ongoing animation when the user changes the slice in one of the top-down views. > Orthogonal_Views appears to do this, but I can't decipher the methods used. > > What happens now is that when the user starts an animation, both stacks scroll together, and the global cursor is > updated to indicate the current slice/y-coordinate. If the user changes the y-coordinate in a top-down view, the stacks are momentarily updated to reflect that change, but the animation (still running) then proceeds to bring the two stacks back > to where the animation wants it. I'd like to be able to stop that. > > Not a big deal - just trying to understand all the corner cases and have as much control as possible. It's certainly usable as-is. > > One final piece of trivia - what is the difference between ImagePlus/getCurrentSlice() and ImagePlus/getSlice()? They appear to > do the same thing. The documentation has an extra notation that getCurrentSlice() returns a 1-based index. There is no such > comment on getSlice() - but it also seems to return a 1-based index. Is this a compatibility issue, or am I confused? > > -- > 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 |
Michael-
Thank you for the information. I suspected that "set(Animate)" was the method of choice, but I hadn't yet had time to experiment (other fires to put out). This was very helpful. -- 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 |
Free forum by Nabble | Edit this page |