public void fitToWindow() {
ImageWindow win = imp.getWindow();
if (win==null) return;
Rectangle bounds = win.getBounds();
Insets insets = win.getInsets();
<BUG>int sliderHeight = (win instanceof StackWindow)?20:0;
double xmag = (double)(bounds.width-10)/srcRect.width;
double ymag = (double)(bounds.height-(10+insets.top+sliderHeight))/srcRect.height;
</BUG>
setMagnification(Math.min(xmag, ymag));

public void fitToWindow() {
ImageWindow win = imp.getWindow();
if (win==null) return;
Rectangle bounds = win.getBounds();
Insets insets = win.getInsets();
int sliderHeight = win.getSliderHeight();
double xmag = (double)(bounds.width-(insets.left+insets.right+ImageWindow.HGAP*2))/srcRect.width;
double ymag = (double)(bounds.height-(ImageWindow.VGAP*2+insets.top+insets.bottom+sliderHeight))/srcRect.height;
setMagnification(Math.min(xmag, ymag));
