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)
| 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, |
no test coverage detected