Skip to main content


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 12:45 Go to next message
Yves Harms is currently offline Yves HarmsFriend
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 16:05 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
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: Fri Apr 26 14:58:40 GMT 2024

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

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

Back to the top