timing of image drawing

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

timing of image drawing

Robert Dougherty
I'm having trouble with a plugin that repeatedly updates some drawing that
I'm adding to an image.  For each update, I call imp.draw(); to erase the
old version of my added artwork, and then I recreate the artwork.  The
problem seems to be that imp.draw(), which ultimately calls repaint() for
the image canvas, seems to run asynchronously.  That is, imp.draw() launches
a repaint process that goes on its way, my plugin redraws the artwork, and
then the still-running imp.draw() erases part of it.  This creates an
annoying flicker effect on some computers.  Sun's API suggests that Swing
has double buffering, which might be related, but it seems like overkill.
Is there an easy way to redraw the graphics from the image data that is
blocking?  I think this issue has come up before, but I was not able to find
it in the archives.

 

imp.draw();

for (int j = 0; j < rows; j++){

            for (int i = 0; i < columns; i++){

                        int ind = i + columns*j;

                        int diam = (int)(ic.getMagnification()*diameter);

 
g.drawOval(ic.screenX(x[ind]),ic.screenX(y[ind]),diam,diam);

}

}

 

Bob

 

Robert P. Dougherty, Ph.D.
President, OptiNav, Inc.
[hidden email]
(425) 467-1118

 
Reply | Threaded
Open this post in threaded view
|

Re: timing of image drawing

Wayne Rasband
The Graphic_Overlay plugin at

    http://rsb.info.nih.gov/ij/plugins/graphic-overlay.html

demonstrates how to add a nondestructive graphics overly to an image or
stack.

-wayne

On Dec 7, 2005, at 1:52 PM, Robert Dougherty wrote:

> I'm having trouble with a plugin that repeatedly updates
> some drawing that I'm adding to an image.? For each update,
> I call imp.draw(); to erase the old version of my added
> artwork, and then I recreate the artwork.? The problem seems
> to be that imp.draw(), which ultimately calls repaint() for
> the image canvas, seems to run asynchronously.? That is,
> imp.draw() launches a repaint process that goes on its way,
> my plugin redraws the artwork, and then the still-running
> imp.draw() erases part of it.? This creates an annoying
> flicker effect on some computers.? Sun's API suggests that
> Swing has double buffering, which might be related, but it
> seems like overkill. Is there an easy way to redraw the
> graphics from the image data that is blocking?? I think this
> issue has come up before, but I was not able to find it in
> the archives.
> ?
> imp.draw();
>
> for (int j = 0; j < rows; j++){
>
> ??????????? for (int i = 0; i < columns; i++){
>
> ??????????????????????? int ind = i + columns*j;
>
> ??????????????????????? int diam =
> (int)(ic.getMagnification()*diameter);
>
> ?
> g.drawOval(ic.screenX(x[ind]),ic.screenX(y[ind]),diam,diam);
>
> }
>
> }