Refine search
final MainDialog dialog) super( 0, 0, imp.getWidth(), imp.getHeight() ); this.imp = imp; this.tb = tb; this.dialog = dialog; this.pa = new PointAction(imp, this, tb, dialog); final ImageWindow iw = imp.getWindow(); if(null != iw) final ImageCanvas ic = iw.getCanvas(); iw.removeKeyListener(IJ.getInstance()); iw.addKeyListener(pa); ic.removeMouseMotionListener(ic); ic.removeMouseListener(ic); ic.removeKeyListener(IJ.getInstance()); ic.addKeyListener(pa); ic.addMouseListener(pa); ic.addMouseMotionListener(pa); started = true;
void zoomToSelection(ImagePlus imp, ImageCanvas ic) { Roi roi = imp.getRoi(); ic.unzoom(); if (roi==null) return; Rectangle w = imp.getWindow().getBounds(); Rectangle r = roi.getBounds(); double mag = ic.getMagnification(); int marginw = (int)((w.width - mag * imp.getWidth())); int marginh = (int)((w.height - mag * imp.getHeight())); int x = r.x+r.width/2; int y = r.y+r.height/2; mag = ic.getHigherZoomLevel(mag); while(r.width*mag<w.width - marginw && r.height*mag<w.height - marginh) { ic.zoomIn(ic.screenX(x), ic.screenY(y)); double cmag = ic.getMagnification(); if (cmag==32.0) break; mag = ic.getHigherZoomLevel(cmag); w = imp.getWindow().getBounds(); } }
public void mouseReleased(ImagePlus imp, MouseEvent e) { ImageCanvas ic = imp.getCanvas(); int sx = e.getX(); int sy = e.getY(); int ox = ic.offScreenX(sx); int oy = ic.offScreenY(sy); Roi roi = imp.getRoi(); if (arrow!=null && !(roi!=null && (roi instanceof Arrow) && roi.contains(ox,oy))) { arrow.mouseReleased(e); e.consume(); } }
protected void handleMouseDown(int sx, int sy) { if (state==NORMAL && ic!=null) { state = MOVING; startX = ic.offScreenX(sx); startY = ic.offScreenY(sy); startXD = ic.offScreenXD(sx); startYD = ic.offScreenYD(sy); //showStatus(); } }
protected void unregisterTool(ImageCanvas canvas) { if (canvas == null) return; if (mouseProxy != null) canvas.removeMouseListener(mouseProxy); if (mouseMotionProxy != null) // we leave the ijMouseMotionProxy in because it might be required by another active custom tool canvas.removeMouseMotionListener(mouseMotionProxy); if (mouseWheelProxy != null) canvas.removeMouseWheelListener(mouseWheelProxy); if (keyProxy != null) // we leave the ijKeyProxy in because it might be required by another active custom tool canvas.removeKeyListener(keyProxy); }
/** Store srcRect and Magnification of the currently active ImageCanvas ic */ private void storeCanvasState(ImageCanvas ic) { currentMag = ic.getMagnification(); currentSrcRect = new Rectangle(ic.getSrcRect()); }
public void mouseReleased(MouseEvent e) { int ox = offScreenX(e.getX()); int oy = offScreenY(e.getY()); if ((overlay!=null||showAllOverlay!=null) && ox==mousePressedX && oy==mousePressedY) { boolean cmdDown = IJ.isMacOSX() && e.isMetaDown(); Roi roi = imp.getRoi(); if (roi!=null && roi.getBounds().width==0) roi=null; if ((e.isAltDown()||e.isControlDown()||cmdDown) && roi==null) { if (activateOverlayRoi(ox, oy)) return; } else if ((System.currentTimeMillis()-mousePressedTime)>250L && !drawingTool()) { if (activateOverlayRoi(ox,oy)) return; PlugInTool tool = Toolbar.getPlugInTool(); if (tool!=null) { tool.mouseReleased(imp, e); && roi.getState()==roi.CONSTRUCTING && type!=roi.POINT) imp.deleteRoi(); else roi.handleMouseUp(e.getX(), e.getY());
public void mouseMoved(MouseEvent e) { int sx = e.getX(); int sy = e.getY(); int ox = offScreenX(sx); int oy = offScreenY(sy); flags = e.getModifiers(); setCursor(sx, sy, ox, oy); mousePressedX = mousePressedY = -1; IJ.setInputEvent(e); PlugInTool tool = Toolbar.getPlugInTool(); if (tool!=null) { tool.mouseMoved(imp, e); if (e.isConsumed()) return; Roi roi = imp.getRoi(); int type = roi!=null?roi.getType():-1; if (type>0 && (type==Roi.POLYGON||type==Roi.POLYLINE||type==Roi.ANGLE||type==Roi.LINE) && roi.getState()==roi.CONSTRUCTING) roi.mouseMoved(e); else { if (ox<imageWidth && oy<imageHeight) { ImageWindow win = imp.getWindow(); if (win!=null&&showCursorStatus) win.mouseMoved(ox, oy); } else IJ.showStatus("");
public void mouseDragged(MouseEvent e) { int x = e.getX(); int y = e.getY(); xMouse = offScreenX(x); yMouse = offScreenY(y); flags = e.getModifiers(); mousePressedX = mousePressedY = -1; //IJ.log("mouseDragged: "+flags); if (flags==0) // workaround for Mac OS 9 bug flags = InputEvent.BUTTON1_MASK; if (Toolbar.getToolId()==Toolbar.HAND || IJ.spaceBarDown()) scroll(x, y); else { PlugInTool tool = Toolbar.getPlugInTool(); if (tool!=null) { tool.mouseDragged(imp, e); if (e.isConsumed()) return; } IJ.setInputEvent(e); Roi roi = imp.getRoi(); if (roi != null) roi.handleMouseDrag(x, y, flags); } }
public void mousePressed(ImagePlus imp, MouseEvent e) { ImageCanvas ic = imp.getCanvas(); int sx = e.getX(); int sy = e.getY(); int ox = ic.offScreenX(sx); int oy = ic.offScreenY(sy); Roi roi = imp.getRoi(); int handle = roi!=null?roi.isHandle(ox, oy):-1; if (!(roi!=null && (roi instanceof Arrow) && (handle>=0||roi.contains(ox,oy)))) { arrow = new Arrow(sx, sy, imp); imp.setRoi(arrow, false); e.consume(); } }
public void mousePressed(ImagePlus imp, MouseEvent e) { if (imp == null) return; imp2 = imp; ic = imp.getCanvas(); if (ic == null) return; roi = imp.getRoi(); if (roi==null) { IJ.beep(); IJ.showStatus("No selection"); return; } startX = ic.offScreenX(e.getX()); startY = ic.offScreenY(e.getY()); if (defaultRotationMode == UPDOWNROTATION){ centerX = imp.getWidth()/2; centerY = imp.getHeight()/2; } else { double[] centroid = roi.getContourCentroid(); centerX = (int)Math.round(centroid[0]); centerY = (int)Math.round(centroid[1]); } }
/** * Method mouse moved, show the coordinates of the mouse pointer. * * @param e mouse event */ public void mouseMoved (final MouseEvent e) { setControl(); final int x = mainImp.getWindow().getCanvas().offScreenX(e.getX()); final int y = mainImp.getWindow().getCanvas().offScreenY(e.getY()); IJ.showStatus(mainImp.getLocationAsString(x, y) + getValueAsString(x, y)); } /* end mouseMoved */
@Override public void mousePressed(final MouseEvent e) { if (IJ.spaceBarDown() || Toolbar.getToolId() == Toolbar.MAGNIFIER || Toolbar.getToolId() == Toolbar.HAND) { super.mousePressed(e); return; } if (currentMarkerVector == null) { IJ.error("Select a counter type first!"); return; } final int x = super.offScreenX(e.getX()); final int y = super.offScreenY(e.getY()); if (!delmode) { final CellCntrMarker m = new CellCntrMarker(x, y, img.getCurrentSlice()); currentMarkerVector.addMarker(m); } else { final CellCntrMarker m = currentMarkerVector.getMarkerFromPosition(new Point(x, y), img .getCurrentSlice()); currentMarkerVector.remove(m); } repaint(); cc.populateTxtFields(); }
public void mouseMoved(MouseEvent e) { int x = canvas.offScreenX(e.getX()); int y = canvas.offScreenY(e.getY()); original.setSlice(y + 1); PolygonRoi roi = rois[y]; if (roi == null) { original.setOverlay(null); original.killRoi(); return; } FloatPolygon polygon = roi.getFloatPolygon(); if (polygon.npoints <= x) return; int x2 = (int)polygon.xpoints[x]; int y2 = (int)polygon.ypoints[x]; original.setOverlay(new Overlay(new PointRoi(x2, y2))); original.setRoi(roi); }
if (vwins == null) return; if (Toolbar.getToolId()!= Toolbar.MAGNIFIER && (e.isPopupTrigger() || (e.getModifiers() & MouseEvent.META_MASK)!=0)) return; ImagePlus imp; ImageWindow iw; ImageCanvas icc = (ImageCanvas) e.getSource(); ImageWindow iwc = (ImageWindow) icc.getParent(); iw = imp.getWindow(); ic = iw.getCanvas(); ic.paint(ic.getGraphics()); if(iw != iwc) { ic = iw.getCanvas(); if (cCoords.getState()) { p = getMatchingCoords(ic, icc, x, y); ic.mousePressed(adaptEvent(e, ic, p));
@Override public void mouseMoved(MouseEvent e) { if (image == null) return; int x = canvas.offScreenX(e.getX()); int frame = 1 + (int)((peakCountPlotLimits[1] - peakCountPlotLimits[0]) * (x - Plot.LEFT_MARGIN) / (peakCountPlot.getWidth() - Plot.LEFT_MARGIN - Plot.RIGHT_MARGIN)); if (frame >= 1 && frame <= image.getStackSize()) image.setSlice(frame); } });
public int getOffscreenX(MouseEvent e) { ImageCanvas canvas = getImageCanvas(e); return canvas == null ? -1 : canvas.offScreenX(e.getX()); }
public int getOffscreenY(MouseEvent e) { ImageCanvas canvas = getImageCanvas(e); return canvas == null ? -1 : canvas.offScreenY(e.getY()); }
/** * 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; }
imp = WindowManager.getCurrentImage(); standardRectangle = new Rectangle( imp.getWidth()/4, imp.getHeight()/4, imp.getWidth()/2, imp.getHeight()/2 ); if ( imp.getType() == ImagePlus.COLOR_RGB || imp.getType() == ImagePlus.COLOR_256 ) IJ.log( "Color images are not supported, please convert to 8, 16 or 32-bit grayscale" ); return; if ( roi.getType() != Roi.RECTANGLE ) IJ.log( "Only rectangular rois are supported..." ); return; imp.getCanvas().addMouseListener( roiListener );