In order to get an instance of the GVT Tree, you need to assign a listener to a JSVGComponent, that will notify you when the GVT Tree is built. At this stage, you can walk the tree until you find the Component you are looking for.

As an example, look at the following code:

svg = new JSVGComponent();
svg.addSVGDocumentLoaderListener(new SVGDocumentLoaderAdapter() {
public void documentLoadingStarted(SVGDocumentLoaderEvent e) {
}
public void documentLoadingCompleted(SVGDocumentLoaderEvent e) {
//System.out.println("SaveAsDXF-ExportCache succesfully loaded");
}
});


///////////////////////// RELEVANT PART STARTS HERE //////////////////////////
svg.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
public void gvtBuildStarted(GVTTreeBuilderEvent e) {
//System.out.println("SaveAsDXF-ExportCache-GVTBuilder Starting.....");
}
public void gvtBuildCompleted(GVTTreeBuilderEvent e) {
//System.out.println("SaveAsDXF-ExportCache succesfully GVT built");


GVTTreeWalker tw = new GVTTreeWalker(e.getGVTRoot());
GraphicsNode node = tw.firstChild();
while (node != null) {
if (node instanceof org.apache.batik.gvt.YOUR_ELEMENT_HERE)) {
//////////////////////////WHATEVER YOU WANT TO DO WITH YOUR NODE /////////////
}
node = tw.nextGraphicsNode();
}
}
});





On Feb 1, 2005, at 9:36 AM, James Shaw wrote:

Thomas DeWeese wrote:


James Shaw wrote:

I am loading an SVG file containing an embedded font (and nothing else) as an SVGDocument.
I wish to obtain bounding boxes for glyphs in the embedded font, without actually inserting that glyph in the DOM.


What is the best way to obtain this data?


Insert the glyph into the DOM (set visibility to hidden or even
just insert and then remove it before your script returns).

Visibility shouldn't be a problem since I'm not actually displaying the document.


If you really want to muck with Batik internals there are other ways
but AFAIK there are no SVG DOM methods for the glyph elements
that provide this functionality.

Looking at the API docs, I'm trying to get hold of an instance of org.apache.batik.gvt.font.Glyph,
then invoke its getBounds2D object. However, I have yet to find a way of obtaining a handle to
the GVT.


Cheers,
James Shaw

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to