Hello,
I'm trying to move a form (a rectangle for example) drawn upon an image using the mouse. The code is : public class JFrame_TestImageJ extends javax.swing.JFrame implements MouseListener { private ij.IJ myImageJ; private ij.ImagePlus myImagePlus; private ij.process.ImageProcessor myImageProcessor; private ij.gui.ImageCanvas myImageCanvas; private void initGUI() { myImageJ = new ij.IJ(); myImageJ.open("image.bmp"); myImagePlus = myImageJ.getImage(); setSize(myImagePlus.getWidth(), myImagePlus.getHeight()); myImageProcessor = myImagePlus.getProcessor(); myImageProcessor.setColor(Color.red); myImageCanvas = new ij.gui.ImageCanvas(myImagePlus); this.add(myImageCanvas); myImageCanvas.addMouseListener(this); } public void mousePressed(MouseEvent evt) { myImageProcessor.drawRect(evt.getX(), evt.getY(), 150, 150); myImagePlus.setProcessor(null,myImageProcessor); } The problem is the update of the form draw. When I press the mouse, the rectangle doesn't appear. Is anybody can tell me what's wrong ??? When I resize the frame, the rectangle then appears !!!! Thanks ... |
Hello
This is more a coding problem then an image analysis problem but I'm using ImageJ so I thought I'd ask incase anyone else has had the same problem. I've written a plugin which I've made in stages adding new parts into it I've written separately. I need to have them in one plugin as the data one part creates needs to be manipulated then stored later in the plugin. The problem is with my very first line of code: "public class Steriology_Output extends PlugInFilter{" The problem is with the PlugInFilter, apparantly I "Can't subclass interfaces". This is very frustrating as I've used PlugInFilter in all thje small parts of code I've written separately and they need it to work. ======================================================================== http://www.international-marine.com International Marine Coatings. http://www.international-pc.com International Protective Coatings. http://www.yachtpaint.com International Yacht Coatings. ======================================================================== Confidentiality Note: This message, including attachments, is confidential and may be privileged. If you are not an intended recipient, please notify the sender then delete and destroy the original message and all copies. You should not copy, forward and/or disclose this message, in whole or in part, without permission of the sender. If you receive this e-mail message in error please notify us immediately by e-mail at [hidden email] |
Hi,
On Mon, 1 Aug 2005, Holmes, Charlotte wrote: > "public class Steriology_Output extends PlugInFilter{" You can extend classes, but you implement interfaces: public class StereologyOutput implements PlugInFilter [...] Hth, Dscho |
In reply to this post by Blandine Chanteloup
You will have to repaint the imageCanvas after drawing to show the
rectangle (which is what happens when you resize). kurt Blandine Chanteloup wrote: > Hello, > > I'm trying to move a form (a rectangle for example) drawn upon an > image using the mouse. > > The code is : > > public class JFrame_TestImageJ extends javax.swing.JFrame implements > MouseListener { > private ij.IJ myImageJ; > private ij.ImagePlus myImagePlus; > private ij.process.ImageProcessor myImageProcessor; > private ij.gui.ImageCanvas myImageCanvas; > > private void initGUI() { > myImageJ = new ij.IJ(); > myImageJ.open("image.bmp"); > myImagePlus = myImageJ.getImage(); > setSize(myImagePlus.getWidth(), myImagePlus.getHeight()); > myImageProcessor = myImagePlus.getProcessor(); > myImageProcessor.setColor(Color.red); > myImageCanvas = new ij.gui.ImageCanvas(myImagePlus); > this.add(myImageCanvas); > myImageCanvas.addMouseListener(this); > } > > public void mousePressed(MouseEvent evt) { > myImageProcessor.drawRect(evt.getX(), evt.getY(), 150, 150); > myImagePlus.setProcessor(null,myImageProcessor); > } > > > The problem is the update of the form draw. > When I press the mouse, the rectangle doesn't appear. > Is anybody can tell me what's wrong ??? > > When I resize the frame, the rectangle then appears !!!! > > Thanks ... -- *--*--*--*--*--*--*--*--*--*--* 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] *--*--*--*--*--*--*--*--*--*--* |
Free forum by Nabble | Edit this page |