Exemplo n.º 1
0
 protected Dimension canEnlarge(int newWidth, int newHeight) {
   // if ((flags&Event.CTRL_MASK)!=0 || IJ.controlKeyDown()) return null;
   ImageWindow win = imp.getWindow();
   if (win == null) return null;
   Rectangle r1 = win.getBounds();
   Insets insets = win.getInsets();
   Point loc = getLocation();
   if (loc.x > insets.left + 5 || loc.y > insets.top + 5) {
     r1.width = newWidth + insets.left + insets.right + 10;
     r1.height = newHeight + insets.top + insets.bottom + 10;
     if (win instanceof StackWindow) r1.height += 20;
   } else {
     r1.width = r1.width - dstWidth + newWidth + 10;
     r1.height = r1.height - dstHeight + newHeight + 10;
   }
   Rectangle max = win.getMaxWindow(r1.x, r1.y);
   boolean fitsHorizontally = r1.x + r1.width < max.x + max.width;
   boolean fitsVertically = r1.y + r1.height < max.y + max.height;
   if (fitsHorizontally && fitsVertically) return new Dimension(newWidth, newHeight);
   else if (fitsVertically && newHeight < dstWidth) return new Dimension(dstWidth, newHeight);
   else if (fitsHorizontally && newWidth < dstHeight) return new Dimension(newWidth, dstHeight);
   else return null;
 }