Login  Register

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

Posted by vischer on May 29, 2017; 8:52pm
URL: http://imagej.273.s1.nabble.com/Screen-update-in-Java-8-and-MacOS-no-double-buffering-tp5018800.html

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