Hello ImageJ Community
I'm looking for a way to handle Roi Events. Are there any listeners that throw an event, when the user resizes a Roi, he made before on an image? When there is no listener for that, how can I handle this problem? Kind regards, Michael -- GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01 |
Hi Michael,
you have to add listeners to mousePressed, mouseDragged, mouseClicked and keyPressed events of the ImageCanvas. See the dynamic profiler for an example. http://rsb.info.nih.gov/ij/plugins/download/Dynamic_Profiler.java Michael ________________________________________________________________ On 2 Jul 2009, at 14:45, Michael Strupp wrote: > Hello ImageJ Community > > I'm looking for a way to handle Roi Events. > Are there any listeners that throw an event, when the user resizes > a Roi, he made before on an image? > > When there is no listener for that, how can I handle this problem? > > Kind regards, > Michael |
In reply to this post by Michael Strupp
Hello Michael,
Thanks for your help again. I still use these listeners. Do you mean that I have to check that the canvas point the user clicked, is simultaneously covered by the edge of a roi? I seems a little bit cumbersome to me. Is there no easier way? Is there no possibility that ImageJ gives me a callback when the user hit the edge of a Roi, with the mouse button, so he resizes the Roi, while dragging it? Kind regards, Michael -------- Original-Nachricht -------- > Datum: Thu, 2 Jul 2009 14:52:08 +0200 > Von: Michael Schmid <[hidden email]> > An: [hidden email] > Betreff: Re: Roi listener > Hi Michael, > > you have to add listeners to mousePressed, mouseDragged, mouseClicked > and keyPressed events of the ImageCanvas. See the dynamic profiler > for an example. > http://rsb.info.nih.gov/ij/plugins/download/Dynamic_Profiler.java > > Michael > ________________________________________________________________ > > On 2 Jul 2009, at 14:45, Michael Strupp wrote: > > > Hello ImageJ Community > > > > I'm looking for a way to handle Roi Events. > > Are there any listeners that throw an event, when the user resizes > > a Roi, he made before on an image? > > > > When there is no listener for that, how can I handle this problem? > > > > Kind regards, > > Michael -- Neu: GMX Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate für nur 19,99 Euro/mtl.!* http://portal.gmx.net/de/go/dsl02 |
Hi Michael,
it is not so difficult. On any of these events, get the roi and if it is different from the old one, do whatever you like. In case doing your code repeatedly does not hurt, you can do it on any of these events, whether the roi has changed or not. Roughly like this: Roi oldRoi; public void mousePressed(MouseEvent e) { checkRoi(); } public void mouseDragged(MouseEvent e) { checkRoi(); } public void mouseClicked(MouseEvent e) { checkRoi(); } public void keyPressed(KeyEvent e) { checkRoi(); } private void checkRoi() { Roi roi = imp.getRoi(); //note: The following simple check may miss it //if one vertex of a polygon is dragged. if (roi != oldRoi || !roi.getBounds().equals(oldRoi.getBounds())) { //do whatever you like; if it is a bit time-consuming //just notify() here and do it in a background thread oldRoi = roi; } } Michael ________________________________________________________________ On 2 Jul 2009, at 18:27, Michael Strupp wrote: > Hello Michael, > > Thanks for your help again. > > I still use these listeners. Do you mean that I have to check that > the canvas point the user clicked, is simultaneously covered by the > edge of a roi? > I seems a little bit cumbersome to me. Is there no easier way? > > Is there no possibility that ImageJ gives me a callback when the > user hit the edge of a Roi, with the mouse button, so he resizes > the Roi, while dragging it? > > Kind regards, > Michael > > -------- Original-Nachricht -------- >> Datum: Thu, 2 Jul 2009 14:52:08 +0200 >> Von: Michael Schmid <[hidden email]> >> An: [hidden email] >> Betreff: Re: Roi listener > >> Hi Michael, >> >> you have to add listeners to mousePressed, mouseDragged, mouseClicked >> and keyPressed events of the ImageCanvas. See the dynamic profiler >> for an example. >> http://rsb.info.nih.gov/ij/plugins/download/Dynamic_Profiler.java >> >> Michael >> ________________________________________________________________ >> >> On 2 Jul 2009, at 14:45, Michael Strupp wrote: >> >>> Hello ImageJ Community >>> >>> I'm looking for a way to handle Roi Events. >>> Are there any listeners that throw an event, when the user resizes >>> a Roi, he made before on an image? >>> >>> When there is no listener for that, how can I handle this problem? >>> >>> Kind regards, >>> Michael > |
Free forum by Nabble | Edit this page |