xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas DeWeese <Thomas.DeWe...@Kodak.com>
Subject Re: dynamically adding an element to svgdocument
Date Thu, 09 Dec 2004 14:49:10 GMT
Hi Chandra,

>>                                 Element elt = svgdoc.createElement("a");
>>   elt.setAttribute("xlink:href","http://www.ibm.com/");

There is one more thing you are missing.  SVG/Batik is a namespace
aware language/processor so you need to take care to use namespaces
properly:

SVG_NS = "http://www.w3.org/2000/svg";
XLINK_NS = "http://www.w3.org/1999/xlink";

// Use this for all SVG elements.
Element elt = svgdoc.createElementNS(SVG_NS, "a");

// Use this for "xlink" attributes.
elt.setAttributeNS(XLINK_NS, "xlink:href","http://www.ibm.com/");

// Use either for "unprefixed" attributes (I've been told that
// the ns one is better than the non-ns one but I'm not 100%
// certain I agree there should be a difference).
elt.setAttributeNS(null, "style", "fill:blue");
elt.setAttribute("stroke", "none");


Jorg Heymans wrote:

> This should come first:
> 
> svgCanvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
> 
> furthermore, there is no need IMO to set the document back on the canvas 
> as you're updating it in place.
> 
> And not all of your code below needs to be invoked from the update mgr 
> thread, only the svgdoc.getRootElement().appendChild(elt); is modifying 
> the document really.



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message