Maybe try an existing SVG that you know renders OK and embed it in a String and load the canvas with that to see if it renders.
John > -----Original Message----- > From: paddy [mailto:[email protected]] > Sent: Wednesday, 21 January 2009 10:13 > To: [email protected] > Subject: Re: Problem rendering an SVG DOM built on the fly in Applet > > > Thanks for the quick reply, I tried it as below, but still no joy i'm > afraid. > This is the relevant code from DrawNode: > > Element nodeElmt = > m_objSVGDoc.createElementNS(m_objSVGDoc.getNamespaceURI(), "rect"); > nodeElmt.setAttributeNS(m_objSVGDoc.getNamespaceURI(), "x", > m_strX); > nodeElmt.setAttributeNS(m_objSVGDoc.getNamespaceURI(), "y", > m_strY); > nodeElmt.setAttributeNS(m_objSVGDoc.getNamespaceURI(), "width", > "40"); > nodeElmt.setAttributeNS(m_objSVGDoc.getNamespaceURI(), > "height", > "40"); > nodeElmt.setAttributeNS(m_objSVGDoc.getNamespaceURI(), "style", > "stroke:black; fill:white;"); > registerListeners(nodeElmt); > m_objSVGRoot.appendChild(nodeElmt); > array[0] = nodeElmt; > > Element txtElmt = > m_objSVGDoc.createElementNS(m_objSVGDoc.getNamespaceURI(), "text"); > Text value = m_objSVGDoc.createTextNode(m_strName); > txtElmt.setAttributeNS(m_objSVGDoc.getNamespaceURI(), "x", > m_strX); > txtElmt.setAttributeNS(m_objSVGDoc.getNamespaceURI(), "y", > m_strY); > txtElmt.setAttributeNS(m_objSVGDoc.getNamespaceURI(), "dx", > "2"); > txtElmt.setAttributeNS(m_objSVGDoc.getNamespaceURI(), "dy", > "20"); > txtElmt.setAttributeNS(m_objSVGDoc.getNamespaceURI(), > "textLength", > "36" ); > txtElmt.setAttributeNS(m_objSVGDoc.getNamespaceURI(), > "lengthAdjust", "spacingAndGlyphs" ); > txtElmt.setAttributeNS(m_objSVGDoc.getNamespaceURI(), "style", > "fill:black"); > txtElmt.appendChild(value); > m_objSVGRoot.appendChild(txtElmt); > registerListeners(txtElmt); > array[1] = txtElmt; > > > Is there something I should be doing when initialising the applet, or > some > special way the canvas has to be added to a swing component. I'm really > at a > loss. > > > > Hi Paddy, > > paddy <[email protected]> wrote on 01/20/2009 03:41:05 PM: > > > Incidentally my DrawNode object just draws a rectangle on the SVG > with a > > label, and pnlSVGMain is directly on the applet. > > I suspect the problem is in your DrawNode code. In particular I > suspect that you are using 'createElement' instead of 'createElementNS' > with the SVG_NAMESPACE_URI for the namespace. It would produce > exactly this sort of problem. > > > objSVGCanvas.setSVGDocument((SVGDocument)m_objSVGDoc); > > objSVGCanvas.repaint(); > > The above repaint is not useful and could be harmful. I suggest > you remove it. The Canvas will repaint as needed. > > -- > View this message in context: http://www.nabble.com/Problem-rendering- > an-SVG-DOM-built-on-the-fly-in-Applet-tp21571223p21573842.html > Sent from the Batik - Users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: batik-users- > [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
