/** Resizes the canvas when the user resizes the window. To avoid a race condition while creating * a new window, this is ignored if no window exists or the window has not been activated yet. */ void resizeCanvas(int width, int height) { if (plot == null || plot.isFrozen()) { super.resizeCanvas(width, height); return; } resetMagnification(); if (width == oldWidth && height == oldHeight) return; if (plot == null) return; ImageWindow win = imp.getWindow(); if (win==null || !(win instanceof PlotWindow)) return; if (!win.isVisible()) return; if (!((PlotWindow)win).wasActivated) return; // window layout not finished yet? Dimension minSize = plot.getMinimumSize(); int plotWidth = width < minSize.width ? minSize.width : width; int plotHeight = height < minSize.height ? minSize.height : height; plot.setSize(plotWidth, plotHeight); setSize(width, height); oldWidth = width; oldHeight = height; }
/** Resizes the canvas when the user resizes the window. To avoid a race condition while creating * a new window, this is ignored if no window exists or the window has not been activated yet. */ void resizeCanvas(int width, int height) { if (plot == null || plot.isFrozen()) { super.resizeCanvas(width, height); return; } resetMagnification(); if (width == oldWidth && height == oldHeight) return; if (plot == null) return; ImageWindow win = imp.getWindow(); if (win==null || !(win instanceof PlotWindow)) return; if (!win.isVisible()) return; if (!((PlotWindow)win).wasActivated) return; // window layout not finished yet? Dimension minSize = plot.getMinimumSize(); int plotWidth = width < minSize.width ? minSize.width : width; int plotHeight = height < minSize.height ? minSize.height : height; plot.setSize(plotWidth, plotHeight); setSize(width, height); oldWidth = width; oldHeight = height; }