Mouse wheel: zooms when shift or ctrl is pressed, scrolls in x if space bar down, in y otherwise.
(MouseWheelEvent e)
| 676 | |
| 677 | /** Mouse wheel: zooms when shift or ctrl is pressed, scrolls in x if space bar down, in y otherwise. */ |
| 678 | @AstroImageJ(reason = "Support scaled plots", modified = true) |
| 679 | public synchronized void mouseWheelMoved(MouseWheelEvent e) { |
| 680 | if (plot.isFrozen() || !(ic instanceof PlotCanvas)) { //frozen plots are like normal images |
| 681 | super.mouseWheelMoved(e); |
| 682 | return; |
| 683 | } |
| 684 | int rotation = e.getWheelRotation(); |
| 685 | int amount = e.getScrollAmount(); |
| 686 | var xBound = plot.frameWidth * (plot.isAijPlot() ? Prefs.getGuiScale() : 1.0); |
| 687 | var yBound = plot.frameHeight * (plot.isAijPlot() ? Prefs.getGuiScale() : 1.0); |
| 688 | if (e.getX() < plot.leftMargin || e.getX() > plot.leftMargin + xBound)//n__ |
| 689 | return; |
| 690 | if (e.getY() < plot.topMargin || e.getY() > plot.topMargin + yBound) |
| 691 | return; |
| 692 | boolean ctrl = (e.getModifiers()&Event.CTRL_MASK)!=0; |
| 693 | if (amount<1) amount=1; |
| 694 | if (rotation==0) |
| 695 | return; |
| 696 | if (ctrl||IJ.shiftKeyDown()) { |
| 697 | double zoomFactor = rotation<0 ? Math.pow(2, 0.2) : Math.pow(0.5, 0.2); |
| 698 | Point loc = ic.getCursorLoc(); |
| 699 | int x = ic.screenX(loc.x); |
| 700 | int y = ic.screenY(loc.y); |
| 701 | ((PlotCanvas)ic).zoom(x, y, zoomFactor); |
| 702 | } else if (IJ.spaceBarDown()) |
| 703 | plot.scroll(rotation*amount*Math.max(ic.imageWidth/50, 1), 0); |
| 704 | else |
| 705 | plot.scroll(0, rotation*amount*Math.max(ic.imageHeight/50, 1)); |
| 706 | } |
| 707 | |
| 708 | /** |
| 709 | * Creates an overlay with triangular buttons and othr symbols for changing the axis range |
nothing calls this directly
no test coverage detected