Tjorven Lauchardt wrote:
Hello,
I am creating a application with Batik and I have the following problem.
I am buidling a DOM Tree and I want to know the bounding box of the
text-Elements while I am building the DOM. I need that information,
because I want to create a fitting rect as a background for every
Text-Element and for other layout-reasons.
Can you help me? I already searched in the mail-archive, but didn't find
a solution for my problem.
Here is my code:
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
SVGOMDocument doc = (SVGOMDocument)impl.createDocument(svgNS, "svg", null);
Element text = doc.createElementNS(svgNS,"text");
Text textNode = doc.createTextNode("a text");
text.appendChild(textNode);
// here I want to know the bounding box
Is it possible?
Yes, but you need to build this with the associated
GVT tree. Here you have two options.
1) Build it as a 'dynamic' document so as you
append elements it will automatically build
the rendering tree version and the geometric
information will be immediately available.
2) Build the whole 'basic' document first then
build the rendering tree as a whole and make
a second pass through the DOM creating the
rectangles.
#2 is faster but #1 is probably simpler code.
To find out how to build the associated rendering tree
(GVT) you should look at the slideshow application.
(batik.app.slideshow).
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]