Overlay drawLine problem

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

Overlay drawLine problem

Stein Rørvik
I want to draw some individual overlay objects per slice on a stack.
There is a problem (bug) involving Overlay.drawLine and Overlay.lineTo.
See the below example macro.

The overlay lines end up global instead of per slice, and the color is not correct.
This bug does not seem to apply to the other Overlay.draw* commands.

As a workaround, if you insert an extra Overlay.show immediately after the respective calls to Overlay.lineTo and Overlay.drawLine, it behaves correctly (uncomment to test this).

Demo macro:
------------------------------
newImage("temp", "RGB black", 200, 200, 4);
x = 100;
y = 100;
run("Set... ", "zoom=200 x=100 y=100");
for (i=1; i <= 4; i++) {
                setSlice(i);
                setColor("cyan");
                Overlay.drawString(i, x, y);
                Overlay.setPosition(i);
                setColor("blue");
                Overlay.drawEllipse(x-40,y-i*10+10, 20, 20)
                Overlay.setPosition(i);
                setColor("green");
                Overlay.drawRect(x-50,y-i*10,40,40);
                Overlay.setPosition(i);
                setColor("orange");
                Overlay.moveTo(x+10,y+i*10);
                Overlay.lineTo(x+20,y+i*10);
                //Overlay.show;              //works correctly if this is called here
                Overlay.setPosition(i);
                setColor("red");
                Overlay.drawLine(x+30,y+i*10,x+50,y+i*10);
                //Overlay.show;              //works correctly if this is called here
                Overlay.setPosition(i);
}
Overlay.show
------------------------------

I am using daily build ImageJ 1.52p with Java 1.8 on Windows 7/64-bit.

Stein


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

Re: Overlay drawLine problem

Wayne Rasband-2
> On Jun 3, 2019, at 8:25 AM, Stein Rørvik <[hidden email]> wrote:
>
> I want to draw some individual overlay objects per slice on a stack.
> There is a problem (bug) involving Overlay.drawLine and Overlay.lineTo.
> See the below example macro.

This bug is fixed in the latest daily build (1.52p41).

-wayne

> The overlay lines end up global instead of per slice, and the color is not correct.
> This bug does not seem to apply to the other Overlay.draw* commands.
>
> As a workaround, if you insert an extra Overlay.show immediately after the respective calls to Overlay.lineTo and Overlay.drawLine, it behaves correctly (uncomment to test this).
>
> Demo macro:
> ------------------------------
> newImage("temp", "RGB black", 200, 200, 4);
> x = 100;
> y = 100;
> run("Set... ", "zoom=200 x=100 y=100");
> for (i=1; i <= 4; i++) {
>                setSlice(i);
>                setColor("cyan");
>                Overlay.drawString(i, x, y);
>                Overlay.setPosition(i);
>                setColor("blue");
>                Overlay.drawEllipse(x-40,y-i*10+10, 20, 20)
>                Overlay.setPosition(i);
>                setColor("green");
>                Overlay.drawRect(x-50,y-i*10,40,40);
>                Overlay.setPosition(i);
>                setColor("orange");
>                Overlay.moveTo(x+10,y+i*10);
>                Overlay.lineTo(x+20,y+i*10);
>                //Overlay.show;              //works correctly if this is called here
>                Overlay.setPosition(i);
>                setColor("red");
>                Overlay.drawLine(x+30,y+i*10,x+50,y+i*10);
>                //Overlay.show;              //works correctly if this is called here
>                Overlay.setPosition(i);
> }
> Overlay.show
> ------------------------------
>
> I am using daily build ImageJ 1.52p with Java 1.8 on Windows 7/64-bit.
>
> Stein

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