Hi Dscho,<br><br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">Just the infinite recursion thing (which is harder than meets the eye;<br>
you'd have to build a graph and detect circles).<br></blockquote>
<br>Or we could invoke the callback only when the GUI changes by user action.<br><br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">
It's also not clear how the callback would signal to the dialog (be that<br>
an ImageJ, or a KNIME or CellProfiler dialog) _what_ value was changed by<br>
the callback. (Just think of the user changing the width, and the callback<br>
wanting to modify the height _iff_ "keep aspect-ratio" is checked.)<br></blockquote>
<br>A given parameter's callback would be called only when the linked parameter changes.<br><br>So the aspect ratio example might look like:<br><br><div style="margin-left: 40px;">@Parameter(callback="widthChanged")<br>
public int width;<br><br>@Parameter(callback="heightChanged")<br>public int height;<br><br>@Parameter(label="Maintain aspect ratio", callback="aspectRatioToggled")<br>public boolean aspectRatio;<br>
<br>/** The plugin must populate these with the current/initial width and height choices. */<br>private int originalWidth, originalHeight;<br><br>/** Invoked when width text field changes. */<br>public void widthChanged() {<br>
if (aspectRatio) constrainHeight();<br>}<br><br>/** Invoked when height text field changes. */<br>public void heightChanged() {<br> if (aspectRatio) constrainWidth();<br>}<br><br>public void aspectRatioToggled() {<br>
if (aspectRatio) constrainHeight(); // arbitrarily change height, rather than width<br>
}<br><br>/** Adjusts width to match original aspect ratio. */<br>private void constrainWidth() {<br> width = originalWidth * height / originalHeight;<br>}<br><br>/** Adjusts height to match original aspect ratio. */<br>
private void constrainHeight() {<br>
height = originalHeight * width / originalWidth;<br>}<br></div><br>After invoking the callback, the plugin infrastructure updates all dialog fields to the latest values (and this update does not itself trigger any additional callbacks).<br>
<br>-Curtis<br><br><div class="gmail_quote">On Tue, Oct 12, 2010 at 9:50 PM, Johannes Schindelin <span dir="ltr"><<a href="mailto:Johannes.Schindelin@gmx.de" target="_blank">Johannes.Schindelin@gmx.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi,<br>
<div><br>
On Tue, 12 Oct 2010, Curtis Rueden wrote:<br>
<br>
> > That was my first idea. But how would the user interface tell the<br>
> > callback without String or java.lang.reflect.Field ugliness which<br>
> > input was modified by the user (and by that, what field should be<br>
> > changed accordingly), and how would the callback tell that it changed<br>
> > something, and what?<br>
><br>
> Each parameter has its own callback method, invoked when that particular<br>
> parameter changes. So as Lee said, which method is called indicates<br>
> which parameter was changed. (Perhaps it would be better to call the<br>
> attribute something like "onChange" instead.)<br>
><br>
> Does that clarify it? Or is there a problem I'm not seeing?<br>
<br>
</div>Just the infinite recursion thing (which is harder than meets the eye;<br>
you'd have to build a graph and detect circles).<br>
<br>
It's also not clear how the callback would signal to the dialog (be that<br>
an ImageJ, or a KNIME or CellProfiler dialog) _what_ value was changed by<br>
the callback. (Just think of the user changing the width, and the callback<br>
wanting to modify the height _iff_ "keep aspect-ratio" is checked.)<br>
<br>
Ciao,<br>
Dscho<br>
<br>
</blockquote></div><br>