oups, I have grabbed the transform attribute, and now, my rect is the right size, but its bottom left is at the center of the node.
My node is like this: <use xlink:href="#Horizon" width="300" height="400" x="-150" y="-200" transform="matrix(0.6881 0 0 -0.6881 142.5107 299.9995)" style= "overflow:visible;"/> Furthermore, I am trying to replace the rect by a symbol reference. I cannot succeed in modifying its aspect ratio. is there an attribute to authorize this? To be more clear, I have drawn a nice rounded rectangle with half opacity and decorations that I want to draw on top of the targeted node (here horizon) with the same size. the targeted node could be a text, that's why my first posted you answered with the bbox and the SVGLocatable. On Mon, Dec 21, 2009 at 11:01 PM, jonathan wood <jonathanshaww...@gmail.com>wrote: > > The example uses direct setting of the x, y coordinates. Your example text > node has a transform attribute. You will likely need to transform the > background rectangle also. > > > > > On Mon, Dec 21, 2009 at 4:49 PM, dao <dao.ho...@gmail.com> wrote: > >> that quick!! >> >> but the rect does not fits my locatable... it has not the right size and >> is stucked on the top left corner of my canvas... >> >> any idea? >> >> >> On Mon, Dec 21, 2009 at 9:44 PM, jonathan wood < >> jonathanshaww...@gmail.com> wrote: >> >>> Sorry for the very incomplete code clipping. This is from a test case I >>> sent to the list a few days ago...nabble, etc will likely yield the entire >>> file >>> >>> .....here is a better cut: >>> >>> >>> SVGRect bbox = >>> ((SVGLocatable)textNode).getBBox(); >>> >>> Element rect = >>> doc.getElementById("my-bg-rect"); >>> if (rect == null) { >>> rect = >>> doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, "rect"); >>> rect.setAttributeNS(null, "id", >>> "my-bg-rect"); >>> rect.setAttributeNS(null, "fill", >>> "#CCDDFF"); >>> rect.setAttributeNS(null, "stroke", >>> "#000000"); >>> rect.setAttributeNS(null, >>> "stroke-width", "3"); >>> } >>> >>> rect.setAttributeNS(null, "x", "" + >>> (bbox.getX() - 10) ); >>> rect.setAttributeNS(null, "y", "" + >>> (bbox.getY() - 10) ); >>> rect.setAttributeNS(null, "width", "" + >>> (bbox.getWidth() + 20) ); >>> rect.setAttributeNS(null, "height", "" + >>> (bbox.getHeight() + 20) ); >>> >>> doc.getDocumentElement().insertBefore(rect, textNode); >>> >>> >>> >>> >>> >>> On Mon, Dec 21, 2009 at 3:41 PM, jonathan wood < >>> jonathanshaww...@gmail.com> wrote: >>> >>>> SVGRect bbox = >>>> ((SVGLocatable)textNode).getBBox(); >>>> >>>> Element rect = >>>> doc.getElementById("my-bg-rect"); >>>> if (rect == null) { >>>> rect = >>>> doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, "rect"); >>>> rect.setAttributeNS(null, "id", >>>> "my-bg-rect"); >>>> rect.setAttributeNS(null, "fill", >>>> "#CCDDFF"); >>>> rect.setAttributeNS(null, "stroke", >>>> "#000000"); >>>> rect.setAttributeNS(null, >>>> "stroke-width", "3"); >>>> >>>> } >>>> >>>> >>>> On Mon, Dec 21, 2009 at 3:07 PM, dao <dao.ho...@gmail.com> wrote: >>>> >>>>> hello, >>>>> >>>>> I'd like to highlight a text element of my svg file: >>>>> >>>>> <text transform="matrix(1 0 0 1 433.8965 494.4141)" style="fill:#00FFFF; >>>>> font-family:'CourierNewPSMT'; font-size:24;">00.00</text> >>>>> >>>>> >>>>> I cannot see any way to set the background of a text, or to get the box >>>>> size to draw a rectangle around it. >>>>> >>>>> Do you know how I can do this? >>>>> >>>>> regards >>>>> >>>>> >>>>> -- >>>>> Dao Hodac >>>>> >>>> >>>> >>> >> >> >> -- >> Dao Hodac >> > > -- Dao Hodac