Posted by
Michael P Ellis on
Dec 24, 2020; 9:23am
URL: http://imagej.273.s1.nabble.com/Notification-of-File-Save-tp5024300p5024308.html
Dear Kenneth,
Alas, imageUpdated() is currently not called after an image has been saved. To effect that change would need a few changes. The notifyListerners method in ImagePlus would need making public (so it could be called from outside of ImagePlus).
Since imageUpdated does not take any context parameter, overriding the imageUpdated() for handling new events such as save or any other event, could conceivably (though very unlikely) break some plugins that were not expecting these extra calls on Save events.
As for the "additional callbacks to ImagePlus", I enclose my reply to Michael Schmid that I submitted earlier and hope this makes clearer what failed to explain before...
> Regarding my suggestion, I apologise for not making my suggestion more clear.
>
> My suggestion is to leave the existing ImageListener interface and the code that supports the registering of handlers and the notification of events entirely unchanged.
>
> I was proposing an entirely new, but very similar ImageLiseterNew interface with ent entirely separate handler registration and event distribution method.
>
> The ImageLiseterNew interface would differ from the original ImageLiseter interface in that it would have a single method that was passed in a String ID. Being a Single Abstract Method interface (aka functional interface) would also mean registering handlers could also be done neatly in Java 8 and beyond as a lambda.
> (To provide easy forward compatibility, the existing notifyListeners(final int ID) could also make a call to the new notifyListeners(final String ID) with appropriate String constants and no compromise to backward compatibility at all).
With best regards and seasons greetings Michael Ellis
December 23, 2020 10:44 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