How to avoid paint merging ? [message #464662] |
Mon, 28 November 2005 07:45  |
Eclipse User |
|
|
|
I need to display large amount of data on a custom widget (subclassed
from canvas) , loading the data from database takes a considerable
amount of time. So I want to fetch the data in smaller bunches while
displaying placeholders fo all elements that are not loaded yet.
On windows everythings works ok, but on MacOSX the paint requests seem
to get merged, the os just waits until everything is loaded (which makes
the app feel very slow).
How can I avoid that ?
control.update() and display.update() both have no effect.
Short snippet to illustrate what i want to do :
Canvas control = new Control(Display.getCurrent(), SWT.NO.BACKGROUND)
control.addPaintListener(new PaintListener(){
public void paintControl(PaintEvent event){
for(int i=0;i<10;i++){
//load data
..
//paint data on event.gc
//paint elements that are already loaded
...
//paint placeholders for the remaining elements
...
//Paint requests must be procesed NOW
this.update(); //no effect ?!
}
}
});
Regards,
Yves Harms
|
|
|
Re: How to avoid paint merging ? [message #464672 is a reply to message #464662] |
Mon, 28 November 2005 11:05  |
Eclipse User |
|
|
|
You should not be loading the data in the UI thread. Start a separate
thread to load the data and from the second thread damage the canvas to
draw.
Canvas control = new Control(Display.getCurrent(), SWT.NO.BACKGROUND)
control.addPaintListener(new PaintListener(){
public void paintControl(PaintEvent event){
//paint data on event.gc
//paint elements that are already loaded
//paint placeholders for the remaining elements
}
Thread newThread = new Thread() {
public void run() {
Display display = Display.getDefault();
for(int i=0;i<10;i++){
//load a chunk of data
display.syncExec(new Runnable() {
public void run() {
if (!canvas.isDisposed())
canvas.redraw();
}
});
}
}
};
newThread.start();
"Yves Harms" <user@domain.invalid> wrote in message
news:dmeud4$msg$1@news.eclipse.org...
>I need to display large amount of data on a custom widget (subclassed from
>canvas) , loading the data from database takes a considerable amount of
>time. So I want to fetch the data in smaller bunches while displaying
>placeholders fo all elements that are not loaded yet.
> On windows everythings works ok, but on MacOSX the paint requests seem to
> get merged, the os just waits until everything is loaded (which makes the
> app feel very slow).
>
> How can I avoid that ?
>
> control.update() and display.update() both have no effect.
>
>
> Short snippet to illustrate what i want to do :
>
> Canvas control = new Control(Display.getCurrent(), SWT.NO.BACKGROUND)
> control.addPaintListener(new PaintListener(){
> public void paintControl(PaintEvent event){
> for(int i=0;i<10;i++){
> //load data
> ..
> //paint data on event.gc
> //paint elements that are already loaded
> ...
> //paint placeholders for the remaining elements
> ...
> //Paint requests must be procesed NOW
> this.update(); //no effect ?!
> }
>
> }
> });
>
> Regards,
> Yves Harms
|
|
|
Powered by
FUDForum. Page generated in 0.04264 seconds