Bug 35922 - SVG rendering is offset and/or missing.
Summary: SVG rendering is offset and/or missing.
Alias: None
Product: Batik - Now in Jira
Classification: Unclassified
Component: SVG Viewer (show other bugs)
Version: 1.5
Hardware: Other Windows 2000
: P2 major
Target Milestone: ---
Assignee: Batik Developer's Mailing list
Depends on:
Reported: 2005-07-28 21:28 UTC by Doug Van Watermulen
Modified: 2005-08-04 10:25 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Doug Van Watermulen 2005-07-28 21:28:30 UTC
We are using Batik 1.6. Our Java application GUI uses mutliple JSVGCanvas 
components to render various SVG's to help our users. Depending on the panel 
that is being displayed, about 2-8 JSVGCanvas components are displayed. During 
the display of these SVG's we are seeing some of the SVGs render offset from 
the upper left hand corner. In some cases resizing the panel that the SVG is in 
causes the SVG to render properly. Other times no amount of resizing/repainting 
will cause the SVG to display properly. It's almost like the SVG canvas is 
caching bad coordinates and doesn't release them, even on the resize. We can 
reproduce this problem consistently with our application but do have test 

We have spordically seen a similiar or maybe the same problem where the SVG 
does not appear to render on the JSVGCanvas. Not sure if the image is rendering 
but outside the viewport of the panel so that it does not display at all.

Our temporary workaround, is to first display a 'loading' SVG and then display 
the real SVG in the canvas. This seems to always work but it's not very 

Our application instaniates the JSVGCanvas, does a setURI(..), and then adds 
the panel to a parent panel that is then displayed. This takes place multiple 
times depending on the number of SVG's being displayed.
Comment 1 Thomas Deweese 2005-08-04 01:15:33 UTC
I suspect the base of the problem is that you set the URI before
you add it to the SWING hierarchy.  Before the component is part
of the Swing tree it has no size so Batik has to make one up this
then changes at some point when you add it to the SWING tree.

Also do you make sure to do all this instantiation from the Swing
Comment 2 Doug Van Watermulen 2005-08-04 18:25:08 UTC
Yes, we are setting the URI before the viewer is added to the Swing hierarchy. 
Yes, all of our instantiation is from the Swing thread. 

We are using the JSVGCanvas like an image viewer panel but instead of 
displaying JPEGs we display SVGs which can be zoomed(an important advantage). A 
single panel may contain 3 or 4 SVGs which it knows it wants to display so it 
does the setGraphicURI using constants, that do not change, and which we would 
like to set once and in most cases be done with it. 

It makes sense that Batik would make up a size to start with and then change 
the SVG size when a resize event occurs. It seems that the heart of the problem 
is that when resizing does occur Batik displays the SVG offset, which is wrong. 
In some cases, no amount of resizing will cause Batik to display properly. 

Given our usage, shouldn’t resize events cause Batik to display properly?