RoiManager runCommand NullPointerException

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

RoiManager runCommand NullPointerException

Gary Richards
Hi,

A simplified version of what i'm attempting to do is:

ImagePlus imp = WindowManager.getCurrentImage();
RoiManager roiManager = RoiManager.getInstance();
RoiManager myRoiManager = new RoiManager();
for (Enumeration elements = roiManager.getROIs().elements(); elements.hasMoreElements(); ) {
     Rectangle originalRoi = ((Roi) elements.nextElement()).getBoundingRect();
     imp.setRoi(originalRoi);
     myRoiManager.runCommand("add");
}

But I cannot get it working properly. myRoiManager.runCommand("add"); is throwing a NullPointerException with a null message.

What i'm essentially trying to do is allow a user to create a number of ROI's with the RoiManager. Then, when the user runs the plugin I want to create a second RoiManager with a copy of the original
Roi's offset by a couple of pixels. This is the reason i've shown using Rectangle's above rather than directly trying to set from the original Roi.

I've been trying to follow the instructions for debugging ImageJ plugins from within Netbeans, but I can't seem to get that working either!

So whilst I continue to try getting debugging working within Netbeans I wondered if anyone knows what i'm doing wrong above?

Thanks

Gary