Using SVG in GWT

后端 未结 8 836
感动是毒
感动是毒 2021-02-05 12:31

I was wondering if it is possible to include SVG content inside a panel (or whatever would work in GWT), be able to add more to the SVG (like add a circle or a curve) programmat

8条回答
  •  攒了一身酷
    2021-02-05 12:46

    Interesting!

    I've tried to use Raphael through GWT/Java code but I can't seem to be able to use your trick.

    I have the following block in my HTML page :

    
    

    When I compile/browse the page in Firefox, I get my circle in my page, no problem.

    Then I add the following native java to my module entrypoint method and call it :

     private native JavaScriptObject returnRaphael() /*-{
                return $wnd.rr;
            }-*/;
    

    Debugging shows that the returned object is always null...

    Plus, I don't understand why I could not simply do the following in my Java code:

    public native void createRaphael()/*-{
        Raphael("some_div", 200,200);
    }-*/;
    

    GWT keeps telling me that Raphael does not exist, though, as I see through firebug, the library is perfectly included. This does not work either :

    public native void createRaphael()/*-{
        $wnd.Raphael("some_div", 200,200);
    }-*/;
    

    Surprinsingly, I manage to access draw2d (openJacob draw2d) classes and functions with that $wnd but not my Raphael objects... There must be something I did not get...

提交回复
热议问题