xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ansgar Radermacher <ansgar.radermac...@cea.fr>
Subject getValue fails with NPE on obtained width
Date Tue, 22 Aug 2017 11:46:47 GMT
Dear all,

we have the following bug in in Papyrus

*Bug 521232* <https://bugs.eclipse.org/bugs/show_bug.cgi?id=521232> 
-[All diagrams] NPE if SVG unit is not in pixels

This bug is caused by calling getValue() in the following way 
(simplified to ease explanation)

SVGSVGElement svgRoot = svgDocument.getRootElement();
SVGAnimatedLength width = svgRoot.getWidth();
SVGLength baseWidth = width.getBaseVal();
if (baseWidth != null) {
    svgWidth = baseWidth.getValue();   // NPE occurs here

The NPE during the call of getValue occurs, if the svgRoot above belongs 
to an SVG file created with inkscape and units are in mm (default in 
Europe). A sample file can be downloaded from the Papyrus forum, see 

Thread [main] (Suspended (exception NullPointerException))
     AbstractSVGLength$DefaultContext.getPixelUnitToMillimeter() line: 
not available [local variables unavailable]
     UnitProcessor.svgToUserSpace(float, short, short, 
UnitProcessor$Context) line: not available
line: not available [local variables unavailable]
line: 212

value of baseWidth in case of error.
AbstractSVGAnimatedLength$BaseSVGLength  (id=1092)
     unitType    1
     valid    false
     value    0.0

Yet the code works, if getValueInSpecifiedUnits() instead of getValue() 
is used. Thus, my question is: do we use batik in a wrong way, 
e.g.should be always getValueInSpecifiedUnits or is this a bug in batik 
which we should report?

Best regards


PS: The SVG tag flowRoot seems to be non-supported. Since that is a 
different issue, I will create a separate post.


Ansgar Radermacher                CEA/DRT/DILS/LISE
phone: +33 16908 3812
mailto: ansgar.radermacher@cea.fr

View raw message