StackWindow details (Java)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

StackWindow details (Java)

Kenneth Sloan-2
I have several Java plugins which use a Class which extends StackWindow.

Typical setup involves building an ImageStack and creating the StackWindow.
Usually, there are several images in the ImageStack at this point.

A new plugin typically has only ONE Image in the ImageStack when the StackWindow
is created, but (later) more images are added.

This all works reasonably well,  EXCEPT that in this special case there is no scrollbar
displayed.  

It seems reasonable that there is no scrollbar displayed in the special case where only
one image is in the ImageStack.  But, I can't seem to find a way to cause a scrollbar
to be displayed once the ImageStack grows.  On the other hand, it's probably also
reasonable to display a scrollbar in this situation (demonstrating that there is only one image
in the stack).

After the supplementary images are added to the ImageStack, I am able to scroll through the stack
using the arrow keys, and can verify that all of the added images are now in the ImageStack
and are being displayed by the StackWindow.  But...it would be nice to also have a scrollbar.

Alas, closing the StackWindow and re-opening it is not an attractive option.  The extended Class
(call it StackWindow2) has a moderately complex interaction with another (similarly, but not exactly
the same) extended StackWindow (call it StackWindow3).  StackWindow2 and StackWindow3 know about each
other, and exchange information based on cursor movement in either window.  This interaction is setup
in a very standard piece of prologue code which I am trying to keep completely separated from
"application dependent" code.
 
option 1: I can live without the scrollbar

option 2: I can wait until I have all the images before creating the StackWindow (painful, but not a disaster)
          This would involve changing code that I want to keep IDENTICAL in all related plugins - and which
          may eventually be moved to a separate module.  At the moment, many plugins share a common
          block of setup code that is (almost) identical everywhere.  I'm trying to stamp out the
          differences.  This opion would create a new difference.  That's the wrong direction!

option 3: I can bite the bullet and tear down the existing pair of StackWindows and create new versions.
          (this is probably not all *that* hard, but it's a bit messy).  This requires that the
          new plugin code is AWARE of this interaction and setup method.  Too messy.

option 4: I could create the initial StackWindow with a dummy second image (I think this will work, but
          have not tried it, yet).  I might even remove the dummy slice once the added slices are in place.
          This isn't TOO bad.


option 4: someone could educate me and show me how to cause a scrollbar to appear (either with only 1
          image, or AFTER the number of images increases).  Perhaps I missed it in the documentation.


Question: does anyone know (I can test, but good knowledge is always good to have) what happens if you
create a StackWindow with a 2-slice ImageStack and then REMOVE one of the slices?  Do you still have
a scrollbar displayed?  

If this works, then we might have:

option 5: in the common setup - create an ImageStack with a 2-slice ImageStack (one a dummy)...and then remove the dummy.
          This could even be propagated to the standard prologue block of code.

At the moment, I can probably live with option 1 - but if someone can tell me how to do what I want CLEANLY, that would
be a plus.

My DRUTHERS (simply taste) would be that a StackWindow with a single-image ImageStack SHOULD display a scrollbar.  Without
looking at the code, this seems simpler than recognizing the special case and NOT creating the scrollbar.  But,
my tastes are sometimes not universally shared, so...

My second choice would be for a scrollbar to automatically be added (perhaps requiring an "update" call) when the ImageStack grows from 1 to 2.  I see that there is an "updateScrollbar"(?) method - but I'm not clear on what it actually does.  I tried invoking
it after the ImageStack is expanded, but it had no effect.

--
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