xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted.Clem...@apcc.com
Subject BridgeContext.getElement returns null
Date Tue, 14 Jun 2005 17:26:02 GMT

I'm sorry, I cut/pasted pieces of code to try to reduce the amount of code
in the email.
( * *  see note at bottom)
The GVTTree is built once here:

      public void gvtBuildCompleted(GVTTreeBuilderEvent e) {

                 UserAgentAdapter userAgent = new UserAgentAdapter();
                 GVTBuilder builder         = new GVTBuilder();
                 BridgeContext ctx          = new BridgeContext(userAgent);

                 builder.build(ctx, theDocument);            // built here
                 theSVGModel.setBridgeContext(ctx);  //register this
reference with the model

                 // Now the tree is ready
                 treeWalker = new GVTTreeWalker(e.getGVTRoot());
                 theSVGModel.setGVTTreeWalker(treeWalker);  //register
reference with the model

Over in the model, in a routine called from a DnD dragOver, I have an X, Y
coordinate (mouse pos) :

        GraphicsNode root = theGVTTreeWalker.getRoot();   // get the GVT
        Point  point = new Point(nowToX, nowToY);                    //
make a Point from the x,y (current mouse pos)
        GraphicsNode childGNode = root.nodeHitAt(point);   // use the Point
to get the rectangle under mouse
// note: this works, childGNode has all the correct attributes
        // from the GVT node, I need to get the DOM element
        Element svgElement = theBridgeContext.getElement(childGNode);   //
this comes up null every time

 Ultimately, I need the "id" attribute of the group that this rectangle
belongs to (see below)
 My intent was to follow the parent chain to the topmost group and do this:
/// String targetNodeID = svgElement.getAttribute("id");

Here's the snipped SVG group - there are HUNDREDS of these in this
auto-generated file!:
    ||||||| I need the value of this attribute
<g id="guid_F917D459-6947-4C77-874B-9FED41DF5492">
   <g transform="translate(50,30)" style="font-size:11;
fill:rgb(230,230,245); font-family:&apos;Arial&apos;
stroke:rgb(230,230,245); stroke-width:1.5;">
    <rect x="180" y="189" width="35.2494" style="stroke:none;" height="63"
    <rect x="180" y="189" width="35.2494" style="fill:none;
stroke:rgb(0,0,205);" height="63" />
    <text x="184.62469482421875" y="200" style="font-size:9; fill:black;
stroke:none;" xml:space="preserve">R6/Z1
    <text x="181.62469482421875" y="218" style="font-size:8; fill:black;
stroke:none;" xml:space="preserve">W1:19.00
    <text x="181.62469482421875" y="226" style="font-size:8; fill:black;
stroke:none;" xml:space="preserve">W2:13.00

* * Thanks for your patience, I hope this makes more sense. I am starting
to think that I will need to abandon this approach,
 and iterate throught the DOM elements, comparing X,Y coordinates...
uggh...   ;  P

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

View raw message