Hi Justin,

jtd <[EMAIL PROTECTED]> wrote on 04/25/2008 08:03:48 AM:

> Thank Helder, that's very helpful, except getBBox doesn't seem to be an
> available method.
> 
> Here's a snippet of my code (this is in Java, using Batik)
> 
>        NodeList nl = document.getElementsByTagName("path");

    This probably won't work since the Batik DOM is namespace
aware. So this should be:

           NodeList nl = document.getElementBtTagNameNS
                (SVGConstants.SVG_NAMESPACE_URI, "path");

>        for(int i = 1; i < nl.getLength(); i++){ 
>           Element elem = (Element) nl.item(i);

            getBBox is defined on the SVGLocatable interface.
All of the SVG shape elements (and a number of other elements) 
implement that interface.  You should be able to simply replace
'Element' with 'SVGLocatable' (or you can go to the SVGPathElement
interface which extends locatable).

> I thought I'd be able to call getBBox on the Element here. Sorry for the
> simple question, but I'm new to this and I can't seem to get my head 
around
> the Batik docs yet.

     I should probably also warn you that you need to make sure you have 
booted the
SVG DOM in Batik before you try and call that:
        http://wiki.apache.org/xmlgraphics-batik/BootSvgAndCssDom


> Helder Magalhães wrote:
> > 
> >>  I've been playing around with a little demo program I found 
somewhere.
> >> I'm
> >>  able to go load an SVG document and script some animations by 
travers,
> >> ing the
> >>  DOM and translating, rotating. I'd like to be able to move the 
elements
> >> to
> >>  specific locations by setting x and y coordinates, but the elements 
are
> >> all
> >>  Paths. How do I get attributes like position, bounding box from a 
Path
> >>  element?
> > Yes, bounding box [1] is probably what you are looking for.
> > 
> >>  I am able only able to translate relative to their current position 
on
> >> the
> >>  canvas, and I'm not seeing how to access that position.
> > Using bonding box you can obtain the initial position which may then
> > be used during calculation of final position. In case you simply want
> > to perform transformations relative to current position, transform [2]
> > (translate, for example) seems more appropriate.
> > 
> > Finally, if asking general SVG questions not directly related with
> > Batik, I advise you try the SVG developers group [3] instead for more
> > visibility.
> > 
> > Hope this helps,
> > 
> >  Helder Magalhães
> > 
> > [1] http://wiki.svg.org/GetBBox
> > [2] http://www.w3.org/TR/SVG/coords.html#TransformAttribute
> > [3] http://tech.groups.yahoo.com/group/svg-developers/
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: 
[EMAIL PROTECTED]
> > 
> > 
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/Get-X-%2B-Y-of-
> Path-element--tp16872215p16895128.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

Reply via email to