Posted by
Michael P Ellis on
Jan 06, 2021; 8:18am
URL: http://imagej.273.s1.nabble.com/Notification-of-File-Save-tp5024300p5024334.html
Dear Wayne,
The AutoClose feature is not a show stopper for me that can easily be worked around.
The FileSave functionality is necessary for my application and without that support
I can only ship my PlugIns with my own modified version of Image which I am loath to do
as I want to make at least some of my plugins free to use for the community. (I do believe
in putting something back)
Can I put to you the idea of supporting the FileSaved functionality in a Java 1.6
compliant way as follows:
=== Added ij.ImageListenerAux.java ===
package ij;
/**
* An extension of the {@code ImageListener} Interface that provides
* notification when and ImagePlus is saved.
*
* Note this interface is deprecated and will be removed as soon as ImageJ is
* using Java 8 whereupon {@code imageSaved()} will be added as a default method
* to the original {@code ImageListener}
*
* @deprecated
*/
public interface ImageListenerAux extends ImageListener {
public void imageSaved(ImagePlus imp);
}
=== Modified ImagePlus.java ===
protected void notifyListeners(final int id) {
final ImagePlus imp = this;
EventQueue.invokeLater(new Runnable() {
public void run() {
for (int i=0; i<listeners.size(); i++) {
ImageListener listener = (ImageListener)listeners.elementAt(i);
switch (id) {
case OPENED:
listener.imageOpened(imp);
break;
case CLOSED:
listener.imageClosed(imp);
break;
case UPDATED:
listener.imageUpdated(imp);
break;
case SAVED:
if (imp instanceof ImageListenerAux){
(ImageListenerAux)listener).imageSaved(imp);
}
break;
}
}
}
});
}
Users needing the FileSaved functionality can just implement the newer ImageListenerAux interface.
Also, when ImageJ finally settled on Jave 8 I'd suggest that all the method interface to ImageListener are defaulted so plugIn developers need
only implement the ones they are interested in.
With best regards -- Michael Ellis
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html