Re: plot window bug

Posted by Fred Damen on
URL: http://imagej.273.s1.nabble.com/plot-window-bug-tp5022945p5022952.html

Greetings Philippe,

Given the fact that this bug seems to have mysteriously started to happen,
and the comment about a timing issue in the source for
PlotWindow.windowActivated, I suspect that there is a some sort of a race
condition going on. My plugin ran did not have the aformetioned plotwindow
problem for the past year or two on linux and windows. I ran into this
same problem ages ago on the Mac and was told there was no known solution.
 Since I found a partial solution, I thought I would share, in case
someone else runs into the same issue.

There also seems to be a race condition with zooming an imagewindow.  The
OS/windowmanager window generally results in the correct size, although,
sometimes/often the image in this window was left in a partially zoomed
state.  Calling imp.getWindow().getCanvas().fitToWindow(); after xooming
seems to get the zoom to complete consistently.

And the imp.getWindow().getSize(); sometimes returns a width that is a few
pixels to wide.

Fred


On Fri, February 14, 2020 10:57 am, CARL Philippe (LBP) wrote:

> Dear Fred,
> I tried to reproduce your bug without any success with the following small
> plugin which is working as expected:
>
> import ij.*;
> import ij.process.*;
> import ij.gui.*;
> import java.awt.*;
> import ij.plugin.*;
> import ij.plugin.frame.*;
>
> public class My_Plot implements PlugIn {
>
> public void run(String arg) {
> Plot plot = new Plot("title","X","Y");
> plot.setSize(600, 300);
> PlotWindow plotwindow = plot.show();
> // The plot is not the write size or scale
> /*
> plotwindow.setSize(600,300);
> Dimension pwDim = plotwindow.getSize();
> plotwindow.setLocation(20,20);
> plotwindow.windowActivated(null);
> plotwindow.drawPlot(plot);
> // window size seems to be the smallest allowed, albeit the scale seem
> to be 1
> plotwindow.drawPlot(plot);
> // windowsize is as requested, although...
> // plotwindow2.setLocation(sx+pwDim.width,sy); // overlaps, is short in
> x by 10 pixels
> // plotwindow2.setLocation(sx,sy+pwDim.height); // overlays, is short in
> y by 100 pixels
> // works for ImageWindow(s)
> */
> }
> }
>
> My best regards,
> Philippe
>
> Philippe CARL
> Laboratoire de Bioimagerie et Pathologies
> UMR 7021 CNRS - Université de Strasbourg
> Faculté de Pharmacie
> 74 route du Rhin
> 67401 ILLKIRCH
> Tel : +33(0)3 68 85 42 89
>
> ----- Le 14 Fév 20, à 6:23, Fred Damen [hidden email] a écrit :
>
> Greetings,
>
> One of the plugins that I am developing, that plots several plots of
> requested size and location, all of a sudden decided to start ignoring the
> requested plot size plot.setSize(xl,yl); and decided to scale the plot
> inappropriately. To my knowledge I did not change anything with the
> plotting, or, X windows / Gnome (Fedora 31) or up/down grade ImageJ
> (currently 1.52r).  The symptoms seem to be the same as I mentioned about
> ages ago on MacOS. The PlotWindow will seem to size itself correctly, on
> the next plotwindow.drawPlot(plot) after resizeing the window using the
> mouse; frustrating to say the least.
>
> A partial work around is to set the size of the plotwindow instead and
> call plotwindow.windowactivated.  Then the second time you do the
> plotwindow.drawplot(plot) the plotwindows will be the requested size and a
> scale of 1.  Although the plotwindow.getSize() and the actual size of the
> gnome adorned window are not the same; whereas the
> imp.getWindow().getSize() is the size of the gnome adorned window. (Useful
> if you want to layout the windows on the screen in a matrix type fashion)
>
> not the exact code, but is easy to understand then my prose ...
>
> Plot plot = new Plot("title","X","Y");
> plot.setSize(600, 300);
> PlotWindow plotwindow = plot.show();
> // The plot is not the write size or scale
> plot.window.setSize(600,300);
> Dimension pwDim = plotwindow.getSize();
> plotwindow.setLocation(sx,sy);
> plotwindow.windowActivated(null);
> plotwindow.drawPlot(plot);
> // window size seems to be the smallest allowed, albeit the scale seem to
> be 1
> plotwindow.drawPlot(plot);
> // windowsize is as requested, although...
> // plotwindow2.setLocation(sx+pwDim.width,sy); // overlaps, is short in x
> by 10 pixels
> // plotwindow2.setLocation(sx,sy+pwDim.height); // overlays, is short in y
> by 100 pixels
> // works for ImageWindow(s)
>
> Fred
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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