Heres SVG. the elements I identify to have BBox are in bold (parent element g with bpel:activity-label attribute). For reference I attached whole svg file as well.

            <g xmlns:bpel="http://www.bpel.com/bpms"
               
                style="color-interpolation:auto;color-rendering:auto;fill:red;fill-opacity:1;font-family:sans-serif;font-size:12;font-style:normal;font-weight:normal;image-rendering:auto;shape-rendering:auto;stroke:black;stroke-dasharray:none;stroke-dashoffset:0;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:10;stroke-opacity:1;stroke-width:1;text-rendering:auto"
                bpel:process-id="ID-d4ef0814-bf00-1004-80f8-5c5630e37dfa"
                bpel:activity-label="Event"
                bpel:activity-id="ID-d54cf1dc-bf00-1004-80f8-5c5630e37dfa">

                <g style="fill:white;stroke:white">
                    <path style="stroke:none"
                        d="M148 347.3505859375 L173 372.3505859375 L148 397.3505859375 L123 372.3505859375 Z" />
                    <path style="fill:none;stroke:black"
                        d="M148 347.3505859375 L173 372.3505859375 L148 397.3505859375 L123 372.3505859375 Z" />
                </g>
                <g
                    style="shape-rendering:geometricPrecision;text-rendering:optimizeLegibility"
                    transform="matrix(1,0,0,1,111.60734558105469,354.00677490234375)">
                    <path style="stroke:none"
                        d="M0.953125 0 L0.953125 -8.59375 L7.15625 -8.59375 L7.15625 -7.578125 L2.09375 -7.578125 L2.09375 -4.953125 L6.84375 -4.953125 L6.84375 -3.9375 L2.09375 -3.9375 L2.09375 -1.015625 L7.359375 -1.015625 L7.359375 0 L0.953125 0 ZM10.51953125 0 L8.16015625 -6.21875 L9.26953125 -6.21875 L10.61328125 -2.5 Q10.81640625 -1.890625 11.00390625 -1.25 Q11.14453125 -1.734375 11.39453125 -2.421875 L12.78515625 -6.21875 L13.86328125 -6.21875 L11.50390625 0 L10.51953125 0 ZM19.05078125 -2 L20.14453125 -1.875 Q19.89453125 -0.921875 19.19140625 -0.390625 Q18.48828125 0.140625 17.41015625 0.140625 Q16.05078125 0.140625 15.24609375 -0.703125 Q14.44140625 -1.546875 14.44140625 -3.0625 Q14.44140625 -4.625 15.25390625 -5.4921875 Q16.06640625 -6.359375 17.34765625 -6.359375 Q18.59765625 -6.359375 19.38671875 -5.515625 Q20.17578125 -4.671875 20.17578125 -3.125 Q20.17578125 -3.03125 20.17578125 -2.84375 L15.53515625 -2.84375 Q15.59765625 -1.8125 16.11328125 -1.2734375 Q16.62890625 -0.734375 17.41015625 -0.734375 Q17.98828125 -0.734375 18.40234375 -1.0390625 Q18.81640625 -1.34375 19.05078125 -2 ZM15.59765625 -3.703125 L19.06640625 -3.703125 Q19.00390625 -4.5 18.67578125 -4.890625 Q18.16015625 -5.5 17.36328125 -5.5 Q16.62890625 -5.5 16.13671875 -5.015625 Q15.64453125 -4.53125 15.59765625 -3.703125 ZM21.474609375 0 L21.474609375 -6.21875 L22.412109375 -6.21875 L22.412109375 -5.34375 Q23.099609375 -6.359375 24.396484375 -6.359375 Q24.958984375 -6.359375 25.435546875 -6.15625 Q25.912109375 -5.953125 26.146484375 -5.625 Q26.380859375 -5.296875 26.474609375 -4.859375 Q26.521484375 -4.5625 26.521484375 -3.828125 L26.521484375 0 L25.474609375 0 L25.474609375 -3.78125 Q25.474609375 -4.4375 25.349609375 -4.75 Q25.224609375 -5.0625 24.912109375 -5.2578125 Q24.599609375 -5.453125 24.177734375 -5.453125 Q23.505859375 -5.453125 23.013671875 -5.0234375 Q22.521484375 -4.59375 22.521484375 -3.40625 L22.521484375 0 L21.474609375 0 ZM30.4453125 -0.9375 L30.6015625 -0.015625 Q30.1484375 0.078125 29.8046875 0.078125 Q29.2265625 0.078125 28.9140625 -0.1015625 Q28.6015625 -0.28125 28.46875 -0.578125 Q28.3359375 -0.875 28.3359375 -1.828125 L28.3359375 -5.40625 L27.5703125 -5.40625 L27.5703125 -6.21875 L28.3359375 -6.21875 L28.3359375 -7.765625 L29.3828125 -8.390625 L29.3828125 -6.21875 L30.4453125 -6.21875 L30.4453125 -5.40625 L29.3828125 -5.40625 L29.3828125 -1.765625 Q29.3828125 -1.3125 29.4375 -1.1875 Q29.4921875 -1.0625 29.6171875 -0.984375 Q29.7421875 -0.90625 29.9765625 -0.90625 Q30.1640625 -0.90625 30.4453125 -0.9375 Z" />
                </g>
                <g style="fill:white;stroke:white"
                    transform="matrix(1,0,0,1,-30,-50)">
                    <path style="stroke:none"
                        d="M192.6341552734375 422.3505859375 C192.6341552734375 430.43280029296875 186.08221435546875 436.9847412109375 178 436.9847412109375 C169.91778564453125 436.9847412109375 163.36585998535156 430.43280029296875 163.36585998535156 422.3505859375 C163.36585998535156 414.26837158203125 169.91778564453125 407.7164306640625 178 407.7164306640625 C186.08221435546875 407.7164306640625 192.6341552734375 414.26837158203125 192.6341552734375 422.3505859375 Z" />
                </g>
                <g style="stroke-linecap:butt;stroke-miterlimit:4"
                    transform="matrix(1,0,0,1,-30,-50)">
                    <path style="fill:none"
                        d="M192.6341552734375 422.3505859375 C192.6341552734375 430.43280029296875 186.08221435546875 436.9847412109375 178 436.9847412109375 C169.91778564453125 436.9847412109375 163.36585998535156 430.43280029296875 163.36585998535156 422.3505859375 C163.36585998535156 414.26837158203125 169.91778564453125 407.7164306640625 178 407.7164306640625 C186.08221435546875 407.7164306640625 192.6341552734375 414.26837158203125 192.6341552734375 422.3505859375 Z" />
                </g>
                <g style="stroke-linecap:butt;stroke-miterlimit:4"
                    transform="matrix(1,0,0,1,-30,-50)">
                    <path style="fill:none"
                        d="M189.7073211669922 422.3505859375 C189.7073211669922 428.81634521484375 184.4657745361328 434.0578918457031 178 434.0578918457031 C171.5342254638672 434.0578918457031 166.2926788330078 428.81634521484375 166.2926788330078 422.3505859375 C166.2926788330078 415.88482666015625 171.5342254638672 410.6432800292969 178 410.6432800292969 C184.4657745361328 410.6432800292969 189.7073211669922 415.88482666015625 189.7073211669922 422.3505859375 Z" />
                </g>
                <g
                    transform="matrix(1,0,0,1,-8.213032722473145,-16.072585105895996)">
                    <path style="stroke:none"
                        d="M156.21302795410156 379.11322021484375 L152.83514404296875 384.0827331542969 L146.92385864257812 384.0827331542969 L149.87950134277344 388.4310607910156 L146.92385864257812 392.7793884277344 L152.83514404296875 392.7793884277344 L156.21302795410156 397.7489013671875 L159.78579711914062 392.7793884277344 L165.50221252441406 392.7793884277344 L162.54656982421875 388.4310607910156 L165.50221252441406 384.0827331542969 L159.59091186523438 384.0827331542969 L156.21302795410156 379.11322021484375 Z" />
                </g>
                <g
                    transform="matrix(1,0,0,1,-8.213032722473145,-16.072585105895996)">
                    <path style="fill:none"
                        d="M156.21302795410156 379.11322021484375 L152.83514404296875 384.0827331542969 L146.92385864257812 384.0827331542969 L149.87950134277344 388.4310607910156 L146.92385864257812 392.7793884277344 L152.83514404296875 392.7793884277344 L156.21302795410156 397.7489013671875 L159.78579711914062 392.7793884277344 L165.50221252441406 392.7793884277344 L162.54656982421875 388.4310607910156 L165.50221252441406 384.0827331542969 L159.59091186523438 384.0827331542969 L156.21302795410156 379.11322021484375 Z" />
                </g>
            </g>

