Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to avoid paint merging ?
How to avoid paint merging ? [message #464662] Mon, 28 November 2005 07:45 Go to next message
Yves Harms is currently offline Yves Harms
Messages: 80
Registered: July 2009
Member
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 Go to previous message
Veronika Irvine is currently offline Veronika Irvine
Messages: 1272
Registered: July 2009
Senior Member
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
Previous Topic:Table Get Selected Cell
Next Topic:Reading data from IStorage Object
Goto Forum:
  


Current Time: Tue Jul 29 17:08:20 EDT 2014

Powered by FUDForum. Page generated in 0.02101 seconds