Skip to main content



      Home
Home » Eclipse Projects » GEF » Cancel a time consuming paint operation
Cancel a time consuming paint operation [message #168459] Wed, 16 February 2005 03:40 Go to next message
Eclipse UserFriend
Originally posted by: kvdijken.tiscali.nl

In my application I have a zoom-to-fit-all button to zoom the viewport so
all figures will be drawn. Sometimes the dataset contains as many as
50.000 figures, which can take 10-30 seconds to be painted. I want to give
the user the option to cancel this painting operation if he presses the
zoom-to-fit-all button by accident. The way the user should do this is not
so important at this moment. I tried several ways (detailed below), but
all without satisfactory results. Does anyone have an idea to get it to
work?


Different methods I tried:

1. In paintChildren() of the layer there is a loop which iterates over all
children to be painted. For every child to be painted I use

for( ... every child to be painted ... ) {

// Paint this child
Display.getCurrent().syncExec(new Runnable() { ... paint this child ...
} );

// Give the user a chance to cancel the painting of this layer.
// Flag abort will be set when user wants to abort.
Display.getCurrent().readAndDispatch();

if(abort)
return;

}

This does work, but the call to readAndDispatch() raises problems when
panning the viewport.


2. Check the status of the ESCAPE key

for( ... every child to be painted ... ) {

// Paint this child
{ ... paint this child ... };

abort = (OS.GetKeyState(OS.VK_ESCAPE) < 0);
if(abort)
return;

}

This works sometimes, but often OS.GetKeyState(OS.VK_ESCAPE) returns 0
even if the ESCAPE key is pressed.


3. I looked at using a cancellable Job to paint the layers, but soon gave
up.


Koen
Re: Cancel a time consuming paint operation [message #168500 is a reply to message #168459] Wed, 16 February 2005 08:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

The only way I think you can do this is to introduce a Figure at the top
level which paints to a cache using tiles, and then paints that cached
image. If you paint a small region of the 50,000 figures, it should be hast
due to clipping. Then you can asynExec more tiles and continue updating the
cached image.

Why so many figures?

"Koen van Dijken" <kvdijken@tiscali.nl> escreveu na mensagem
news:cuv0to$fs2$1@www.eclipse.org...
> In my application I have a zoom-to-fit-all button to zoom the viewport so
> all figures will be drawn. Sometimes the dataset contains as many as
> 50.000 figures, which can take 10-30 seconds to be painted. I want to give
> the user the option to cancel this painting operation if he presses the
> zoom-to-fit-all button by accident. The way the user should do this is not
> so important at this moment. I tried several ways (detailed below), but
> all without satisfactory results. Does anyone have an idea to get it to
> work?
>
>
> Different methods I tried:
>
> 1. In paintChildren() of the layer there is a loop which iterates over all
> children to be painted. For every child to be painted I use
> for( ... every child to be painted ... ) {
>
> // Paint this child
> Display.getCurrent().syncExec(new Runnable() { ... paint this child
> ... } );
> // Give the user a chance to cancel the painting of this layer.
> // Flag abort will be set when user wants to abort.
> Display.getCurrent().readAndDispatch();
>
> if(abort)
> return;
>
> }
>
> This does work, but the call to readAndDispatch() raises problems when
> panning the viewport.
>
>
> 2. Check the status of the ESCAPE key
>
> for( ... every child to be painted ... ) {
>
> // Paint this child
> { ... paint this child ... };
> abort = (OS.GetKeyState(OS.VK_ESCAPE) < 0);
> if(abort)
> return;
>
> }
>
> This works sometimes, but often OS.GetKeyState(OS.VK_ESCAPE) returns 0
> even if the ESCAPE key is pressed.
>
>
> 3. I looked at using a cancellable Job to paint the layers, but soon gave
> up.
>
>
> Koen
>
Re: Cancel a time consuming paint operation [message #168517 is a reply to message #168500] Wed, 16 February 2005 09:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kvdijken.tiscali.nl

Randy Hudson wrote:

> The only way I think you can do this is to introduce a Figure at the top
> level which paints to a cache using tiles, and then paints that cached
> image. If you paint a small region of the 50,000 figures, it should be hast
> due to clipping. Then you can asynExec more tiles and continue updating the
> cached image.

Hi Randy,

Painting a small part of these 50.000 figures is very fast allready,
because I use a spatial index in the layer to find out which figures to
paint, I do not have to cycle through all figures in the layer.

Your idea may be usefull. When I divide the Viewport into a number of
tiles (TileFigure implements IFigure) I can fill these tiles in the
background. As soon as the real image for a tile is ready, I can notify
the TileFigure to update its contents (sounds like a posting earlier in
the newsgroup). Then still there is a question how large these tiles
should be, with large datasets any tilesize may result in a long
paintingtime per tile. I would prefer to be able to cancel the painting
after *every* Figure in a Layer. Also, I suspect there may arise problems
with selecting figures which extend over the edge of a tile.

> Why so many figures?

This is a GIS application, where datasets may be very large.

Koen




> "Koen van Dijken" <kvdijken@tiscali.nl> escreveu na mensagem
> news:cuv0to$fs2$1@www.eclipse.org...
>> In my application I have a zoom-to-fit-all button to zoom the viewport so
>> all figures will be drawn. Sometimes the dataset contains as many as
>> 50.000 figures, which can take 10-30 seconds to be painted. I want to give
>> the user the option to cancel this painting operation if he presses the
>> zoom-to-fit-all button by accident. The way the user should do this is not
>> so important at this moment. I tried several ways (detailed below), but
>> all without satisfactory results. Does anyone have an idea to get it to
>> work?
>>
>>
>> Different methods I tried:
>>
>> 1. In paintChildren() of the layer there is a loop which iterates over all
>> children to be painted. For every child to be painted I use
>> for( ... every child to be painted ... ) {
>>
>> // Paint this child
>> Display.getCurrent().syncExec(new Runnable() { ... paint this child
>> ... } );
>> // Give the user a chance to cancel the painting of this layer.
>> // Flag abort will be set when user wants to abort.
>> Display.getCurrent().readAndDispatch();
>>
>> if(abort)
>> return;
>>
>> }
>>
>> This does work, but the call to readAndDispatch() raises problems when
>> panning the viewport.
>>
>>
>> 2. Check the status of the ESCAPE key
>>
>> for( ... every child to be painted ... ) {
>>
>> // Paint this child
>> { ... paint this child ... };
>> abort = (OS.GetKeyState(OS.VK_ESCAPE) < 0);
>> if(abort)
>> return;
>>
>> }
>>
>> This works sometimes, but often OS.GetKeyState(OS.VK_ESCAPE) returns 0
>> even if the ESCAPE key is pressed.
>>
>>
>> 3. I looked at using a cancellable Job to paint the layers, but soon gave
>> up.
>>
>>
>> Koen
>>
Re: Cancel a time consuming paint operation [message #168577 is a reply to message #168517] Wed, 16 February 2005 16:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kvdijken.tiscali.nl

I found out why the use of OS.GetKeyState() gives strange results: it
returns the state of the key at the time the event we are currently
processing. I need something likeOS.GetAsyncKeyState, but that does not
exist.

Also see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=82707

Koen



"Koen van Dijken" <kvdijken@tiscali.nl> wrote in message
news:cuvln1$j3v$1@www.eclipse.org...
> Randy Hudson wrote:
>
>> The only way I think you can do this is to introduce a Figure at the top
>> level which paints to a cache using tiles, and then paints that cached
>> image. If you paint a small region of the 50,000 figures, it should be
>> hast due to clipping. Then you can asynExec more tiles and continue
>> updating the cached image.
>
> Hi Randy,
>
> Painting a small part of these 50.000 figures is very fast allready,
> because I use a spatial index in the layer to find out which figures to
> paint, I do not have to cycle through all figures in the layer.
>
> Your idea may be usefull. When I divide the Viewport into a number of
> tiles (TileFigure implements IFigure) I can fill these tiles in the
> background. As soon as the real image for a tile is ready, I can notify
> the TileFigure to update its contents (sounds like a posting earlier in
> the newsgroup). Then still there is a question how large these tiles
> should be, with large datasets any tilesize may result in a long
> paintingtime per tile. I would prefer to be able to cancel the painting
> after *every* Figure in a Layer. Also, I suspect there may arise problems
> with selecting figures which extend over the edge of a tile.
>
>> Why so many figures?
>
> This is a GIS application, where datasets may be very large.
>
> Koen
>
>
>
>
>> "Koen van Dijken" <kvdijken@tiscali.nl> escreveu na mensagem
>> news:cuv0to$fs2$1@www.eclipse.org...
>>> In my application I have a zoom-to-fit-all button to zoom the viewport
>>> so all figures will be drawn. Sometimes the dataset contains as many as
>>> 50.000 figures, which can take 10-30 seconds to be painted. I want to
>>> give the user the option to cancel this painting operation if he presses
>>> the zoom-to-fit-all button by accident. The way the user should do this
>>> is not so important at this moment. I tried several ways (detailed
>>> below), but all without satisfactory results. Does anyone have an idea
>>> to get it to work?
>>>
>>>
>>> Different methods I tried:
>>>
>>> 1. In paintChildren() of the layer there is a loop which iterates over
>>> all children to be painted. For every child to be painted I use
>>> for( ... every child to be painted ... ) {
>>>
>>> // Paint this child
>>> Display.getCurrent().syncExec(new Runnable() { ... paint this child
>>> ... } );
>>> // Give the user a chance to cancel the painting of this layer.
>>> // Flag abort will be set when user wants to abort.
>>> Display.getCurrent().readAndDispatch();
>>>
>>> if(abort)
>>> return;
>>>
>>> }
>>>
>>> This does work, but the call to readAndDispatch() raises problems when
>>> panning the viewport.
>>>
>>>
>>> 2. Check the status of the ESCAPE key
>>>
>>> for( ... every child to be painted ... ) {
>>>
>>> // Paint this child
>>> { ... paint this child ... };
>>> abort = (OS.GetKeyState(OS.VK_ESCAPE) < 0);
>>> if(abort)
>>> return;
>>>
>>> }
>>>
>>> This works sometimes, but often OS.GetKeyState(OS.VK_ESCAPE) returns 0
>>> even if the ESCAPE key is pressed.
>>>
>>>
>>> 3. I looked at using a cancellable Job to paint the layers, but soon
>>> gave up.
>>>
>>>
>>> Koen
>>>
>
>
Re: Cancel a time consuming paint operation [message #168593 is a reply to message #168517] Wed, 16 February 2005 16:29 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

> Your idea may be usefull. When I divide the Viewport into a number of
> tiles (TileFigure implements IFigure) I can fill these tiles in the
> background. As soon as the real image for a tile is ready, I can notify
> the TileFigure to update its contents (sounds like a posting earlier in
> the newsgroup). Then still there is a question how large these tiles
> should be, with large datasets any tilesize may result in a long
> paintingtime per tile. I would prefer to be able to cancel the painting
> after *every* Figure in a Layer. Also, I suspect there may arise problems
> with selecting figures which extend over the edge of a tile.
>
>> Why so many figures?
>
> This is a GIS application, where datasets may be very large.

I would also look into creating cached layers. We wrote LayeredPane with
the thought that a Layer may contain a local UpdateManager which store a
cached Image of what is painted on that layer and below. Some of this code
may have been simplified away, but there is still the possibility of adding
your own local updatemanagers at one or more layers. That, tiling, and
perhaps reducing the data displayed based on zoom level could help.
Previous Topic:showing properties for a list of items
Next Topic:displaying graph in popup window
Goto Forum:
  


Current Time: Tue Jun 17 07:45:47 EDT 2025

Powered by FUDForum. Page generated in 1.85916 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top