protected void addMouseMotionListener(ImageCanvas canvas) { if (mouseMotionProxy != null) { canvas.addMouseMotionListener(mouseMotionProxy); // make sure that IJ gets only unconsumed key events MouseMotionListener listener = null; for (MouseMotionListener listener2 : canvas.getMouseMotionListeners()) if (listener2 == canvas || listener2.getClass().getName().endsWith("MouseMotionProxyIfNotConsumed")) listener = listener2; if (listener == null) listener = new MouseMotionProxyIfNotConsumed(canvas); else { canvas.removeMouseMotionListener(listener); if (listener == canvas) listener = new MouseMotionProxyIfNotConsumed(canvas); } canvas.addMouseMotionListener(listener); } }
/** Adds "this" object as mouse listener and mouse motion listener to each of the windows in input array. */ private void addWindows(Vector v) { Integer I; ImagePlus imp; ImageWindow iw; // Handle initial case of no windows. if(vwins == null && v.size() > 0) vwins = new Vector(); // Add all windows in vector to synchronized window list. for(int n=0; n<v.size();++n) { I = (Integer)v.elementAt(n); // Make sure input window is not already on list. if(!vwins.contains(I)) { imp = WindowManager.getImage(I.intValue()); if (imp != null) { iw = imp.getWindow(); iw.getCanvas().addMouseMotionListener(this); iw.getCanvas().addMouseListener(this); vwins.addElement(I); } } } }
/** Adds "this" object as mouse listener and mouse motion listener to each of the windows in input array. */ private void addWindows(Vector v) { Integer I; ImagePlus imp; ImageWindow iw; // Handle initial case of no windows. if(vwins == null && v.size() > 0) vwins = new Vector(); // Add all windows in vector to synchronized window list. for(int n=0; n<v.size();++n) { I = (Integer)v.elementAt(n); // Make sure input window is not already on list. if(!vwins.contains(I)) { imp = WindowManager.getImage(I.intValue()); if (imp != null) { iw = imp.getWindow(); iw.getCanvas().addMouseMotionListener(this); iw.getCanvas().addMouseListener(this); vwins.addElement(I); } } } }
private void createListeners() { //IJ.log("createListeners"); if(srcImp == null) { return; } ImageCanvas canvas = srcImp.getCanvas(); if(canvas == null) { return; } canvas.addMouseListener(this); canvas.addMouseMotionListener(this); canvas.addKeyListener(this); ImagePlus.addImageListener(this); Font font = live.getFont(); live.setFont(new Font(font.getName(), Font.BOLD, font.getSize())); live.setForeground(Color.red); }
public ImageCanvas(ImagePlus imp) { this.imp = imp; paintPending = new AtomicBoolean(false); ij = IJ.getInstance(); int width = imp.getWidth(); int height = imp.getHeight(); imageWidth = width; imageHeight = height; srcRect = new Rectangle(0, 0, imageWidth, imageHeight); setSize(imageWidth, imageHeight); magnification = 1.0; addMouseListener(this); addMouseMotionListener(this); addKeyListener(ij); // ImageJ handles keyboard shortcuts setFocusTraversalKeysEnabled(false); //setScaleToFit(true); }
public ImageCanvas(ImagePlus imp) { this.imp = imp; paintPending = new AtomicBoolean(false); ij = IJ.getInstance(); int width = imp.getWidth(); int height = imp.getHeight(); imageWidth = width; imageHeight = height; srcRect = new Rectangle(0, 0, imageWidth, imageHeight); setSize(imageWidth, imageHeight); magnification = 1.0; addMouseListener(this); addMouseMotionListener(this); addKeyListener(ij); // ImageJ handles keyboard shortcuts setFocusTraversalKeysEnabled(false); //setScaleToFit(true); }
private void addListeners(ImageCanvas canvas) { canvas.addMouseListener(this); canvas.addMouseMotionListener(this); canvas.addKeyListener(this); win.addWindowListener (this); win.addMouseWheelListener(this); win.addFocusListener(this); ImagePlus.addImageListener(this); Executer.addCommandListener(this); }
private void addListeners(ImageCanvas canvas) { canvas.addMouseListener(this); canvas.addMouseMotionListener(this); canvas.addKeyListener(this); win.addWindowListener (this); win.addMouseWheelListener(this); win.addFocusListener(this); ImagePlus.addImageListener(this); Executer.addCommandListener(this); }
/** * Kill listeners. */ public void killListeners () { if(imp != null) { final ImageWindow iw = imp.getWindow(); if(null != iw) { final ImageCanvas ic = iw.getCanvas(); ic.removeKeyListener(pa); ic.removeMouseListener(pa); ic.removeMouseMotionListener(pa); ic.addMouseMotionListener(ic); ic.addMouseListener(ic); ic.addKeyListener(IJ.getInstance()); } } } /* end killListeners */
peakCountPlot = plot.show().getImagePlus(); final ImageCanvas canvas = peakCountPlot.getCanvas(); canvas.addMouseMotionListener(new MouseAdapter() { @Override public void mouseMoved(MouseEvent e) {
imp.getCanvas().addMouseMotionListener( this ); imp.getCanvas().addKeyListener( this );
imp.getCanvas().addMouseMotionListener( this ); imp.getCanvas().addKeyListener( this );
public void create() { xmin = min(x); ymin = min(y); xmax = max(x); ymax = max(y); xdiff = xmax - xmin; ydiff = ymax - ymin; factor = xdiff > ydiff ? size / xdiff : size / ydiff; w = (int)(xdiff * factor); h = (int)(ydiff * factor); ip = new ByteProcessor(w+2*INDENT, h+3*INDENT+CTRL_HEIGHT); ip.setColor(255); ip.fill(); drawAxis(); drawPoints(); imp = new ImagePlus("lkdjf", ip); imp.show(); imp.getCanvas().addMouseMotionListener(this); }
imp.getCanvas().addMouseMotionListener( this ); imp.getCanvas().addKeyListener( this );
@Override public void run( final String arg ) { /* cleanup */ m.clear(); imp = IJ.getImage(); target = imp.getProcessor(); source = target.duplicate(); source.setInterpolationMethod( ImageProcessor.BILINEAR ); init(); createMapping(); painter = new MappingThread( imp, source, target, pleaseRepaint, mapping, interpolate ); painter.start(); Toolbar.getInstance().setTool( Toolbar.getInstance().addTool( "Add_and_drag_handles." ) ); imp.getCanvas().addMouseListener( this ); imp.getCanvas().addMouseMotionListener( this ); imp.getCanvas().addKeyListener( this ); imp.getWindow().addKeyListener( this ); IJ.getInstance().addKeyListener( this ); }
imp.getCanvas().addMouseMotionListener( this ); imp.getCanvas().addKeyListener( this );
@Override public void run( final String arg ) { /* cleanup */ m.clear(); imp = IJ.getImage(); target = imp.getProcessor(); source = target.duplicate(); source.setInterpolationMethod( ImageProcessor.BILINEAR ); init(); createMapping(); painter = new MappingThread( imp, source, target, pleaseRepaint, mapping, interpolate ); painter.start(); Toolbar.getInstance().setTool( Toolbar.getInstance().addTool( "Add_and_drag_handles." ) ); imp.getCanvas().addMouseListener( this ); imp.getCanvas().addMouseMotionListener( this ); imp.getCanvas().addKeyListener( this ); imp.getWindow().addKeyListener( this ); IJ.getInstance().addKeyListener( this ); }
ic.addKeyListener(pa); ic.addMouseListener(pa); ic.addMouseMotionListener(pa); started = true;
/** * Method to start the dynamic reslice process after all parameters * have been set. Will not initiate as long as there is no ROI. */ public void start() { if (hasStarted || imp.getRoi() == null) return; // Get type of source window rgb = imp.getType() == ImagePlus.COLOR_RGB; notFloat = !rgb && imp.getType() != ImagePlus.GRAY32; // Create the destination ImagePlus dest_imp by get a slice a first time. dest_imp = new ImagePlus("Dynamic Reslice of "+imp.getShortTitle(), getSlice(imp, imp.getRoi())); dealWithCalibration(); // Copy min & max to new result final ImageProcessor ip = imp.getProcessor(); final double min = ip.getMin(); final double max = ip.getMax(); if (!rgb) dest_imp.getProcessor().setMinAndMax(min, max); // Display window result dest_imp.show(); // Add listeners imp.getCanvas().addMouseMotionListener(this); imp.getWindow().addWindowListener(this); dest_imp.getWindow().addWindowListener(this); // Set the started flag to true hasStarted = true; }
window.addMouseWheelListener(window); canvas.addKeyListener(IJ.getInstance()); canvas.addMouseMotionListener(canvas); canvas.addMouseListener(canvas);