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 Vitaly Hryb <vi...@gmail.com> on 2008/11/05 16:37:19 UTC
getBounds return null ...
Hi,
GraphicsNode.getBounds() returns null when it has "visibility='hidden'",
but why such node participate in calculation of getBounds for parent
(CompositeGraphicsNode) if such graphics node represent text SVG node?
Best regards Vitali.
Re: Re: getBounds return null ...
Posted by Vitaly Hryb <vi...@gmail.com>.
Thanks Thomas. All right, it works as described ...
Re: getBounds return null ...
Posted by th...@kodak.com.
Hi Vitaly,
"Vitaly Hryb" <vi...@gmail.com> wrote on 11/05/2008 10:37:19 AM:
> GraphicsNode.getBounds() returns null when it has "visibility='hidden'",
It doesn't do that for me. When visiblity is hidden it should return
good bounds. If display=none then it will have no bounds.
> but why such node participate in calculation of getBounds for parent
> (CompositeGraphicsNode) if such graphics node represent text SVG node?
A node that is only hidden should participate in the bounds calculation
for it's parent. A node that has display none will not even appear in
the GVT tree and hence will not contribute to it's parent's bounds calc.
See the following sample file:
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="800" height="600" viewBox="0 0 800 600"
onload="showBounds('t1'); showBounds('t2'); showBounds('t3');
showBounds('testG'); dynChange()">
<script type="text/ecmascript"><![CDATA[
var SVG_NS = "http://www.w3.org/2000/svg";
var nullY = 20;
function showBounds(id) {
var root = document.getRootElement()
var e = root.getElementById(id);
var bbox = e.getBBox();
var te = document.createElementNS(SVG_NS, "text");
te.setAttributeNS(null, "id", "tag_"+id);
var str;
if (bbox != null) {
te.setAttributeNS(null, "x", bbox.x+5);
te.setAttributeNS(null, "y", bbox.y+bbox.height+18);
str = (id + ": " + bbox.x + "," + bbox.y + " " +
bbox.width + "x" + bbox.height);
} else {
te.setAttributeNS(null, "x", 10);
te.setAttributeNS(null, "y", nullY);
nullY += 20;
str = (id + ": " + null);
}
te.appendChild(document.createTextNode(str));
root.appendChild(te);
}
function dynChange() {
var root = document.getRootElement()
root.getElementById("dt2").setAttributeNS(null, "visibility",
"hidden");
root.getElementById("dt3").setAttributeNS(null, "display", "none");
showBounds("testG2");
}
]]></script>
<g font-weight="bold">
<text id="t1" x="50" y="50">Test1</text>
<text id="t2" x="50" y="80" visibility="hidden">Test2</text>
<text id="t3" x="50" y="110" display="none">Test3</text>
</g>
<g id="testG" font-weight="bold">
<text x="350" y="50">test2-1</text>
<text x="350" y="80" visibility="hidden">test2-2</text>
<text x="350" y="110" display="none">test2-3</text>
</g>
<g id="testG2" font-weight="bold">
<text id="dt1" x="50" y="250">test3-1</text>
<text id="dt2" x="50" y="280">test3-2</text>
<text id="dt3" x="50" y="310">test3-3</text>
</g>
</svg>