Hi folks,
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? Cheers jy -- Jean-Yves Tinevez PFID - Imagopole Institut Pasteur 25-28, rue du Docteur Roux 75724 Paris cedex 15 France tel: +33 1 40 61 31 77 |
Hi Jean-Yves,
you could try (ImageWindow)imageCanvas.getParent(), which should give you the associated ImageWindow. ImageWindow has a getImagePlus() method. Michael ________________________________________________________________ On 2 Dec 2009, at 15:34, Jean-Yves Tinevez wrote: > Hi folks, > > 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? > > Cheers > jy > > -- > Jean-Yves Tinevez > PFID - Imagopole > Institut Pasteur > 25-28, rue du Docteur Roux > 75724 Paris cedex 15 > France > tel: +33 1 40 61 31 77 |
In reply to this post by Jean-Yves Tinevez-2
Hi Jean-Yves,
> 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. I don't know if this is possible in your case. Best wishes, Bene |
In reply to this post by Jean-Yves Tinevez-2
> Hi folks,
> > 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? > > Cheers The ImageCanvas class in the ImageJ 1.43m daily build has a getImage() getter that returns the ImagePlus. -wayne |
In reply to this post by Benjamin Schmid-2
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 |
In reply to this post by Wayne Rasband
Hi,
On Wed, 2 Dec 2009, Wayne Rasband 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? > > The ImageCanvas class in the ImageJ 1.43m daily build has a getImage() > getter that returns the ImagePlus. Is it not a dangerous direction to make the image data structures even less GUI agnostic than they are already? Ciao, Dscho |
In reply to this post by dscho
Thank you all for your answers.
In my case, the simplest way was to use the ImageWindow method or the future ImageCanvas method. Doing this, I minimize the the reach of my plugin. Cheers jyt |
In reply to this post by dscho
On 2/12/09 17:58, Johannes Schindelin wrote:
> Hi, >> The ImageCanvas class in the ImageJ 1.43m daily build has a getImage() >> getter that returns the ImagePlus. > > Is it not a dangerous direction to make the image data structures even > less GUI agnostic than they are already? Hi Johannes, could you just elaborate why it is a problem this way around ? It seems the Wayne's modification makes a GUI component capable of pointing to the underlying data, not the other way round. It seems that there is no need for the ImagePlus to be aware of the ImageCanvas for this, but I'd be curious to know where the risk lies. Adrian |
Free forum by Nabble | Edit this page |