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 "Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> on 2005/12/01 16:58:07 UTC

Drag and drop breaks with a JSVGScrollPane?

I added a JSVGScrollPane around my JSVGCanvas.  Now I'm getting random
NPEs when dragging an element around the canvas.  This looks
thread-related, but my drag and drop code hasn't changed.  I'm updating
the document in the JSVGCanvas's UpdateManager with a Runnable.  Here's
the stack trace:

 

java.lang.NullPointerException

        at org.apache.batik.swing.JSVGScrollPane.getViewBoxRect(Unknown
Source)

        at
org.apache.batik.swing.JSVGScrollPane$ScrollListener.updateCompleted(Unk
nown Source)

        at org.apache.batik.swing.svg.JSVGComponent$12.run(Unknown
Source)

        at
java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)

        at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)

        at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThrea
d.java:201)

        at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.
java:151)

        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)

        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)

        at
java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

 

Is there something else I need to manage when I have a JSVGScrollPane?
I just wanted to be able to scroll around the canvas when I'm zoomed in.
All I did was wrap the JSVGCanvas in the JSVGScrollPane.  Oddly enough,
this error occurs if I don't even add the JSVGScrollPane to the
application.  As long as I call its constructor with the JSVGCanvas as
the parameter, the error happens.

 

Michael Bishop


Re: Drag and drop breaks with a JSVGScrollPane?

Posted by th...@kodak.com.
Hi Michael,

"Bishop, Michael W. CONTR J9C880" <Mi...@je.jfcom.mil> wrote on 
12/01/2005 10:58:07 AM:

> I added a JSVGScrollPane around my JSVGCanvas.  Now I’m getting random 
NPEs 
> when dragging an element around the canvas.  This looks thread-related, 
but my
> drag and drop code hasn’t changed.  I’m updating the document in the 
> JSVGCanvas’s UpdateManager with a Runnable.  Here’s the stack trace:

   This looks like a bug in the JSVGScrollPane (it's looking at GVT stuff
outside of the update manager thread).  The fix is pretty simple however,
add a viewBox attribute to the root SVG element.  This is a good idea 
anyways.

   The problem is that if there is no viewbox the canvas tries to be
nice and look at the actual bounds of the GraphicsNode and use that
instead.  The problem is that unless it does that in the UpdateManager
thread your code could have invalidated the bounds information at the
same time - in which case it just returns a null BBox.

   Probably the 'right' thing to do is for the canvas to 'cache' the
bounds of the GVT tree for each rendering/update - then the scroll pane
can just get that.  I get nervous about adding invokeAndWait calls 
in the ScrollPane as it may cause lots of people to have lock ups.

> Is there something else I need to manage when I have a JSVGScrollPane? I 
just
> wanted to be able to scroll around the canvas when I’m zoomed in.  All I 
did 
> was wrap the JSVGCanvas in the JSVGScrollPane.  Oddly enough, this error 

> occurs if I don’t even add the JSVGScrollPane to the application.  As 
long as 
> I call its constructor with the JSVGCanvas as the parameter, the error 
happens.

   Yes, when the JSVGScrollPane is constructed it attaches it's self to 
the
update callbacks of the canvas so it can keep the scrollbars in sync 
(really
all the scroll pane does is offer visual feedback and manipulation of the
existing scrolling support in the canvas).