Home » Eclipse Projects » Remote Application Platform (RAP) » Re-Initialization of Canvas/GC in RAP
Re-Initialization of Canvas/GC in RAP [message #765511] |
Wed, 14 December 2011 08:21 |
Jiri Sliva Messages: 3 Registered: October 2010 |
Junior Member |
|
|
Hello,
I found out strange behavior of RAP for drawing into Canvas.
Each update of Canvas (draw new graphic element from asyncExec) causes re-initialization of JS canvas (set size and clean canvas content).
For example: repeated call of following code:
display.asyncExec(new Runnable() {
public void run() {
final GC gc = new GC(canvas);
gc.drawLine(x, 0, x, 100);
gc.dispose();
}
});
Where x is changed each time will produce only ONE line on canvas in same time.
Doesn't matter if GC is created once or repeatly.
RAP's class GCOperationWriter produces following JS code:
var wm = org.eclipse.swt.WidgetManager.getInstance();
var w = wm.findWidgetById( "w3" );
var gc = w.getGC();
gc.init( 468, 430, "14px Verdana, 'Lucida Sans', Arial, Helvetica, sans-serif", "#ffffff", "#4a4a4a" );
gc.drawLine( ... )
And there is init method from GC.js
init : qx.core.Variant.select( "qx.client", {
"mshtml" : function( width, height, font, background, foreground ) {
// TODO [tb]: Should the control be detached from the DOM
// (e.g. by Widget.prepareEnhancedBorder), this might lead to glitches
// in IE/VML. The flush prevents this in some cases:
qx.ui.core.Widget.flushGlobalQueues();
this._initTextCanvas( width, height );
this._context.clearRect( 0, 0, width, height );
this._initFields( font, background, foreground );
},
"default" : function( width, height, font, background, foreground ) {
this._initTextCanvas( width, height );
this._canvas.width = width;
this._canvas.style.width = width + "px";
this._canvas.height = height;
this._canvas.style.height = height + "px";
this._context.clearRect( 0, 0, width, height );
this._initFields( font, background, foreground );
}
} ),
Call of this._canvas.width = width; is enough to reset/clean content of JS canvas (I have tried to remove only call of this._context.clearRect( 0, 0, width, height ); but this didn't help).
We have to avoid add this call (init) into each drawing JS code generated by RAP.
var wm = org.eclipse.swt.WidgetManager.getInstance();
var w = wm.findWidgetById( "w3" );
var gc = w.getGC();
// -- removed -- gc.init( 468, 430, "14px Verdana, 'Lucida Sans', Arial, Helvetica, sans-serif", "#ffffff", "#4a4a4a" );
gc.drawLine( ... )
Before I enter this into RAP bugs I want to ask you. Do you know what is purpose of this behavior?
With this is impossible to make additional drawings into canvas (which is possible in SWT).
Thanks for any comment.
[Updated on: Wed, 14 December 2011 09:53] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Apr 26 02:16:41 GMT 2024
Powered by FUDForum. Page generated in 0.03777 seconds
|