hay All! I'm writing a plugin that will have two open images. The two
images have the same filename from different folders. I want to trigger an action (roiSave) off of the mouse release that occurs after the drawing of the ROI. How can I identify which image I'm in? Any ideas appreciated - -- Mike |
Mike,
FileInfo fi = imp.getOriginalFileInfo(); if(fi != null){ directory = fi.directory; } Bob Robert P. Dougherty, Ph.D. President, OptiNav, Inc. Phone (425) 467-1118 Fax (425) 467-1119 www.optinav.com > -----Original Message----- > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of > Michael Sullivan > Sent: Tuesday, December 20, 2005 12:55 PM > To: [hidden email] > Subject: Which Image > > hay All! I'm writing a plugin that will have two open images. The two > images have the same filename from different folders. I want to trigger > an action (roiSave) off of the mouse release that occurs after the drawing > of the ROI. How can I identify which image I'm in? Any ideas appreciated > - > -- Mike |
In reply to this post by Sullivan, Michael J (College of Med.)
> hay All! I'm writing a plugin that will have two open
> images. The two images have the same filename from > different folders. I want to trigger an action (roiSave) > off of the mouse release that occurs after the drawing of > the ROI. How can I identify which image I'm in? Any ideas > appreciated - > -- Mike In a macro: dir = getDirectory("image"); In a plugin: String dir = IJ.getDirectory("image"); -wayne |
In reply to this post by Sullivan, Michael J (College of Med.)
Wayne, Bob, Thanks for the responses. But I don't know which image/canvas the mouse event was triggered from; the mouse listener does not seem to be unique to the canvas.
// "this" is the class from which the images are opened. preImageCanvas.addMouseListener(this); postImageCanvas.addMouseListener(this); I thought a "focus" test would work but it doesn't or I'm testing the wrong thing --- Mike -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Wayne Rasband Sent: Tuesday, December 20, 2005 5:47 PM To: [hidden email] Subject: Re: Which Image > hay All! I'm writing a plugin that will have two open images. The two > images have the same filename from different folders. I want to > trigger an action (roiSave) off of the mouse release that occurs after > the drawing of the ROI. How can I identify which image I'm in? Any > ideas appreciated - > -- Mike In a macro: dir = getDirectory("image"); In a plugin: String dir = IJ.getDirectory("image"); -wayne |
I guess you create a new custom window and canvas for each window?
If so you could give those an id and check that in the listener. kurt On 21 Dec 2005, at 16:26, Sullivan, Michael J (College of Med.) wrote: > Wayne, Bob, Thanks for the responses. But I don't know which image/ > canvas the mouse event was triggered from; the mouse listener does > not seem to be unique to the canvas. > > // "this" is the class from which the images are opened. > preImageCanvas.addMouseListener(this); > postImageCanvas.addMouseListener(this); > > I thought a "focus" test would work but it doesn't or I'm testing > the wrong thing > > --- Mike > > -----Original Message----- > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf > Of Wayne Rasband > Sent: Tuesday, December 20, 2005 5:47 PM > To: [hidden email] > Subject: Re: Which Image > >> hay All! I'm writing a plugin that will have two open images. The >> two >> images have the same filename from different folders. I want to >> trigger an action (roiSave) off of the mouse release that occurs >> after >> the drawing of the ROI. How can I identify which image I'm in? Any >> ideas appreciated - >> -- Mike > > In a macro: > > dir = getDirectory("image"); > > In a plugin: > > String dir = IJ.getDirectory("image"); > > -wayne *--*--*--*--*--*--*--*--*--*--*--*--*--* University of Sheffield Academic Neurology Unit Division of Genomic Medicine E Floor, Medical School Beech Hill Road Sheffield S10 2RX United Kingdom Tel: ++44 (0) 114 271 2473 Fax: ++44 (0) 114 226 1201 Email: [hidden email] *--*--*--*--*--*--*--*--*--*--*--*--*--* |
In reply to this post by Sullivan, Michael J (College of Med.)
Thanks Kurt, that looks like it'll work. Just get to hammer together
the code to get to the events/source/ijCanvas/ID. --- Mike -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Kurt De Vos Sent: Wednesday, December 21, 2005 11:30 AM To: [hidden email] Subject: Re: Which Image I guess you create a new custom window and canvas for each window? If so you could give those an id and check that in the listener. kurt On 21 Dec 2005, at 16:26, Sullivan, Michael J (College of Med.) wrote: > Wayne, Bob, Thanks for the responses. But I don't know which image/ > canvas the mouse event was triggered from; the mouse listener does not > seem to be unique to the canvas. > > // "this" is the class from which the images are opened. > preImageCanvas.addMouseListener(this); > postImageCanvas.addMouseListener(this); > > I thought a "focus" test would work but it doesn't or I'm testing the > wrong thing > > --- Mike > > -----Original Message----- > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of > Wayne Rasband > Sent: Tuesday, December 20, 2005 5:47 PM > To: [hidden email] > Subject: Re: Which Image > >> hay All! I'm writing a plugin that will have two open images. The >> two images have the same filename from different folders. I want to >> trigger an action (roiSave) off of the mouse release that occurs >> after the drawing of the ROI. How can I identify which image I'm in? >> Any ideas appreciated - >> -- Mike > > In a macro: > > dir = getDirectory("image"); > > In a plugin: > > String dir = IJ.getDirectory("image"); > > -wayne *--*--*--*--*--*--*--*--*--*--*--*--*--* University of Sheffield Academic Neurology Unit Division of Genomic Medicine E Floor, Medical School Beech Hill Road Sheffield S10 2RX United Kingdom Tel: ++44 (0) 114 271 2473 Fax: ++44 (0) 114 226 1201 Email: [hidden email] *--*--*--*--*--*--*--*--*--*--*--*--*--* |
This is a bit of sample code from a plugin of mine that might be
helpfull: public CanvasSync(MyImageCanvas canvas1, MyImageCanvas canvas2) { this.canvas1 = canvas1; this.canvas2 = canvas2; } public void mouseClicked(MouseEvent mouseEvent) {} public void mouseReleased(MouseEvent mouseEvent) {} public void mousePressed(MouseEvent mouseEvent) {} public void mouseMoved(MouseEvent mouseEvent) { if (mouseEvent.getComponent().equals(canvas1)){ //do something }else if (mouseEvent.getComponent().equals(canvas2)){ //do something } } kurt |
In reply to this post by Sullivan, Michael J (College of Med.)
Hay Kurt. Thanks for the example; it made me examine the methods for
the mouseEvent. Instead of getComponent() I use getSource() which returned a canvas with a unique name retrievable by imageCanvas.getName(). So now it's on to the next part of the plugin. Thanks, --- Mike -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Kurt De Vos Sent: Wednesday, December 21, 2005 12:07 PM To: [hidden email] Subject: Re: Which Image This is a bit of sample code from a plugin of mine that might be helpfull: public CanvasSync(MyImageCanvas canvas1, MyImageCanvas canvas2) { this.canvas1 = canvas1; this.canvas2 = canvas2; } public void mouseClicked(MouseEvent mouseEvent) {} public void mouseReleased(MouseEvent mouseEvent) {} public void mousePressed(MouseEvent mouseEvent) {} public void mouseMoved(MouseEvent mouseEvent) { if (mouseEvent.getComponent().equals(canvas1)){ //do something }else if (mouseEvent.getComponent().equals(canvas2)){ //do something } } kurt |
Free forum by Nabble | Edit this page |