Dear Wayne, or whomever it may concern,

My maven project includes ImageJ with the following dependency:

        <dependency>
            <groupId>net.imagej</groupId>
            <artifactId>ij</artifactId>
            <version>1.54j</version>
        </dependency>

But I note that version 1.54j, which supersedes 1.54h10 daily build does
not include the modified ImageListenerAdapter that includes:

default void imageSaved(ImagePlus imp) { }

Is there a reason why this being excluded from the versions stored in the
central maven repository?

Sincerely yours -- Michael Ellis


On Mon, 4 Dec 2023 at 05:11, Wayne Rasband <[email protected]> wrote:

> > On Dec 2, 2023, at 5:27 AM, Michael Ellis <[email protected]>
> wrote:
> >
> > Regarding adding notification when an ImagePlus saved, it occurs to me
> that this can be done in a Java 6 compliant way by adding an
> ImageListenerAdapter class that provides overridable stubs the behaviour of
> the existing ImageListener methods add the additional imageSaved() method
> too, as below.
>
> Hi Michael,
>
> Your ImageListenerAdapter class is in the ImageJ 1.54h10 daily build.
>
> -wayne
>
>
> > ImagePlus:: notifyListeners() can then check whether the registered
> listener is an instance of ImageListenerAdapter before imageSaved() method.
> >
> > Advantages:
> > - Java 1.6 compliance
> > - Users of ImageListenerAdapter need only override the method they are
> interested in,
> >
> > Disadvantages:
> > A bit of code bloat and neither tidy nor flexible as adding default
> methods to the original ImageListener interface.
> >
> >
> > === ImageListenerAdapter.java ===
> > package ij;
> >
> > /**
> > * An Adapter class for the ImageListener interface. Note
> ImageListenerAdapter
> > * supports notification when an ImagePlus gets saved.
> > * <p>
> > * With this adapter you need only override the methods that you require
> > * notification for.
> > * <p>
> > * TODO When ImageJ has a minimum support of Java8 consider updating
> > * ImageListener to provide default methods for all these callbacks as
> this will
> > * allow ImageListener interface to be used as mix-in class whereas Java
> single
> > * inheritance precludes that for this ImageListenerAdapter class.
> > *
> > * @author Michael Ellis
> > */
> > public class ImageListenerAdapter implements ImageListener {
> >
> >    @Override
> >    public void imageOpened(ImagePlus imp) {
> >    }
> >
> >    @Override
> >    public void imageClosed(ImagePlus imp) {
> >    }
> >
> >    @Override
> >    public void imageUpdated(ImagePlus imp) {
> >    }
> >
> >    public void imageSaved(ImagePlus imp) {
> >    }
> > }
> > ===
> >
> > === ImagePlus.java ===
> >    protected void notifyListeners(final int id) {
> >        if (temporary) {
> >            return;
> >        }
> >        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 (listener instanceof ImageListenerAdapter)
> {
> >                                ((ImageListenerAdapter)
> listener).imageSaved(imp);
> >                            }
> >                            break;
> >                    }
> >                }
> >            }
> >        });
> >    }
> >
> > ===
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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

Reply via email to