[EMAIL PROTECTED] wrote:
Hi Nazar,

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

  
Well, that is the way I continued investigation yesterday. The answer I 
had found was that not every SVGLocatable.getBBox returns valid value. 
For most of elements it returned null. However some of the elements had 
reasonable values.
    

  
Sample output (excerpt)
+org.apache.batik.dom.svg.SVGOMGElement
+org.apache.batik.dom.svg.SVGOMRectElement
+org.apache.batik.dom.svg.SVGOMGElement
+org.apache.batik.dom.svg.SVGOMPathElement
-org.apache.batik.dom.svg.SVGOMPathElement
-org.apache.batik.dom.svg.SVGOMRectElement
-org.apache.batik.dom.svg.SVGOMGElement

What is the reason that the element has no boundingBox?
    

   As I said if the element is not in the rendering tree,
because it's in a '<defs>' element or under and element
with 'display="none"' or under an element that is not
part of the SVG display tree (most often an element from
a different namespace).  Then it will not have a BBox
since it is not in the rendering tree.

   If you can post a sample SVG document and identify a 
few of elements that are giving you problems we can
probably identify exactly why you aren't getting a BBox.

  
Pepping, Florian wrote:
    
Hi Nazer,

mhhh, that's strange. As Thomas said, that's the way it should 
      
