Hello All,
A hopefully simple question. I am creating a plugin which randomly draws a
circular ROI onto an overlay and then displays that overlay on a large TIF
image. My problem is that I would like to zoom in on the circle after
drawing it, and the ImageCanvas.zoomIn() function appears to only actually
include the circle in its field of view a small portion of the time. I have
noticed that on feeding coordinates to the zoomIn() function, that the
supplied coordinates to not actually end up being in the center of the
image following the zom (I dont notice any systematic manner regarding
where the specificied coordinates actually end up in the field of view). I
have attached the code below, I would appreciate any tips regarding how to
zoom in on the ROI and have it more reliably show up on the screen.
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
char keyChar = e.getKeyChar();
int flags = e.getModifiers();
IJ.log("keyPressed: keyCode=" + keyCode + " (" +
KeyEvent.getKeyText(keyCode) + ")");
Random generator = new Random();
int width = img.getWidth();
int height = img.getHeight();
int x = generator.nextInt(width);
int y = generator.nextInt(height);
IJ.log("Coords" + x + " " + y);
canvas.unzoom();
Overlay overlay = new Overlay();
Roi roi = new OvalRoi(x,y,50,50, null);
overlay.add(roi);
img.setOverlay(overlay);
canvas.zoomIn(x,y);
}
Randy
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html