Re: Live lens cursor?
Posted by Jerome Mutterer on Dec 09, 2005; 3:34pm
URL: http://imagej.273.s1.nabble.com/Live-lens-cursor-tp3704274p3704276.html
I have done just that. The code is included below.
It is not a fast method, so you're supposed to click
the mouse to have the zoom updated.
Le 9 déc. 05 à 16:02, Bill Christens-Barry a écrit :
> I wonder if the method demo'd by Wayne in his Graphic_Overlay
> plugin would be fast
> enough for repainting as the mouse is moved.
Jerome
Graphic_Overlay_mod.java
import ij.plugin.*;
import ij.*;
import ij.gui.*;
import ij.process.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
public class Graphic_Overlay_mod implements PlugIn {
public void run(String arg) {
ImagePlus imp = IJ.getImage();
CustomCanvas cc = new CustomCanvas(imp);
if (imp.getStackSize()>1)
new StackWindow(imp, cc);
else
new ImageWindow(imp, cc);}
class CustomCanvas extends ImageCanvas {
int xpos =100;
int ypos =200;
int size =40;
CustomCanvas(ImagePlus imp) {
super(imp);
}
public void paint(Graphics g) {
super.paint(g);
drawOverlay(g);
}
void drawOverlay(Graphics g) {
g.setColor(Color.red);
g.drawRect(xpos,ypos,size,size);
ImagePlus im2 = imp;
g.drawImage(imp.getImage(),xpos-50,ypos-50,xpos
+50,ypos+50,xpos-25,ypos-25,xpos+25,ypos+25,this);
}
public void mousePressed(MouseEvent e) {
super.mousePressed(e);
if (e.isAltDown()) {
xpos = -100;
ypos = -100;
return;
}
xpos = offScreenX(e.getX());
ypos = offScreenY(e.getY());
}
}
}