My current work on a GWT-Wrapper for Raphael might be interesting to you [1].
Tom [1]http://tomsondev.bestsolution.at/2010/01/31/qxwt-1-0-1-0-rc1-and-other-cool-stuff/ On Tue, Jan 26, 2010 at 6:45 PM, markww <mar...@gmail.com> wrote: > Ok this is what I came up with: > > public class SVGRect extends Node > { > protected SVGRect() {} > > public static final native SVGRect create() /*-{ > var rect = document.createElementNS('http://www.w3.org/2000/ > svg', 'rect'); > return rect; > }-*/; > } > > public class SVGPanel extends Node > { > protected SVGRect() {} > > public native SVGPanel create(String width, String height) /*-{ > var svg = document.createElementNS('http://www.w3.org/2000/ > svg', 'svg'); > svg.setAttribute('width', width); > svg.setAttribute('height', height); > return svg; > }-*/; > } > > // main module > public void onModuleLoad() { > > SVGPanel panel = SVGPanel.create("100%", "100%"); > Document doc = Document.get(); > doc.getBody().appendChild(panel); > > SVGRect rect = SVGRect.create(); > rect.setWidth(100); > .... create / manipulate shapes etc ... > > panel.appendChild(rect); > } > > I wanted to use overlays since they're supposed to introduce zero > overhead. If I derive from Widget (like gwt-svg does), then don't we > have to pay for the extra member variables used in the Widget class? > I'm worried that if I want to create a large number of rectangles for > example, then each will have extra data associated with it. The Widget > implementation looks like this at the start: > > public abstract class Widget { > int style, state; > Display display; > EventTable eventTable; > Object data; > > so I'm just imaging each rectangle I create in my svg having all that > extra data associated with it. > > @DaveC's comment: > "Your create method is returning an Element - not an SVGPanel..." > Yeah I'm not sure if this is right - runs ok (programming by chance) - > should I really return a Node, then cast it to my SVGRect type? Since > it's just an overlay, I thought it would be ok. > > I may be completely off on all this, any more thoughts would be great. > I've got dragging svg shapes built in now and all that fun stuff, I'd > like to make this library available when complete, svg is really cool. > I also hooked it up to SVG Web, so that if on Internet Explorer, it'll > use that library to emulate SVG using Flash, > > Thanks > > > On Jan 26, 3:19 am, Brett Morgan <brett.mor...@gmail.com> wrote: >> It might be worth checking out the gwt svg implementation in gwt-widget >> library: >> >> http://gwt-widget.sourceforge.net/docs/xref/org/gwtwidgets/client/svg... >> >> >> >> >> >> On Tue, Jan 26, 2010 at 6:22 AM, markww <mar...@gmail.com> wrote: >> > Hi, >> >> > I'd like to make some really simple overlay classes in GWT to wrap >> > some SVG stuff. I'd basically like to get a rectangle drawn, this is >> > how I do it in javascript: >> >> > var svg = document.createElementNS('http://www.w3.org/2000/svg', >> > 'svg'); >> > svg.setAttribute('width', '100%'); >> > svg.setAttribute('height', '100%'); >> > document.body.appendChild(svg); >> >> > var rect = document.createElementNS('http://www.w3.org/2000/ >> > svg','rect'); >> > rect.setAttribute("width","300"); >> > rect.setAttribute("height","100"); >> > svg.appendChild(rect); >> >> > and now I'm having trouble translating that to GWT. I was hoping I >> > could do a really thin overlay around all those calls, something like >> > this: >> >> > public class SVGPanel extends JavaScriptObject { >> > protected SVGPanel() {} >> >> > public static native SVGPanel create(String width, String height) / >> > *-{ >> > var svg = document.createElementNS('http://www.w3.org/2000/ >> > svg', 'svg'); >> > svg.setAttribute('width', width); >> > svg.setAttribute('height', height); >> > return svg; >> > }-*/; >> > } >> >> > public MyProject implements EntryPoint { >> >> > public void onModuleLoad() { >> > SVGPanel panel = SVGPanel.create("100%", "100%"); >> > Document.get().getBody().appendChild(panel); >> > } >> > } >> >> > yeah but I do not have a grasp on how we can jump from the javascript >> > representation of the SVG stuff to GWT java classes. For one, the >> > SVGPanel class extends JavaScriptObject, but I can't simply add it to >> > the Document body class because it's expecting an Element type. If >> > someone could just point out the right way to do that bridge I should >> > be able to get going after that. >> >> > Also, I'm not sure if this the optimal way to incorporate some simple >> > SVG classes, should I be modeling them using the DOM classes instead >> > of trying to use JSNI ? >> >> > Thanks >> >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "Google Web Toolkit" group. >> > To post to this group, send email to google-web-tool...@googlegroups.com. >> > To unsubscribe from this group, send email to >> > google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2Bunsubs >> > cr...@googlegroups.com> >> > . >> > For more options, visit this group at >> >http://groups.google.com/group/google-web-toolkit?hl=en. >> >> -- >> Brett Morganhttp://domesticmouse.livejournal.com/ > > -- > You received this message because you are subscribed to the Google Groups > "Google Web Toolkit" group. > To post to this group, send email to google-web-tool...@googlegroups.com. > To unsubscribe from this group, send email to > google-web-toolkit+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.