[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Re: How to avoid paint merging ?
|
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@xxxxxxxxxxxxxx> wrote in message
news:dmeud4$msg$1@xxxxxxxxxxxxxxxxxxx
>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