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 Maik Schürer proveo GmbH <Ma...@proveo.de> on 2004/11/02 18:57:30 UTC

bounding box exception

after getBBox() from a SVGOMGElement and calling bbox.getWidth() e.g. I get
following exception:
java.lang.NullPointerException
 at org.apache.batik.dom.svg.SVGLocatableSupport$1.getX(Unknown Source)
but the bbox itself isn't null
what means 'Unknown Source' ?
Thanks in advance
Maik


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: bounding box exception

Posted by Cameron McCormack <ca...@aka.mcc.id.au>.
Maik Schrer  proveo GmbH:
> yes, it is a static document
> but why I can not get a bounding box of an element when it comes from static
> document ?

Normally, if you do not have any Java code that will manipulate the SVG
in your JSVGComponent, references to the Java 2D objects which are used
for drawing (and hence their geometry) are not kept.  If the document
has no script element or event attributes (and a couple of other cases),
then the document by itself will have no need to keep around these
objects.

But if you use some Java code to manipulate the SVG, it may well need to
keep the objects to allow, for example, bounding box calculations.
Since the JSVGComponent doesn't know if it will be used in this way or
not (unless there are script elements, or event attributes, or ...), it
has the setDocumentState method so that you can tell it to allow such
dynamic interactions to be possible.

Cameron

-- 
Cameron McCormack
|  Web: http://mcc.id.au/
|  ICQ: 26955922

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: bounding box exception

Posted by Maik Schürer proveo GmbH <Ma...@proveo.de>.
Thanks Cameron (and Tonny),
yes, it is a static document
but why I can not get a bounding box of an element when it comes from static
document ?
Maik
----- Original Message ----- 
From: "Cameron McCormack" <ca...@aka.mcc.id.au>
To: "Batik Users" <ba...@xml.apache.org>
Sent: Tuesday, November 02, 2004 11:53 PM
Subject: Re: bounding box exception


> Hi Maik.
>
> Maik Schrer  proveo GmbH:
> > after getBBox() from a SVGOMGElement and calling bbox.getWidth() e.g. I
get
> > following exception:
> > java.lang.NullPointerException
> >  at org.apache.batik.dom.svg.SVGLocatableSupport$1.getX(Unknown Source)
> > but the bbox itself isn't null
> > what means 'Unknown Source' ?
>
> As Tonny said, "Unknown Source" means that you don't have debugging
> information compiled in.  But as to the actual problem: it sounds like
> you are trying to get the bounding box but the document is running in
> "static" mode (i.e., extra information about the document to allow
> scripting and Java interaction hasn't been held around).
>
> If you are using a JSVGComponent to display your SVG, call
>
>   myJSVGComponent.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC);
>
> before loading your SVG document into it.
>
> Cameron
>
> -- 
> Cameron McCormack
> |  Web: http://mcc.id.au/
> |  ICQ: 26955922
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: bounding box exception

Posted by Cameron McCormack <ca...@aka.mcc.id.au>.
Hi Maik.

Maik Schrer  proveo GmbH:
> after getBBox() from a SVGOMGElement and calling bbox.getWidth() e.g. I get
> following exception:
> java.lang.NullPointerException
>  at org.apache.batik.dom.svg.SVGLocatableSupport$1.getX(Unknown Source)
> but the bbox itself isn't null
> what means 'Unknown Source' ?

As Tonny said, "Unknown Source" means that you don't have debugging
information compiled in.  But as to the actual problem: it sounds like
you are trying to get the bounding box but the document is running in
"static" mode (i.e., extra information about the document to allow
scripting and Java interaction hasn't been held around).

If you are using a JSVGComponent to display your SVG, call

  myJSVGComponent.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC);

before loading your SVG document into it.

Cameron

-- 
Cameron McCormack
|  Web: http://mcc.id.au/
|  ICQ: 26955922

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: bounding box exception

Posted by Tonny Kohar <to...@kiyut.com>.
Hi,

> java.lang.NullPointerException
>  at org.apache.batik.dom.svg.SVGLocatableSupport$1.getX(Unknown Source)
> but the bbox itself isn't null
> what means 'Unknown Source' ?

If I am not wrong, I think "unknown source" mean you compile batik
without debuging info enabled, so it doesn't know the line number where
the NullPointerException occur. 

Regards
Tonny Kohar
-- 
Sketsa 
SVG Graphics Editor
http://www.kiyut.com



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org