normally
  
work and my code looks very similiar to yours and it works.
Perhaps you can do one more thing. Test, if the node you are looking 
      
for
  
is an instance of SVGLocatable [if (node instanceof SVGLocatable) 
      
{...}]
  
Only if this is true, you can get the BoundingBox of this element.

If this also doesn't work, make a very simple example and test it 
      
there
  
first. Perhaps you can get closer to the problem then.

Florian


-----Original Message-----
From: Nazar Stasiv (Lohika, Inc) [mailto:[EMAIL PROTECTED]] 
Sent: Monday, August 14, 2006 5:47 PM
To: [email protected]
Subject: Re: SVGOMGElement and coordinates?

Florian,

I get null here for return value

    public static SVGRect getSVGRect(SVGLocatable e){
        return e.getBBox(); //<-- returns null.
    }

And initialization I do with the code below

    public static SVGDocument parseSvg(String uri)  {
        UserAgent userAgent = new UserAgentAdapter();
        DocumentLoader loader = new DocumentLoader(userAgent);
        SVGDocument doc;
        try {
            doc = (SVGDocument) loader.loadDocument(uri);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
        BridgeContext ctx = new BridgeContext(userAgent, loader);
        ctx.setDynamicState(BridgeContext.DYNAMIC);
        GVTBuilder builder = new GVTBuilder();
        GraphicsNode rootGN = builder.build(ctx, doc);
        loader.dispose();
        return doc;
    }
Everything goes fine (no exceptions in parseSvg(String)) untill 
getSVGRect is called. Please help.

Pepping, Florian wrote:

      
Hi Nazer,

I think I had the same problem some time ago. Before you can use
getBBox() you have to build the GVT-Tree in order to get this
information.
You can do this in the following way:
           SVGDocument svgDoc =
(SVGDocument)loader.loadDocument(file.toURL().toString());
           loader.dispose();
        BridgeContext ctx = new BridgeContext(userAgent,
loader);
           ctx.setDynamicState(BridgeContext.DYNAMIC);
           GVTBuilder     builder = new GVTBuilder();
            builder.build(ctx, svgDoc);

        // use getBBox() afterwards

After this, SVGLocatable.getBBox() shouldn't return null any longer.

Florian

-----Original Message-----
From: Nazar Stasiv (Lohika, Inc) [mailto:[EMAIL PROTECTED]] 
Sent: Monday, August 14, 2006 3:16 PM
To: [email protected]
Subject: Re: SVGOMGElement and coordinates?


SVGLocatable.getBBox(elem) returns null No javadoc comments are there

        
to

      
unveil the reason of such behaviour

Is there the other way to get coordinates of SVGOMGElement ?


[EMAIL PROTECTED] wrote:


        
Hi Nazer,

"Nazar Stasiv (Lohika, Inc)" <[EMAIL PROTECTED]> wrote on 
          
08/14/2006
  
      
07:29:19 AM:




          
I use batik to operate SVG at runtime. 

The question is how can I get SVGOMGElement coordinates when 
            
walking
  
            
DOM


        
tree of the SVG document?



            
   You should look at the SVG DOM.  In particular the 'getBBox'


          
method.


        
There are also methods get 'getIntersectionList' that could be

          
useful.

      
          
The reason I'm asking such a thing it that requirements are to


            
display


        
info popup near named elements of SVG. If I had coordinates of such


            
an


        
element I could use DOM to add new element to the tree with 
            
computed
  
coordinates for correct positioning of the info popup.



            
   This is typically done with mouse over/out event handlers.  This 
allows you to receive a DOM event when the mouse enters/exits a


          
particular


        
element or group in the SVG document.  If you need the sensitive 
          
area
  
          
to


        
be larger than the rendered area you can add a hidden element
(visibility="hidden" pointer-events="fill") that can cover the


          
expanded


        
area and tie your event handler to that.



          
---------------------------------------------------------------------
  
To unsubscribe, e-mail:

          
[EMAIL PROTECTED]

      
For additional commands, e-mail:


          
[EMAIL PROTECTED]


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

        
[EMAIL PROTECTED]

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

        
[EMAIL PROTECTED]

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

    


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


  

Reply via email to