MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / mouseWheelMoved

Method mouseWheelMoved

ij/src/main/java/ij/gui/PlotWindow.java:678–706  ·  view source on GitHub ↗

Mouse wheel: zooms when shift or ctrl is pressed, scrolls in x if space bar down, in y otherwise.

(MouseWheelEvent e)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 14

getGuiScaleMethod · 0.95
shiftKeyDownMethod · 0.95
spaceBarDownMethod · 0.95
isAijPlotMethod · 0.80
getModifiersMethod · 0.80
getXMethod · 0.65
getYMethod · 0.65
isFrozenMethod · 0.45
getCursorLocMethod · 0.45
screenXMethod · 0.45
screenYMethod · 0.45
zoomMethod · 0.45

Tested by

no test coverage detected