Login  Register

Re: Orthogonal Views and getComponents()

Posted by Rasband, Wayne (NIH/NIMH) [E] on May 13, 2014; 8:35pm
URL: http://imagej.273.s1.nabble.com/Fwd-Orthogonal-Views-and-getComponents-tp5007707p5007725.html

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