Login  Register

Re: Notification of File Save

Posted by Michael P Ellis on Dec 24, 2020; 9:31am
URL: http://imagej.273.s1.nabble.com/Notification-of-File-Save-tp5024300p5024309.html

Albert, hi,

Cool suggestion, though I am hoping for a change to ImageJ that can be adopted in the central release and I am not sure if minimal Java version 8 is at present expected?

A similar Java 1.6 compliant approach could be adopted (but a bit messier) could be achieved by extending ij.ImageListener with an extra interface say, ij.ImageListener2 that had the extra method then the notifyLister could runtime check the class and call the imageSaved only if the registered handler was a ij.ImageListener2 interface.

The question I have now, I suppose is, who decides what goes into the central distribution of ImageJ1?

P.S. I still like the idea of these handles being rewritten as Single Access Methods (Functional Interfaces) passing a context of some sort, that would also allow for handlers to be implemented as lambdas :-)

Many thanks for the default interface method idea though, it's a more attractive way of providing compatibility!

Merry Christmas.

-- Michael Ellis


December 23, 2020 11:26 PM, "Albert Cardona" <[hidden email]> wrote:

> Best would be a default interface method imageSaved that does nothing, added to ij.ImageListener.
> Wouldn’t break anything and it’s supported since at least java 8.
>
> Albert
>
>> On Dec 23, 2020, at 9:21 PM, Kenneth Sloan <[hidden email]> wrote:
>>
>> Is it possible to squeeze this functionality into "ImageUpdated"? Perhaps add calls to ImagePlus to
>> ask about the nature of the update? This would not break existing code, I think.
>> --
>> Kenneth Sloan
>> [hidden email]
>> Vision is the art of seeing what is invisible to others.
>>
>>> Unfortunately, I think that your suggestion of adding additional callbacks to ImagePlus does not
>>> work: The ImageListener of ImagePlus cannot be extended because its callback functions are not
>>> something like imageOperationDone(image, whatOperation) but the notifyListeners has separate
>>> imageOpened,
>>> imageClosed, and
>>> imageUpdated
>>> calls to the listener. One can't add more without breaking compatibility with existing plugins.
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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