Posted by
Michael Schmid on
URL: http://imagej.273.s1.nabble.com/Programatic-Java-zooming-issue-s-tp5024578p5024584.html
Hi Fred,
at least with JavaScript, there is no such problem on my Linux machine
(which is usually susceptible to race conditions). It makes no
difference whether a CPU-demanding operation runs in the background or not.
Here is my JavaScript test:
imp = IJ.openImage("
https://imagej.net/images/t1-rendering.zip");
imp = imp.crop("1-9");
imp.show();
IJ.run("Stack to Images", "");
//Thread.sleep(1000); //works with and without this
for (i=1; i<10;i++) {
IJ.selectWindow("DUP_t1-rendering-000"+i);
IJ.run("In [+]", "");
// IJ.run("Set... ", "zoom=200"); //alternatively
}
One can even see that the display of the images is asynchronous: Some
images get zoomed while they are in the background.
ImageJ 1.53i28; Java 1.8.0_112 [64-bit]; Linux 4.4.0-206-generic; 53MB
of 10000MB (<1%)
Michael
________________________________________________________________
On 01.04.21 04:09, Fred Damen wrote:
> Greetings,
>
> Resizing image windows thru the GUI seems to always work as expected.
> Resizing the windows from within a Java plugin seem to work undesirably
> about 40% of the time. The undesirable effects tend to be consistent,
> e.g., the second,third, and fifth windows exhibit the same effect each
> time the plugin is run. I suspect that the issue is some sort of a race
> condition between ImageJ and Java/System GUI proper, as the symptoms vary
> somewhat with load and computer.
>
> The symptoms include:
> Window has slightly wrong size and image appears to be the correct
> magnification.
> Window has correct size and the image is original size.
>
> Both these statements produce these results:
> IJ.run("In [+]", "");
> IJ.run("Set... ", "zoom=200");
>
> I have found that after show(ing) all the windows if I ...
> Dimension ws = imps[0].getWindow().getSize();
> for(ImagePlus imp : imps)
> imp.getWindow().setSize(ws.width,ws.height);
> for(ImagePlus imp : imps)
> imp.getWindow().getCanvas().fitToWindow();
> This seems to adjust the window and image sizes appropriately most of the
> time.
>
> Is there a recommended way to zoom a window programmatically that works
> consistently and correctly like it does from Image>Zoom>... ?
>
> Thanks in advance,
>
> Fred
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html