Hi,

If you know with certainty the order of the definitions, you may use the following suggestion:

Instead of putting the diplay in <def> elements, put them in <svg> elements. By doing this, you have a unique placeholder for each in the GVT (a CanvasGraphicsNode is created for each embedded SVG element). So you may walk the GVT tree to create the CanvasGraphicNode´s array with the geometry of each display.

Andres.


On Feb 3, 2005, at 11:27 AM, Rémy Brousset wrote:

 
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.
 
 

<imstp_emo_fr.gif>

Reply via email to