Hi Nazar,

     I found your problem, read on:

"Nazar Stasiv (Lohika, Inc)" <[EMAIL PROTECTED]> wrote on 08/15/2006 
08:09:33 AM:

> Here is how I do it
> 
>     public static SVGDocument installScript(SVGDocument doc,
>             Collection<String> labels) {
> 
>         // add to dom tree element with id=background to use it in 
draggable
>         // functions
>         Element parent = doc.createElement("g");

    This is not an SVG 'g' element it is a 'g' element in
the "no namespace" namespace (well it's really more complex than
that but the important bit is that it is not an SVG 'g' Element).

    As a result, as the SVG specification requires we ignore that
element _and_all_of_it's_children.  So they do not become part
of the rendering tree and hence have no BBox.  The fix is trivial:

        Element parent = doc.createElementNS(svgns,"g");


      There are a few other little bits that should be cleaned up
as well in this code with regard to namespaces.

>         // Append script element with reference to library file
>         Element sc = doc.createElementNS(svgns, "script");

        This is good.

>         sc.setAttributeNS(svgns, "language", "text/ecmascript");

        This is bad (it works because your value is the default). 
This should be:
         sc.setAttributeNS(null, "language", "text/ecmascript");

>         sc.setAttributeNS(xlinkns, "href", "svg-common.js");

        This will work "in memory" (href is in xlink namespace), but you 
might
want to change the "href" to "xlink:href" so it will work correctly
when read back in.

>         NodeList list = doc.getElementsByTagNameNS(null, "svg");

        This should not work, you should need 'svgns' instead of 'null'.

>         Element svgNode = (Element) list.item(0);
         sc.setAttributeNS(svgns, "language", "text/ecmascript");

        This should be:
         sc.setAttributeNS(null, "language", "text/ecmascript");

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to