« Return to Thread: Repainting a JSVGCanvas

Re: Repainting a JSVGCanvas

by thomas.deweese :: Rate this Message:

Reply to Author | View in Thread


Hi Cameron, scorefande,


Cameron McCormack <cam@...> wrote on 05/31/2008 07:28:00 AM:

> Are these changes being made in the UpdateManager’s thread?  If not,
> then it might explain the problem.  See:

   Actually I think it's the JSVGScrollPane that is interacting
with the graphics tree outside of the UpdateManager's thread.
In particular updateCompleted is called in the Swing thread not
the update manager's thread.  However I don't think this is
really the source of the problem, but it might be good to
move at least all of the graphics node stuff in getViewBoxRect
into a runnable that we dispatch to the UpdateManager thread.

aaaa aaaa <scorefande@...> wrote on 05/30/2008 07:03:47 AM:

> I found out that when the Exception occurs "bounds" in the
> getViewBoxRect method is null. That's why it returns null.
>
> Rectangle2D bounds = gn.getBounds();

   This happens when a rendering is interrupted.  We should
handle this more gracefully.  I think the simplest thing
would be to simply protect all the callers of getViewBoxRect()
against a null return.  I've put this in SVN.

> Maybe this is part of the problem? What does getBounds() do?

   'getBounds' calculates the smallest rectangle that encloses
the contents of the graphics node it is called on.  In this
case it's trying to get the bounds of the document because
you haven't provided a viewBox attribute.  So your simplest
fix would be to provide a viewBox attribute on the outermost
SVG element.  This is really a better solution anyway as the
geometric bounds of the document is rarely the truly correct
document bounds (often documents have oversized 'background rects'
or they may want white space around the content, etc...).

 « Return to Thread: Repainting a JSVGCanvas