You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Thomas DeWeese <Th...@Kodak.com> on 2005/04/12 11:23:48 UTC
Re: I want to get the Graphic node associated to a node
Hi Bader,
bader houmad wrote:
> I have a problem.
> I want to get the Graphic node associated to a Node:
>
> org.w3c.dom.Element e = (org.w3c.dom.Element)
> myCanvas.getSVGDocument().getDocumentElement().getFirstChild();
> Rectangle2D rect =
> myCanvas.getBridgeContext().getGraphicsNode(e).getBounds();
>
> but here the graphics node returned is null. (nullpointer exception)
> e is not null and the bridge context is valid.
Do you know what 'e' actually is? It is quite common
for the first child of the document element to be a
TextNode (white space between elements) or any of 'defs', 'style',
'title', 'desc', 'script', ....
None of which have a GraphicsNode since they don't draw anything.
Also was the document loaded with the document state set to
ALWAYS_DYNAMIC or ALWAYS_INTERACTIVE? If it wasn't then the
BridgeContext doesn't bother to build the element/GraphicsNode
mapping.
HTH
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org