Greetings Wayne,
I have been unable to produce a minimal plugin. As this appears to be
caused by a race condition issue, I assume even if I got one working on my
machine it would not produces the same results on yours. Nonetheless...
I have attached the method in my plugin that is in question below. I have
added IJ.log statements and added / removed statements to debug this
issue, and here is what I found.
a) When the windows do not show, and after the plugin in question has
finished running, the window size(width,height) is either 0,0 or 1,1. and
the ImageCanvas.isValid() == true. Zoom.in and Image/Zoom/View 100% seem
to make the ImageWindow visible again. Other Zoom related operation do
not.
b) The window sizes that are logged while this method is running is not
always consistent with what you would expect after the Zoom.set or after
the plugin has finished, albeit if any of the logged window sizes are 0,0
or 1,1, and ImageCanvas.isValid() == false, then resulting window is
either 0,0 or 1,1, respectively.
c) IJ.wait(1000); after imp.show(); always produces the intended output.
d) Commenting out Zoom.set(imp,n); always produces the windows at 100%.
e) imp.waitTillActivated(); after show does not cause intended display of
the windows. imp.isActivated() method would be nice. imp.showZoomed(n) and
showAt(x,y) and showZoomedAt(n,x,y) are on my which list...
f) commenting out the ImageWindow.setNextLocation or imp.setLocation does
not seem to change/improve the resulting displayed window sizes.
g) N.B., The ImagePlus code I perused was not the latest, albeit...
ImagePlus.show() only seems to wait for activated ImageWindow when
IJ.isMacro() is true. This may be one of the root causes for the race
condition that I am experiencing. I would expect that imp.show() should
also wait for plugins.
h) ImageCanvas super class Component.isValid() documentation says it
indicated the correctness of the component's size. I suspect that this has
something to do with the somewhat random setting of the canvas/window
size(s). Although, sometimes the canvas says invalid but the sizes look
correct.
Thanks for listening,
Fred
private void show(ImagePlus imp, String title, double drmin, double
drmax, int x, int y) {
IJ.log("title="+imp.getTitle());
if (imp == null) return;
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();
//IJ.wait(1000);
IJ.log("ic="+imp.getCanvas()+" mag="+imp.getCanvas().getMagnification()+"
ws="+ws+" WS= "+imp.getWindow().getSize());
//IJ.log(title+" "+(imp.getWindow().isValid()?"is Valid":"is NOT
valid"));
//if (magnification != 100.0f) IJ.run(imp,"Set...
","zoom="+magnification);
// if (magnification != 100.0f)
Zoom.set(imp, magnification/100f);
IJ.log("ic="+imp.getCanvas()+" Mag="+imp.getCanvas().getMagnification()+"
ws="+ws+" WS= "+imp.getWindow().getSize());
if (ws == null) {
ws = imp.getWindow().getSize();
if (loc != null)
imp.getWindow().setLocation(loc.x+x*ws.width,loc.y+y*ws.height);
}
IJ.log("ic="+imp.getCanvas()+" MAG="+imp.getCanvas().getMagnification()+"
ws="+ws+" WS="+imp.getWindow().getSize());
}
title=fssfpDIFF_21454301.img
ic=ij.gui.ImageCanvas[canvas82,10,49,128x128] mag=1.0 ws=null WS=
java.awt.Dimension[width=148,height=216]
ic=ij.gui.ImageCanvas[canvas82,5,26,-36x-228,invalid] Mag=4.0 ws=null WS=
java.awt.Dimension[width=0,height=0]
ic=ij.gui.ImageCanvas[canvas82,5,26,-36x-228,invalid] MAG=4.0
ws=java.awt.Dimension[width=0,height=0]
WS=java.awt.Dimension[width=138,height=186]
title=fssfpDIFF_21454301_iphs.img
ic=ij.gui.ImageCanvas[canvas83,10,49,128x128] mag=1.0
ws=java.awt.Dimension[width=0,height=0] WS=
java.awt.Dimension[width=148,height=216]
ic=ij.gui.ImageCanvas[canvas83,5,26,-36x-228,invalid] Mag=4.0
ws=java.awt.Dimension[width=0,height=0] WS=
java.awt.Dimension[width=0,height=0]
ic=ij.gui.ImageCanvas[canvas83,5,26,-10x-58] MAG=4.0
ws=java.awt.Dimension[width=0,height=0]
WS=java.awt.Dimension[width=0,height=0]
On Thu, May 30, 2024 9:34 am, Wayne Rasband wrote:
>> On May 29, 2024, at 10:06â¯PM, Fred Damen <[email protected]> wrote:
>>
>> Greetings,
>>
>> I recently upgraded the OS and ImageJ, so now I seem to have a race
>> condition.
>
> Hi Fred,
>
> Please provide a minimal plugin that reproduces this problem.
>
> -wayne
>
>> I open several images from a plugin and resize the imagewindow
>> immediately.
>> essentially but not really
>> for(...) {
>> ImagePlus imp = create();
>> imp.show();
>> Zoom.set(imp,n);
>> }
>>
>> Usually one of the images shows and the rest can not be shown, that is,
>> selecting the imagewindow from the Window menu or through the OS window
>> manager the imagewindow is not shown. Most manipulation of the window
>> size
>> does not seem to work. Image/Zoom/View 100% will show the window and any
>> further change to the window size occurs as expected. Placing a
>> IJ.wait(1000) between show and zoom above causes the windows to appear
>> as
>> expected.
>>
>> I ran the plugin in question with n set to 1 and the one of the
>> imagewindow(s) appeared at the appropriate window size but with out an
>> image displayed within it. Image/Show info... shows
>> Magnification: -9.00
>>
>> Is there a way to set the initial zoom so that the show displays the
>> imagewindow at this initial zoom level?
>>
>> Thanks for listening,
>>
>> Fred
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html