I need to do some client-side 2D drawing in my GWT app (nothing fancy, just draw a bunch of basic 2D shapes - circles, rectangles, etc.).
I don't believe GWT has a graphics/drawing framework, and so I was wondering if there was any way to use JSNI to somehow connect to the reputed Raphael JS library and invoke Raphael from inside GWT.
If this isn't possible, can someone explain why and what my options might be?
And if this is possible, then consider the following Raphael code that draws a square:
paper = new Raphael(0,0,500,500);
var rect = paper.rect(x,y,width,height).attr({"fill":"white","stroke":"red"});
I want that JS code above to execute when a user clicks a button. Here is my GWT click handler:
@UiHandler("signInButton")
void onClickSignInButton(final ClickEvent clickEvent) {
// ????
}
How do I connect the two?
Wrap Raphael class in JSObject class.
Like wise you can wrap other classes and/or provide methods on them.
Then call this Java code as you would otherwise.