Screen update in Java 8 and MacOS: no double-buffering?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Screen update in Java 8 and MacOS: no double-buffering?

vischer
Hello,
in the past, we successfully could use a "moving roi" that followed the cursor until the mouse is clicked.
In combination with a complex overlay, this is not feasible anymore with Java 8 on MacOS because the update mechanism is different.  

Years ago, a similar problem on Windows could be solved by switching "double-buffering" on.
Meanwhile, Windows 7 + Java 8 behaves well, but OS X + Java 8 doesn't.

To illustrate my problem, run the macro below that first creates an image with a complex overlay pattern. Then, without clicking the mouse, move the cursor across the image and see how the circular roi is periodically repainted while the mouse is moved. Press left button to stop.
With Java 8, the screen flickers. This happens because:
a) the entire screen is updated, not only the old and then the new bounding rectangle, and
b) double-buffering appears to be off.

On the other hand, when dragging the roi manually rather than by macro, the screen remains more quiet, because only the relevant parts of the image are updated.

My Questions:
-------------
a) Can we tell Java 8 on OS X to provide the same type of double-buffering as Java 6?

b) If this is not the possible, would it be difficult to apply more intelligent updating for
   creating or moving a roi by macro?

Norbert



//-----------macro begin
if(isOpen("a_b_c"))
        selectImage("a_b_c");
else{
        numPoints = 5000;
        xx = newArray(numPoints);
        yy = newArray(numPoints);
        newImage("a_b_c", "16-bit black", 1200, 800, 1);
        for(jj = 0; jj < numPoints; jj++){
                xx[jj] = getWidth*random;
                yy[jj] = getHeight*random;
        }
        makeSelection("Point", xx, yy);
        run("Properties... ", "point=Circle  stroke=blue size=Medium");
        run("Add Selection...");
}
makeOval(0, 0, 50, 50);
run("Properties... ", "stroke=yellow width=2 fill=none");
leftButton=16;
done = false;
x2=-1; y2=-1; z2=-1; flags2=-1;
while (!done) {
        getCursorLoc(x, y, z, flags);
        if (x!=x2 || y!=y2) {
          x2 = x;
          y2 = y;
          Roi.move(x-25, y-25);
        }
        done = (flags&leftButton!=0);
        wait(10);
}
       
//-----------macro end

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

Re: Screen update in Java 8 and MacOS: no double-buffering?

Wayne Rasband-2
> On May 29, 2017, at 4:52 PM, Norbert Vischer <[hidden email]> wrote:
>
> Hello,
> in the past, we successfully could use a "moving roi" that followed the cursor until the mouse is clicked.
> In combination with a complex overlay, this is not feasible anymore with Java 8 on MacOS because the update mechanism is different.  
>
> Years ago, a similar problem on Windows could be solved by switching "double-buffering" on.
> Meanwhile, Windows 7 + Java 8 behaves well, but OS X + Java 8 doesn't.
>
> To illustrate my problem, run the macro below that first creates an image with a complex overlay pattern. Then, without clicking the mouse, move the cursor across the image and see how the circular roi is periodically repainted while the mouse is moved. Press left button to stop.
> With Java 8, the screen flickers. This happens because:
> a) the entire screen is updated, not only the old and then the new bounding rectangle, and
> b) double-buffering appears to be off.

Hi Norbert,

The latest ImageJ daily build (1.51o30) uses double buffering on Mac OS X, which seems to solve the problem illustrated by your test macro. Thanks for bringing this problem to my attention and for providing the helpful test macro that reproduces it.

-wayne


> On the other hand, when dragging the roi manually rather than by macro, the screen remains more quiet, because only the relevant parts of the image are updated.
>
> My Questions:
> -------------
> a) Can we tell Java 8 on OS X to provide the same type of double-buffering as Java 6?
>
> b) If this is not the possible, would it be difficult to apply more intelligent updating for
>   creating or moving a roi by macro?
>
> Norbert
>
>
>
> //-----------macro begin
> if(isOpen("a_b_c"))
> selectImage("a_b_c");
> else{
> numPoints = 5000;
> xx = newArray(numPoints);
> yy = newArray(numPoints);
> newImage("a_b_c", "16-bit black", 1200, 800, 1);
> for(jj = 0; jj < numPoints; jj++){
> xx[jj] = getWidth*random;
> yy[jj] = getHeight*random;
> }
> makeSelection("Point", xx, yy);
> run("Properties... ", "point=Circle  stroke=blue size=Medium");
> run("Add Selection...");
> }
> makeOval(0, 0, 50, 50);
> run("Properties... ", "stroke=yellow width=2 fill=none");
> leftButton=16;
> done = false;
> x2=-1; y2=-1; z2=-1; flags2=-1;
> while (!done) {
> getCursorLoc(x, y, z, flags);
> if (x!=x2 || y!=y2) {
>  x2 = x;
>  y2 = y;
>  Roi.move(x-25, y-25);
> }
> done = (flags&leftButton!=0);
> wait(10);
> }
>
> //-----------macro end
>

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

Re: Screen update in Java 8 and MacOS: no double-buffering?

vischer
Thank you Wayne for solving this problem so fast!

Best regards, Norbert

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