Greetings Kenneth,
There is a special case with ImagePlus.show. I tend to present my
ImagePlus results in a matrix format on the screen, which requires the
ImageWindow and ImageCanvas to show as requested. It seems as though the
last time I brought this up, the ImageWindow shows up the right size, but
the ImageCanvas sometimes does not, thus I think of this as a race
condition. The fix for this is in the attached code between "Fix
ImageCanavas". It at most takes a few iterations to have a correct
ImageCanvas.
Enjoy,
Fred
private void show(ImagePlus imp, String title, double drmin, double
drmax, int x, int y) {
if (imp == null) return;
if (loc != null) ImageWindow.setNextLocation(loc.x,loc.y);
if (loc != null && ws != null)
ImageWindow.setNextLocation(loc.x+x*ws.width,loc.y+y*ws.height);
if (title != null) imp.setTitle(title);
if (!Double.isNaN(drmin) && !Double.isNaN(drmax))
imp.setDisplayRange(drmin,drmax);
imp.show();
imp.waitTillActivated();
{ // Fix ImageCanvas
ImageWindow win = imp.getWindow();
ImageCanvas ic = win.getCanvas();
for(int i=0; i<100; i++)
if (ic.isValid()) break;
else { IJ.log("C"+i); IJ.wait(10); }
for(int i=0; i<100; i++)
if (ic.getWidth() != imp.getWidth() || ic.getHeight() !=
imp.getHeight()) {
//IJ.log("ic("+ic.getWidth()+","+ic.getHeight()+")
imp("+imp.getWidth()+","+imp.getHeight()+")");
IJ.wait(1); ic.zoom100Percent(); IJ.wait(1);
}
} // Fix ImageCanvas
Zoom.set(imp, magnification/100f);
if (ws == null) {
ws = imp.getWindow().getSize();
if (loc != null)
imp.getWindow().setLocation(loc.x+x*ws.width,loc.y+y*ws.height);
}
}
On Wed, January 22, 2025 1:00 pm, Kenneth R Sloan wrote:
> Iâm not so much worried about user-generated events - Iâm more
> concerned
> about operations invoked by my Java code. Any operation which is handled
> asynchronously needs some way of determining (assuring?) that it has
> completed.
>
> You have noted two ways that can happen: either the operation is
> inherently
> asynchronous (such as show()), or the operation itself is open ended until
> the user is done providing input (paste()). Are there others?
>
> Show() has waitTilActivated. Paste() has EndPaste(). What about others
> (if there are any).
>
> â-
> Kenneth Sloan
> (von meinem iPhone13 gesendet)
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html