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

Method canEnlarge

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

Returns the size to which the window can be enlarged, or null if it can't be enlarged. newWidth, newHeight is the size needed for showing the full image at the magnification needed

(int newWidth, int newHeight)

Source from the content-addressed store, hash-verified

938 * <code>newWidth, newHeight</code> is the size needed for showing the full image
939 * at the magnification needed */
940 protected Dimension canEnlarge(int newWidth, int newHeight) {
941 if (IJ.altKeyDown())
942 return null;
943 ImageWindow win = imp.getWindow();
944 if (win==null) return null;
945 Rectangle r1 = win.getBounds();
946 Insets insets = win.getInsets();
947 Point loc = getLocation();
948 if (loc.x>insets.left+5 || loc.y>insets.top+5) {
949 r1.width = newWidth+insets.left+insets.right+ImageWindow.HGAP*2;
950 r1.height = newHeight+insets.top+insets.bottom+ImageWindow.VGAP*2+win.getSliderHeight();
951 } else {
952 r1.width = r1.width - dstWidth + newWidth;
953 r1.height = r1.height - dstHeight + newHeight;
954 }
955 Rectangle max = GUI.getMaxWindowBounds(win);
956 boolean fitsHorizontally = r1.x+r1.width<max.x+max.width;
957 boolean fitsVertically = r1.y+r1.height<max.y+max.height;
958 if (fitsHorizontally && fitsVertically)
959 return new Dimension(newWidth, newHeight);
960 else if (fitsVertically && newHeight<dstWidth)
961 return new Dimension(dstWidth, newHeight);
962 else if (fitsHorizontally && newWidth<dstHeight)
963 return new Dimension(newWidth, dstHeight);
964 else
965 return null;
966 }
967
968 /**Zooms out by making the source rectangle (srcRect)
969 larger and centering it on (x,y). If we can't make it larger,

Callers 1

zoomInMethod · 0.95

Calls 7

altKeyDownMethod · 0.95
getInsetsMethod · 0.95
getSliderHeightMethod · 0.95
getMaxWindowBoundsMethod · 0.95
getLocationMethod · 0.80
getBoundsMethod · 0.65
getWindowMethod · 0.45

Tested by

no test coverage detected