[ImageJ-devel] @Parameter fields - don't make them final

Curtis Rueden ctrueden at wisc.edu
Tue May 24 17:23:41 CDT 2011


Hi Grant,

I fixed GradientImage in r2956. If you notice any others, please fix and
commit.

The problem is that I frequently use the command "Clean up" in Eclipse which
formats source code according to our conventions. One of the things it does
is add final where possible, which normally is very nice, but in this one
case causes problems. A workaround might be to add methods such as
"setWidth(int)" and "setHeight(int)" to GradientImage so that the parameters
cannot legally be final.

-Curtis

On Tue, May 24, 2011 at 5:07 PM, Grant B. Harris <gharris at mbl.edu> wrote:

> I discovered the hard way - don't declare @Parameter fields final.
>
> In the GradientImage plugin, the width and height are declared thus:
>    @Parameter(min = "1")
>    private final int width = 512;
>
>    @Parameter(min = "1")
>    private final int height = 512;
>
> The input dialog gives you two spinners to change these values.  It even
> remembers the last values input.  But then the plugin uses the initial final
> values set when declared... which makes sense.  But the input dialog does
> not recognize, and there are not warnings that the inputs will be ignored.
>
> So, if you really want the user to be able to change a parameter, best to
> not final !
>
> -- Grant
>
> _______________________________________________
> ImageJ-devel mailing list
> ImageJ-devel at imagejdev.org
> http://imagejdev.org/mailman/listinfo/imagej-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20110524/313e92f3/attachment.html>


More information about the ImageJ-devel mailing list