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
<[email protected]>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 <[email protected]> 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
>>
>
>

Reply via email to