plot window bug

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

plot window bug

Fred Damen
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
Reply | Threaded
Open this post in threaded view
|

Re: plot window bug

CARL Philippe (LBP)
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
Reply | Threaded
Open this post in threaded view
|

Re: plot window bug

Fred Damen
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
Reply | Threaded
Open this post in threaded view
|

Re: plot window bug

CARL Philippe (LBP)
Dear Peter,
I'm afraid that it is quite difficult if not to say impossible to help you on your issue if you aren't able to provide a minimal macro or plugin demonstrating it.
In the case you have "racing issues" you could try to empirically add a "IJ.wait(int msecs)" maybe in combinaison of a window checking like:
        PlotWindow plotwindow = plot.show();
        while(plotwindow == null) { IJ.wait(200); }
But I'm rather convinced that your issue has a more ad hoc solution with a provided example.
Have a nice week-end.
My best regards,
Philippe

----- Le 15 Fév 20, à 6:55, Fred Damen [hidden email] a écrit :

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

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: plot window bug

Wayne Rasband-2
In reply to this post by Fred Damen
> On Feb 14, 2020, at 12:23 AM, Fred Damen <[hidden email]> wrote:
>
> 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.

The latest ImageJ daily build (1.52u11) adds a plot.setWindowSize(width,height) method that sets the window size before the plot is displayed. It should work more reliably because it avoids potential race conditions. Here is a JavaScript example:

  plot = new Plot("title","X","Y");
  plot.setWindowSize(600, 300);
  win = plot.show();
  win.setLocation(100,100);

-wayne



> 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
Reply | Threaded
Open this post in threaded view
|

Re: plot window bug

Fred Damen
In reply to this post by CARL Philippe (LBP)
Greetings,

Sorry for the confusion.  My intention was not to request someone to debug
my issue, but to document a possible resolution to an issue that
frustrated me greatly.  If someone can actually fix this from what I
posted then that would be a bonus. I generally search the web for
solutions before asking questions / help.  The last time I ran into this
issue I could not find any information and and the response to my inquiry
was that this was a known Mac issue and there was no known solution.
Hopefully the next person who is afflicted by this has a possible solution
to try.

Given the symptoms that I faced, it worked and then it didn't, and I did
not change the code, ImageJ, or my system, it seemed silly to provide a
minimal plugin.

Enjoy,

Fred

On Sat, February 15, 2020 1:26 pm, CARL Philippe (LBP) wrote:

> Dear Peter,
> I'm afraid that it is quite difficult if not to say impossible to help you
> on your issue if you aren't able to provide a minimal macro or plugin
> demonstrating it.
> In the case you have "racing issues" you could try to empirically add a
> "IJ.wait(int msecs)" maybe in combinaison of a window checking like:
> PlotWindow plotwindow = plot.show();
> while(plotwindow == null) { IJ.wait(200); }
> But I'm rather convinced that your issue has a more ad hoc solution with a
> provided example.
> Have a nice week-end.
> My best regards,
> Philippe
>
> ----- Le 15 Fév 20, à 6:55, Fred Damen [hidden email] a écrit :
>
> 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
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: plot window bug

CARL Philippe (LBP)
Dear Fred,
You don't need to apologize at all given that this is exactly the aim of this list : we try to help each other as much as possible (through debugging, examples, recommendations,...).
Also, did you see the answer of Wayne on Friday who has probably fixed your issue though the daily build version of ImageJ.
Does his update finally fix your issue?
My best regards,
Philippe

----- Le 16 Fév 20, à 1:34, Fred Damen [hidden email] a écrit :

Greetings,

Sorry for the confusion.  My intention was not to request someone to debug
my issue, but to document a possible resolution to an issue that
frustrated me greatly.  If someone can actually fix this from what I
posted then that would be a bonus. I generally search the web for
solutions before asking questions / help.  The last time I ran into this
issue I could not find any information and and the response to my inquiry
was that this was a known Mac issue and there was no known solution.
Hopefully the next person who is afflicted by this has a possible solution
to try.

Given the symptoms that I faced, it worked and then it didn't, and I did
not change the code, ImageJ, or my system, it seemed silly to provide a
minimal plugin.

Enjoy,

Fred

On Sat, February 15, 2020 1:26 pm, CARL Philippe (LBP) wrote:

> Dear Peter,
> I'm afraid that it is quite difficult if not to say impossible to help you
> on your issue if you aren't able to provide a minimal macro or plugin
> demonstrating it.
> In the case you have "racing issues" you could try to empirically add a
> "IJ.wait(int msecs)" maybe in combinaison of a window checking like:
> PlotWindow plotwindow = plot.show();
> while(plotwindow == null) { IJ.wait(200); }
> But I'm rather convinced that your issue has a more ad hoc solution with a
> provided example.
> Have a nice week-end.
> My best regards,
> Philippe
>
> ----- Le 15 Fév 20, à 6:55, Fred Damen [hidden email] a écrit :
>
> 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
>
> --
> 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