ROI in standalone java application

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

ROI in standalone java application

laserCoder
I am coding a standalone java application using the imagej jar file with only the API to work from as I can't find any guides on this.  So my question is pretty straight forward.

How on earth do you select a region of interest on an image canvas?

At the moment I have created a subclass of ImageCanvas and a subclass of ROI which is a field on the ImageCanvas.  The code is as below as I thought all I needed to do was pass the mouse events to ROI but nothing is happening.  Any help would be much appreciated.

public class TheImageCanvas extends ij.gui.ImageCanvas
{
    TheRoi myRoi;
   
    public TheImageCanvas(ImagePlus imp)
    {
        super(imp);        
    }  
   
    public void mousePressed(MouseEvent e)
    {
        myRoi = new TheRoi(e.getX(),e.getY(),this.imp );
        myRoi.handleMousePressed(e);
    }
   
    public void mouseDragged(MouseEvent e)
    {        
        myRoi.handleMouseDragged(e);        
    }

    public void mouseReleased(MouseEvent e)
    {        
        myRoi.handleMouseReleased(e);
    }
}

public class TheRoi extends ij.gui.Roi
{
   
    public TheRoi(int sx, int sy, ImagePlus imp)
    {
        super(sx,sy,imp);        
    }
   
    public void handleMousePressed(MouseEvent e)
    {
       super.handleMouseDown(e.getX(), e.getY);
    }
   
    public void handleMouseReleased(MouseEvent e)
    {
        super.handleMouseUp(e.getX(), e.getY);
    }
   
    public void handleMouseDragged(MouseEvent e)
    {
       super.handleMouseDrag(e.getXOnScreen(), e.getYOnScreen(), e.MOUSE_DRAGGED);  
    }
   
}