thank's it works now FYI, I have fixed the symbol aspect ratio using preserveaspectratio:
<symbol id="SelectionMask" viewBox="-100.408 -99.377 200.815 198.754" preserveAspectRatio="none"> <path style="fill:#66CCFF;fill-opacity:0.33;stroke:#336699;stroke-width:7;" d="M96.908-83.877c0-6.627-5.373-12-12-12H-84.908 c-6.627,0-12,5.373-12,12V83.877c0,6.627,5.373,12,12,12H84.908c6.627,0,12-5.373,12-12V-83.877z"/> </symbol> On Mon, Dec 21, 2009 at 11:34 PM, jonathan wood <jonathanshaww...@gmail.com>wrote: > See inlined responses below > > On Mon, Dec 21, 2009 at 5:18 PM, dao <dao.ho...@gmail.com> wrote: > >> 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;"/> >> >> > > This <use> tag contains both an explicit x, y (-150,-200) and a transform, > you'll need to account for both in the rectangles positioning. > > > >> 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. >> >> > From the spec...hoping it helps... > > *If the 'use' element references a 'symbol' element: > > In the generated content, the 'use' will be replaced by 'g', where all > attributes from the 'use' element except > for x, y, width, height and xlink:href are transferred to the generated 'g' > element. An additional > transformation translate(x,y) is appended to the end (i.e., right-side) of > the transform attribute on the > generated 'g', where x and y represent the values of the x and y attributes > on the 'use' element. The > referenced 'symbol' and its contents are deep-cloned into the generated > tree, with the exception that the > 'symbol' is replaced by an 'svg'. This generated 'svg' will always have > explicit values for attributes width > and height. If attributes width and/or height are provided on the 'use' > element, then these attributes will be > transferred to the generated 'svg'. If attributes width and/or height are > not specified, the generated 'svg' > element will use values of 100% for these attributes.* > > > >> the targeted node could be a text, that's why my first posted you answered >> with the bbox and the SVGLocatable. >> >> > The SVGLocatable/bbox method should work ok for any Element. > > >> >> 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 >> > > -- Dao Hodac