Hi Nazar,

"Nazar Stasiv (Lohika, Inc)" <[EMAIL PROTECTED]> wrote on 08/14/2006 
09:55:27 AM:

> No I don't use JSVGCanvas. My application is using servlets. Basically I 

> construct SVGDocument from file and while visiting elements of its DOM 
> tree I need a coordinate of the element for later use
> 
> To boot SVG DOM you mean a code like this ?

   Close but for correct results you need to build it from the root
of the SVG tree (just like the Wiki page).  You should also only do 
this once for the whole document right after loading it (not for 
each element).

>     public static Rectangle2D getBounds2D(Element e) {
>         UserAgent userAgent = new UserAgentAdapter();
>         DocumentLoader loader = new DocumentLoader(userAgent);
>         BridgeContext ctx = new BridgeContext(userAgent, loader);
>         ctx.setDynamicState(BridgeContext.DYNAMIC);
>         GVTBuilder builder = new GVTBuilder();
>         GraphicsNode rootGN = builder.build(ctx, e);
>         return rootGN.getBounds();
> 
>     }
> Note: when visiting an element it is already of type SVGOMGElement, 
> hence there no need to boot SVG DOM or am I wrong?

   You need to boot the SVG DOM in all cases, if you want to use it.

> If you look at my code at line last but one, rootGN = builder.build(ctx, 

> e); it assigns null to rootGN.

   Right you need to build from root of Document.

> 
> 
> 
> [EMAIL PROTECTED] wrote:
> > Hi Nazar,
> >
> > "Nazar Stasiv (Lohika, Inc)" <[EMAIL PROTECTED]> wrote on 08/14/2006 
> > 09:16:01 AM:
> >
> > 
> >> 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 ?
> >> 
> >
> >     How are you using the Document?  Is it in the JSVGCanvas?
> > Are you trying to call this method before loading the document?
> >
> >     For these methods to work you need to boot the SVG DOM.
> > This normally happens when you load the document in the Canvas
> > (you may need to set document state to ALWAYS_DYNAMIC on the
> > canvas before loading the document if there are no obvious dynamic 
> > features of the document).
> >
> >     If you are trying to use these features outside of the
> > JSVGCanvas check the Batik wiki for how to bring up the SVG DOM:
> >
> > http://wiki.apache.org/xmlgraphics-batik/BootSvgAndCssDom
> >
> > 
> >> [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]

Reply via email to