Dear Remy,

 

I am making a “dynamic” graphic container based on svg. The symbols I use are in the defs section of the svg-file in <symbol> tags with id’s. To view the symbol I use the use tag <use> with a reference to the symbol in the xlink:href attribute. Changing the symbol is as simple as changing the attribute value. Mind you, the attribute is in the xlink namespace, so it must be defined in the svg root element AND you must use the setAttributeNS(..) to change it.

 

Maybe not the approach you are looking for, but it works and really fast!!

 

 

Leo van den Berg.

 

 

-----Mensaje original-----
De: Rémy Brousset [mailto:[EMAIL PROTECTED]
Enviado el: jueves, 03 de febrero de 2005 17:27
Para: batik-users@xml.apache.org
Asunto: dynamic change of display rendering

 

 

hi folks,

 

i have some simple svg that i use with their gvt root node to display it in existing java canvas.

 

....

GVTBuilder builder = new GVTBuilder();

Element svgRootElem = svgDoc.getDocumentElement();
 GraphicsNode rootNode = builder.build(ctx,svgRootElem );

...

rootNode.paint( myDisplayContext );

 

this works pretty good.

What i want to do now is changing the display dynamically among 3 or 4 possible definitions stored in the svg.

I tried tu put a defs section in the svg,

 

<svg width="10%" xmlns:xlink="http://www.w3.org/1999/xlink" height="10%" viewBox="0 0 600 600" preserveAspectRatio="xMidYMid meet"     xmlns="http://www.w3.org/2000/svg">
   

<!-- default display -->
    <ellipse rx="299" ry="299" style="stroke: rgb(255, 255, 255); fill: rgb(255, 153, 0);" cx="300"
         cy="300"/>
    <path style="stroke: rgb(255, 255, 255); fill:rgb(255, 255, 255)" d="m300,300 l 212.1,-212.1
        a300 300 0 0 1 0 424.2 z"/>
    <path style="stroke: rgb(255, 255, 255); fill:rgb(255, 255, 255)" d="m300,300 l -212.1,-212.1
        a300 300 0 0 0 0 424.2 z"/>
        


       <defs>
             <g id="display2" >
       
                <ellipse rx="299" ry="299" style="stroke: rgb(255, 255, 255); fill: rgb(100, 150, 100);" cx="300"
                  cy="300"/>
                <path style="stroke: rgb(255, 255, 255); fill:rgb(255, 255, 255)" d="m300,300 l 212.1,-212.1
                 a300 300 0 0 1 0 424.2 z"/>
                 <path style="stroke: rgb(255, 255, 255); fill:rgb(255, 255, 255)" d="m300,300 l -212.1,-212.1
                 a300 300 0 0 0 0 424.2 z"/>
 
             </g>  

       </defs>
</svg>

 

 

 

and i tried to access it that way with no results :

 

     Element elem = svgDoc.getElementById("display2");
     GraphicsNode auxDisplayNode = ctx.getGraphicsNode(elem);  <-- auxDisplayNode == null

 

Has someone ever done it? should i put it in a symbol section instead of defs?

have i to reconstruct a whole gvt tree (to have a root graphics node)?if i have, how can i do that?

 

every ideas welcome (even stupids, trust me i got a lot...;)

 

thanks,regards

Remy.

 

 

 

 

 

Add FUN to your email - CLICK HERE!

Reply via email to