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