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

Method zoomIn

ij/src/main/java/ij/gui/ImageCanvas.java:892–920  ·  view source on GitHub ↗

Zooms in by making the window bigger. If it can't be made bigger, then makes the source rectangle (srcRect) smaller and centers it on the position in the image where the cursor was when zooming has started. Note that sx and sy are screen coordinates.

(int sx, int sy)

Source from the content-addressed store, hash-verified

890 image where the cursor was when zooming has started.
891 Note that sx and sy are screen coordinates. */
892 @AstroImageJ(reason = "increase zoom levels to 128 from 32", modified = true)
893 public void zoomIn(int sx, int sy) {
894 if (magnification>=128) return;
895 scaleToFit = false;
896 boolean mouseMoved = sqr(sx-lastZoomSX) + sqr(sy-lastZoomSY) > MAX_MOUSEMOVE_ZOOM*MAX_MOUSEMOVE_ZOOM;
897 lastZoomSX = sx;
898 lastZoomSY = sy;
899 if (mouseMoved || zoomTargetOX<0) {
900 boolean cursorInside = sx >= 0 && sy >= 0 && sx < dstWidth && sy < dstHeight;
901 zoomTargetOX = offScreenX(cursorInside ? sx : dstWidth/2); //where to zoom, offscreen (image) coordinates
902 zoomTargetOY = offScreenY(cursorInside ? sy : dstHeight/2);
903 }
904 double newMag = getHigherZoomLevel(magnification);
905 int newWidth = (int)(imageWidth*newMag);
906 int newHeight = (int)(imageHeight*newMag);
907 Dimension newSize = canEnlarge(newWidth, newHeight);
908 if (newSize!=null) {
909 setSize(newSize.width, newSize.height);
910 if (newSize.width!=newWidth || newSize.height!=newHeight)
911 adjustSourceRect(newMag, zoomTargetOX, zoomTargetOY);
912 else
913 setMagnification(newMag);
914 imp.getWindow().pack();
915 } else // can't enlarge window
916 adjustSourceRect(newMag, zoomTargetOX, zoomTargetOY);
917 repaint();
918 if (srcRect.width<imageWidth || srcRect.height<imageHeight)
919 resetMaxBounds();
920 }
921
922 /** Centers the viewable area on offscreen (image) coordinates x, y */
923 void adjustSourceRect(double newMag, int x, int y) {

Callers 7

inMethod · 0.95
runMethod · 0.95
updateMagnificationMethod · 0.95
commandExecutingMethod · 0.95
commandExecutingMethod · 0.95
zoom100PercentMethod · 0.95
mousePressedMethod · 0.95

Calls 11

sqrMethod · 0.95
offScreenXMethod · 0.95
offScreenYMethod · 0.95
getHigherZoomLevelMethod · 0.95
canEnlargeMethod · 0.95
setSizeMethod · 0.95
adjustSourceRectMethod · 0.95
setMagnificationMethod · 0.95
resetMaxBoundsMethod · 0.95
getWindowMethod · 0.45
repaintMethod · 0.45

Tested by

no test coverage detected