Nice example... have you done anything with dragging rectangles around, and having other rectangles scooch out of their way? I would like to investigate something like this for scheduling.
On Wed, Aug 4, 2010 at 5:22 AM, pschonefeld <[email protected]>wrote: > I've played around with svgweb and GWT ... > > new SvgRectangle("myRect","0", "0", "200", "200", "0", "0", > "black", "orange", "5"); > ... > private class SvgRectangle extends Widget { > private Element element; > private String fill; > private String svgns = "http://www.w3.org/2000/svg"; > private SvgRectangle(String id, String x, String y, > String width, String > height, > String rx, String ry, > String fill, String stroke, > String strokeWidth) { > element = createElementNS(svgns,"rect"); > element.setAttribute("id", id); > element.setAttribute("x", x); > element.setAttribute("y", y); > element.setAttribute("width", width); > element.setAttribute("height", height); > element.setAttribute("rx", rx); > element.setAttribute("ry", ry); > element.setAttribute("fill", fill); > element.setAttribute("stroke", stroke); > element.setAttribute("stroke-width",strokeWidth); > this.fill = fill; > setElement(element); > Element elem = RootPanel.get("myg").getElement(); > elem.appendChild(element); > addClickListener(this, id); > > } > > public void OnClick() { > Element elem = getElementById("myRect"); > elem.setAttribute("fill", "green" ); > Window.alert("Ahhtahh!"); > } > > private native Element createElementNS(String ns, String > localname) /*-{ > return elem = $doc.createElementNS(ns,localname); > }-*/; > > private native Element getElementById(String id) /*-{ > return $doc.getElementById(id); > }-*/; > > private native void addClickListener(SvgRectangle instance, > String id) /*-{ > function pete_click(e) { > if ($wnd.event || $wnd.Event) { > if (!e) e = $wnd.event; > > [email protected]::OnClick()(); > } > } > var rect =$doc.getElementById(id); > rect.addEventListener("click",pete_click,false); > }-*/; > > @Override > protected void onLoad() { > super.onLoad(); > addClickListener(this, "myRect"); > } > > @Override > protected void onUnload() { > super.onUnload(); > } > } > > and in the html .... > > <script type="text/javascript" src="src/svg.js" data- > path="src" data-debug="false"></script> > ... > <script type="image/svg+xml"> > <svg xmlns="http://www.w3.org/2000/svg" width="200" > height="200" > version="1.1" baseProfile="full"> > <g id="myg"></g> > </svg> > </script> > > probably not the out of the box solution that you're looking for but > HTH. > > -- > You received this message because you are subscribed to the Google Groups > "Google Web Toolkit" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-web-toolkit%[email protected]> > . > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
