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...@jfcom.mil> on 2008/12/04 21:59:21 UTC

Bug with the use of the SVGMatrix class?

I've run into this problem before and I wanted to see if there's a better way to address it or if this should be filed as a bug.  Essentially what happens is that you can create an SVGMatrix from an SVGLocatable that hasn't been rendered and has no useful information.  Assume this happens before CSS and DOM are fully booted:
 
SVGLocatable locatable = (SVGLocatable) svgDocument.getDocumentElement();
SVGMatrix matrix = locatable.getScreenCTM();
 
The returned SVGMatrix object won't necessarily be null.  Unfortunately, attempting to use it will throw an NPE:
 
// This would be false.
boolean nullMatrix = matrix == null;
 
In order to "test" the SVGMatrix, I've had to resort to the following:
 
try {
   matrix.getA();
} catch (NullPointerException npEx) {
// Document must not be ready!
}
 
Basically the only exposed way to check the matrix is to try an accessor method which causes the NPE.  Is there a better way of handling this or should this be filed?  In contrast this would be null:
 
SVGRect boundingBox = locatable.getBBox();
 
// This would be true.
boolean nullBox = boundingBox == null;
 
Michael Bishop

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