Re: Programatic(Java) zooming issue(s)

Posted by JAMES, gregory (SANDWELL AND WEST BIRMINGHAM HOSPITALS NHS TRUST) on
URL: http://imagej.273.s1.nabble.com/Programatic-Java-zooming-issue-s-tp5024578p5024590.html

Hello ImageJ-ers.

I was pleased to read Fred's post about the zooming issue. I too encounter this problem quite regularly in the macro language. I was going to ask the community for help, but Fred beat me to it. (Thanks Fred).

As Fred says... The behaviour is seemingly random. Furthermore, it happens often with some of my macro scripts and never happens with other scripts. I can't see an obvious reason for the difference but it's *possible​* that having a line of code before the 'zoom' command helps. For example, the following code sometimes produces the zooming error...

selectWindow(title);
run("Set... ", "zoom=400");

I do not observe the zooming error in the following code...

selectWindow(title);
Matrix = getHeight();
run("Set... ", "zoom=400");

I would like to understand the problem better. It's also possible that I'm talking rubbish and I'm completely wrong about the 'fix'. I wonder if certain combinations of code are more likely to produce the error?

I'm keen to hear from more users to see if they are encountering similar issues and how they have fixed them... Or is it just me and Fred encountering the problem?

Greg.

__________________________________________
Gregory James
Clinical Scientist (Nuclear Medicine)
Department of Physics and Nuclear Medicine
City Hospital
Dudley Road
Birmingham
B18 7QH

0121 507 4043

________________________________
From: Herbie <[hidden email]>
Sent: 01 April 2021 08:53
To: [hidden email] <[hidden email]>
Subject: Re: Programatic(Java) zooming issue(s)

Dear Fred,

since long I successfully use

if ( imp.getRoi() != null )
   new Zoom().run( "to" );

and have never ever encountered any of the described effects.

Regards

Herbie

::::::::::::::::::::::::::::::::::::::::
Am 01.04.21 um 04:09 schrieb Fred Damen:

> 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



This message originated from outside of NHSmail. Please do not click links or open attachments unless you recognise the sender and know the content is safe.


********************************************************************************************************************

This message may contain confidential information. If you are not the intended recipient please inform the
sender that you have received the message in error before deleting it.
Please do not disclose, copy or distribute information in this e-mail or take any action in relation to its contents. To do so is strictly prohibited and may be unlawful. Thank you for your co-operation.

NHSmail is the secure email and directory service available for all NHS staff in England and Scotland. NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and other accredited email services.

For more information and to find out how you can switch, https://portal.nhs.net/help/joiningnhsmail


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html