/** Implements the Image/Zoom/View 100% command. */ public void zoom100Percent() { if (magnification == 1.0) return; double imag = imp.getWindow().getInitialMagnification(); if (magnification != imag) unzoom(); if (magnification == 1.0) return; if (magnification < 1.0) { while (magnification < 1.0) zoomIn(imageWidth / 2, imageHeight / 2); } else if (magnification > 1.0) { while (magnification > 1.0) zoomOut(imageWidth / 2, imageHeight / 2); } else return; int x = xMouse, y = yMouse; if (mouseExited) { x = imageWidth / 2; y = imageHeight / 2; } int sx = screenX(x); int sy = screenY(y); adjustSourceRect(1.0, sx, sy); repaint(); }
public void mousePressed(MouseEvent e) { // if (ij==null) return; showCursorStatus = true; int toolID = Toolbar.getToolId(); ImageWindow win = imp.getWindow(); if (win != null && win.running2 && toolID != Toolbar.MAGNIFIER) { if (win instanceof StackWindow) ((StackWindow) win).setAnimate(false); else win.running2 = false; return; } int x = e.getX(); int y = e.getY(); flags = e.getModifiers(); // IJ.log("Mouse pressed: " + e.isPopupTrigger() + " " + ij.modifiers(flags)); // if (toolID!=Toolbar.MAGNIFIER && e.isPopupTrigger()) { if (toolID != Toolbar.MAGNIFIER && (e.isPopupTrigger() || (!IJ.isMacintosh() && (flags & Event.META_MASK) != 0))) { handlePopupMenu(e); return; } int ox = offScreenX(x); int oy = offScreenY(y); xMouse = ox; yMouse = oy; if (IJ.spaceBarDown()) { // temporarily switch to "hand" tool of space bar down setupScroll(ox, oy); return; } if (showAllROIs) { Roi roi = imp.getRoi(); if (!(roi != null && (roi.contains(ox, oy) || roi.isHandle(x, y) >= 0)) && roiManagerSelect(x, y)) return; } if (customRoi && overlay != null) return; switch (toolID) { case Toolbar.MAGNIFIER: if (IJ.shiftKeyDown()) zoomToSelection(ox, oy); else if ((flags & (Event.ALT_MASK | Event.META_MASK | Event.CTRL_MASK)) != 0) { // IJ.run("Out"); zoomOut(x, y); if (getMagnification() < 1.0) imp.repaintWindow(); } else { // IJ.run("In"); zoomIn(x, y); if (getMagnification() <= 1.0) imp.repaintWindow(); } break; case Toolbar.HAND: setupScroll(ox, oy); break; case Toolbar.DROPPER: setDrawingColor(ox, oy, IJ.altKeyDown()); break; case Toolbar.WAND: Roi roi = imp.getRoi(); if (roi != null && roi.contains(ox, oy)) { Rectangle r = roi.getBounds(); if (r.width == imageWidth && r.height == imageHeight) imp.killRoi(); else if (!e.isAltDown()) { handleRoiMouseDown(e); return; } } if (roi != null) { int handle = roi.isHandle(x, y); if (handle >= 0) { roi.mouseDownInHandle(handle, x, y); return; } } setRoiModState(e, roi, -1); String mode = WandToolOptions.getMode(); double tolerance = WandToolOptions.getTolerance(); int npoints = IJ.doWand(ox, oy, tolerance, mode); if (Recorder.record && npoints > 0) { if (tolerance == 0.0 && mode.equals("Legacy")) Recorder.record("doWand", ox, oy); else Recorder.recordString( "doWand(" + ox + ", " + oy + ", " + tolerance + ", \"" + mode + "\");\n"); } break; case Toolbar.OVAL: if (Toolbar.getBrushSize() > 0) new RoiBrush(); else handleRoiMouseDown(e); break; case Toolbar.SPARE1: case Toolbar.SPARE2: case Toolbar.SPARE3: case Toolbar.SPARE4: case Toolbar.SPARE5: case Toolbar.SPARE6: case Toolbar.SPARE7: case Toolbar.SPARE8: case Toolbar.SPARE9: Toolbar.getInstance().runMacroTool(toolID); break; default: // selection tool handleRoiMouseDown(e); } }