Re: Getting the ImagePlus in an ImageCanvas
Posted by
dscho on
Dec 02, 2009; 4:57pm
URL: http://imagej.273.s1.nabble.com/Getting-the-ImagePlus-in-an-ImageCanvas-tp3690250p3690255.html
Hi,
On Wed, 2 Dec 2009, Benjamin Schmid wrote:
> > I am writing something involving user interaction. In one of the
> > steps, I catch mouse events: when the user clicks in a frame, I get
> > the source of the click as an ImageCanvas.
> >
> > But of course, what I would like to get is the ImagePlus within this
> > canvas. How would you do that, knowing that there is not getter for
> > the ImagePlus in the ImageCanvas class?
>
> One way would be to create a new MouseListener for each ImagePlus you
> want to listen to, and store a reference to the ImagePlus as a field of
> the MouseListener, at the time you register the listener.
If you want to go that route, an ImageListener is probably better. You
just have to verify that imp.getCanvas() is the same canvas.
Ciao,
Johannes