Hi all,

 

I’m dealing with maps which are available in SVG format.

I have to put icons onto the map in runtime. The icons are available in separated SVG files.

 

My idea is that I’m loading the icons element from the SVG file and put them into <defs> part:

 

<defs>

<g id="train-1-purple">

                        <polygon i:knockout="Off" fill="#CC66CC" points="0,28 26,28 40,14 26,0 0,0 "/>

                        <polygon i:knockout="Off" points="4,24 24,24 34,14 24,4 4,4 "/>

            </g>

</defs>

 

But I have problem when I use a reference of this def element.

if I place a <use> element in the svg file, the icon will be displayed.

                        <use id="T_3_0_0" xlink:href="" x="0" y="0" />

if I try to place it from code, it won’t be displayed.

 

                        Element trainImage = canvas.getSVGDocument().createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, SVGConstants.SVG_USE_TAG);

            trainImage.setAttributeNS(XMLConstants.XLINK_NAMESPACE_URI, "xlink:href", "#train-1-purple");

trainImage.setAttributeNS(null, "id", "T_3_0_0");

trainImage.setAttributeNS(null, "x", "0");

            trainImage.setAttributeNS(null, "y", "0");

            trainRoot.appendChild(trainImage); 

 

Is it a bug in Batik or do I something wrong?

 

Thanks,

Tamas

Reply via email to