Fwd: Orthogonal Views and getComponents()

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

Fwd: Orthogonal Views and getComponents()

Chris Weisiger
I'm a developer for the Micro-Manager project, which builds extensively on
ImageJ. Recently I started an effort to refactor much of our
display/control logic. As part of this, I replaced the default
ScrollbarWithLabels in our descendant of StackWindow (the cSelector,
tSelector, and zSelector objects) with our own custom controls.

Unfortunately, this breaks the "Orthogonal Views" command, because it
expects the components in the StackWindow to come in a specific order:

      Component[] c = win.getComponents();
      ((ScrollbarWithLabel) c[1]).addAdjustmentListener (this);

(There is similar code later to call removeAdjustmentListener)

I believe it's doing this so it can repaint when the channel is changed.
Naturally this code breaks when it tries to cast our AxisScroller class
(which is now the 2nd component in the array returned by getComponents())
to a ScrollbarWithLabel. I've tried to work around the problem by
overriding our getComponents() function to give this code what it expects,
but this causes the window layout code to break horribly -- as should
probably be expected.

Ideally there would be a better-supported way to access the selectors so
this code doesn't need to do this (though there's some question as to
whether outside code should have direct access to the selectors to begin
with). I generated a patch that adds a "getCSelector()" function to
StackWindow to expose the component that the Orthogonal Views plugin
requires; it seems to work:

http://pastebin.com/1xwmeU01

It would be very helpful if this change or a similar one, removing
Orthogonal View's reliance on component ordering in the StackWindow, could
get adopted into the official codebase. Thanks!

If there's some other place where I should send this request, please let me
know.

-Chris

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Orthogonal Views and getComponents()

Rasband, Wayne (NIH/NIMH) [E]
On May 12, 2014, at 6:32 PM, Chris Weisiger wrote:

> I'm a developer for the Micro-Manager project, which builds extensively on
> ImageJ. Recently I started an effort to refactor much of our
> display/control logic. As part of this, I replaced the default
> ScrollbarWithLabels in our descendant of StackWindow (the cSelector,
> tSelector, and zSelector objects) with our own custom controls.
>
> Unfortunately, this breaks the "Orthogonal Views" command, because it
> expects the components in the StackWindow to come in a specific order:
>
>      Component[] c = win.getComponents();
>      ((ScrollbarWithLabel) c[1]).addAdjustmentListener (this);

This code was removed in the latest ImageJ daily build (1.49a23). It is not needed because OrthogonalViews implements the ImageListener interface, so it gets notified when the
stack is updated.

-wayne

> (There is similar code later to call removeAdjustmentListener)
>
> I believe it's doing this so it can repaint when the channel is changed.
> Naturally this code breaks when it tries to cast our AxisScroller class
> (which is now the 2nd component in the array returned by getComponents())
> to a ScrollbarWithLabel. I've tried to work around the problem by
> overriding our getComponents() function to give this code what it expects,
> but this causes the window layout code to break horribly -- as should
> probably be expected.
>
> Ideally there would be a better-supported way to access the selectors so
> this code doesn't need to do this (though there's some question as to
> whether outside code should have direct access to the selectors to begin
> with). I generated a patch that adds a "getCSelector()" function to
> StackWindow to expose the component that the Orthogonal Views plugin
> requires; it seems to work:
>
> http://pastebin.com/1xwmeU01
>
> It would be very helpful if this change or a similar one, removing
> Orthogonal View's reliance on component ordering in the StackWindow, could
> get adopted into the official codebase. Thanks!
>
> If there's some other place where I should send this request, please let me
> know.
>
> -Chris

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Orthogonal Views and getComponents()

Chris Weisiger
On Tue, May 13, 2014 at 1:35 PM, Rasband, Wayne (NIH/NIMH) [E] <
[hidden email]> wrote:

>
> This code was removed in the latest ImageJ daily build (1.49a23). It is
> not needed because OrthogonalViews implements the ImageListener interface,
> so it gets notified when the
> stack is updated.
>

Great news! Thank you very much. Working around this problem in our own
code was giving me headaches.

-Chris

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html