deweese 2004/11/29 19:23:58
Modified: samples/solitaire/script util.js
samples/tests/spec/scripting rectResizeOnClick.svg
zeroSize.svg
samples/tests/spec12/text flowText.svg
sources/org/apache/batik/bridge
AbstractGraphicsNodeBridge.java
SVGUseElementBridge.java
sources/org/apache/batik/dom/svg SVGLocatableSupport.java
sources/org/apache/batik/ext/awt/geom SegmentList.java
sources/org/apache/batik/gvt CompositeGraphicsNode.java
ShapeNode.java
sources/org/apache/batik/gvt/flow LineInfo.java
sources/org/apache/batik/swing/gvt JGVTComponent.java
test-references/samples/tests/spec/scripting
text_content.png zeroSize.png
test-resources/org/apache/batik/test samplesRendering.xml
Added: samples/tests/spec/scripting bbox.svg
test-references/samples/tests/spec/scripting bbox.png
Log:
1) getBBox should now work per the specification.
a) fill="none" will still give bbox
b) It is now the tight bounds of the geometry
c) It does not include the stroke anymore.
d) When called on 'undisplayed' elements returns null (not sure
what the spec really says about this).
2) Modification of use element's width/height now works.
3) Some fixes for flowText with soft-hyphens and the like.
Revision Changes Path
1.3 +3 -1 xml-batik/samples/solitaire/script/util.js
Index: util.js
===================================================================
RCS file: /home/cvs/xml-batik/samples/solitaire/script/util.js,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- util.js 23 Oct 2004 17:11:03 -0000 1.2
+++ util.js 30 Nov 2004 03:23:57 -0000 1.3
@@ -52,7 +52,9 @@
if (elem.getScreenCTM)
return elem.getScreenCTM();
- if (elem == root) {
+ // This is to handle ASV 3.0, this depends on
+ // a number of bugs in the ASV implementation.
+ if (elem.currentScale) {
var scale = root.currentScale;
var trans = root.currentTranslate;
var ret = root.createSVGMatrix();
1.5 +2 -2
xml-batik/samples/tests/spec/scripting/rectResizeOnClick.svg
Index: rectResizeOnClick.svg
===================================================================
RCS file:
/home/cvs/xml-batik/samples/tests/spec/scripting/rectResizeOnClick.svg,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- rectResizeOnClick.svg 18 Aug 2004 07:12:05 -0000 1.4
+++ rectResizeOnClick.svg 30 Nov 2004 03:23:58 -0000 1.5
@@ -44,7 +44,7 @@
// This function is only called if test is run from regard.
function regardStart() {
setRect('targetRect', '5', '5', '440', '490');
- regardTestInstance.scriptDone();
+ setTimeout('regardTestInstance.scriptDone()', 100);
}
</script>
1.5 +3 -1 xml-batik/samples/tests/spec/scripting/zeroSize.svg
Index: zeroSize.svg
===================================================================
RCS file: /home/cvs/xml-batik/samples/tests/spec/scripting/zeroSize.svg,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- zeroSize.svg 8 Oct 2004 16:12:01 -0000 1.4
+++ zeroSize.svg 30 Nov 2004 03:23:58 -0000 1.5
@@ -74,6 +74,8 @@
if (!doShowBounds) return;
var bbox = shape.getBBox();
var elem;
+// System.err.println("XXX: [" + bbox.x + ", " +bbox.y + ", " +
+// bbox.width + ", " + bbox.height + "]");
if (bbox.width == 0) {
if (bbox.height == 0) {
elem = document.createElementNS(svgns, "circle");
1.1 xml-batik/samples/tests/spec/scripting/bbox.svg
Index: bbox.svg
===================================================================
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"
"http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd">
<!--
Copyright 2003 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- ======================================================================
-->
<!-- Test of getBBox interface for various elements with various property
-->
<!-- values (fill, stroke, visibility, display).
-->
<!--
-->
<!-- @author [EMAIL PROTECTED] -->
<!-- @version $Id: bbox.svg,v 1.1 2004/11/30 03:23:58 deweese Exp $ -->
<!-- ======================================================================
-->
<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>
<svg id="body" width="450" height="500" viewBox="0 0 450 500"
onload="start()">
<title>Test getBBox interface</title>
<text x="50%" y="45" class="title">Test getBBox interface</text>
<script type="text/ecmascript"><![CDATA[
var svgns = "http://www.w3.org/2000/svg";
var root;
var pref = new Array("n", "v", "d" );
var fillStroke = new Array("-", "f", "s", "fs" );
var elemT = new Array("p", "t", "u", "i" );
var xLoc = new Array(35, 115, 195, 275);
var yLoc = 10;
function start() {
root = document.getRootElement();
for (i=0; i<pref.length; i++) {
for (j=0; j<fillStroke.length; j++) {
for (k=0; k<elemT.length; k++) {
doBBox(pref[i]+fillStroke[j]+elemT[k], xLoc[k], yLoc);
}
}
}
updatePath("u-p");
updatePath("ufsp");
updateText("u-t");
updateText("ufst");
updateG("u-u");
updateG("ufsu");
updateImg("u-i");
updateImg("ufsi");
}
function updatePath(id) {
doBBox(id, xLoc[0], yLoc);
var elem = root.getElementById(id);
elem.setAttribute("d", "M 10,25 c 0,-40 60,20 60,-20z");
doBBox(id, xLoc[0], yLoc);
}
function updateText(id) {
doBBox(id, xLoc[1], yLoc);
var elem = root.getElementById(id);
var txt = document.createTextNode("getBBox");
elem.replaceChild(txt,elem.firstChild);
doBBox(id, xLoc[1], yLoc);
}
function updateG(id) {
doBBox(id, xLoc[2], yLoc);
var elem = root.getElementById(id);
var use = elem.firstChild;
use.setAttribute("x", "190");
use.setAttribute("y", "5");
use.setAttribute("width", "20");
use.setAttribute("height", "20");
doBBox(id, xLoc[1], yLoc);
}
function updateImg(id) {
doBBox(id, xLoc[2], yLoc);
var elem = root.getElementById(id);
elem.setAttribute("x", "261");
elem.setAttribute("y", "5");
elem.setAttribute("width", "43");
elem.setAttribute("height", "20");
doBBox(id, xLoc[1], yLoc);
}
function doBBox(id, locX, locY) {
var elem = root.getElementById(id);
var bbox;
if (elem) bbox = elem.getBBox();
var rect = document.createElementNS(svgns, "rect");
if (!bbox) {
// No BBox undisplayed etc... use small crimson rect.
rect.setAttribute("x", ""+locX);
rect.setAttribute("y", ""+locY);
rect.setAttribute("width", "10");
rect.setAttribute("height", "10");
rect.setAttribute("fill", "crimson");
} else {
rect.setAttribute("x", ""+bbox.x);
rect.setAttribute("y", ""+bbox.y);
rect.setAttribute("width", ""+bbox.width);
rect.setAttribute("height", ""+bbox.height);
rect.setAttribute("fill", "none");
rect.setAttribute("stroke", "black");
rect.setAttribute("stroke-width", "2");
rect.setAttribute("stroke-opacity", "0.5");
}
elem.getParentNode().getParentNode().appendChild(rect);
}
]]></script>
<defs>
<symbol id="Batik_Squiggle" viewBox="0 0 540 570">
<path id="Batik_Squiggle_Blue"
d="M172,44C137,60,31,135,11,199c-8,27,22,48,44,33
C14,306-1,332,0,356c0,14,13,42,44,27c8-4,35-25,52-41
c14-1,24-11,42-28c17,14,36,10,52-7c22,2,82-78,44-108
c-3-24-30-37-53-18c-6-2-13-1-18,1c22-35,43-82,49-105
C219,47,188,36,172,44z"/>
<path id="Batik_Squiggle_Red"
d="M400,0c-18,3-49,31-49,31c-29,23-43,58-28,95
c-13,14-29,44-29,67c0,28,20,52,50,29c7,8,21,16,37,5
c-5,29,3,48,26,49c1,10,13,31,36,17c16-10,58-39,79-56
c25-23,25-94-18-89c33-59-3-96-27-84c-10,4-46,25-52,30
c-1-7-5-12-11-14C436,45,436-5,401,0z"/>
<path id="Batik_Squiggle_Green"
d="M275,353c-46,12-88,43-114,91c-9,16,6,37,25,33
c-14,24-40,67-15,81c28,16,52-8,60-15c18,21,50,10,81-17
c41,14,68-2,103-53c8-12,30-43,30-65c0-16-15-30-35-21
c-1-12-9-38-53-19c-10-6-31-5-54,17
C308,375,300,347,275,353z"/>
</symbol>
</defs>
<g id="test-content" transform="translate(0, 60)" >
<g> <!-- The test grid -->
<g stroke="#000">
<rect x="10" y="0" width="20" height="120" fill="#eee"/>
<rect x="10" y="120" width="20" height="120" fill="#ddd"/>
<rect x="10" y="240" width="20" height="120" fill="#eee"/>
<rect x="10" y="360" width="20" height="60" fill="#ddd"/>
<rect x="30" y="0" width="410" height="30" fill="#f8f8f8"/>
<rect x="30" y="30" width="410" height="30" fill="#f0f0f0"/>
<rect x="30" y="60" width="410" height="30" fill="#f8f8f8"/>
<rect x="30" y="90" width="410" height="30" fill="#f0f0f0"/>
<rect x="30" y="120" width="410" height="30" fill="#e0e0e0"/>
<rect x="30" y="150" width="410" height="30" fill="#d0d0d0"/>
<rect x="30" y="180" width="410" height="30" fill="#e0e0e0"/>
<rect x="30" y="210" width="410" height="30" fill="#d0d0d0"/>
<rect x="30" y="240" width="410" height="30" fill="#f8f8f8"/>
<rect x="30" y="270" width="410" height="30" fill="#f0f0f0"/>
<rect x="30" y="300" width="410" height="30" fill="#f8f8f8"/>
<rect x="30" y="330" width="410" height="30" fill="#f0f0f0"/>
<rect x="30" y="360" width="410" height="30" fill="#e0e0e0"/>
<rect x="30" y="390" width="410" height="30" fill="#d0d0d0"/>
<line x1="120" x2="120" y1="0" y2="420"/>
<line x1="200" x2="200" y1="0" y2="420"/>
<line x1="280" x2="280" y1="0" y2="420"/>
<line x1="360" x2="360" y1="0" y2="420"/>
<line x1="10" x2="440" y1="120" y2="120" stroke-width="3"/>
<line x1="10" x2="440" y1="240" y2="240" stroke-width="3"/>
<line x1="10" x2="440" y1="360" y2="360" stroke-width="3"/>
</g>
<text transform="rotate(-90,25,60)" x="25" y="60"
text-anchor="middle">Normal</text>
<text transform="rotate(-90,25,180)" x="25" y="180"
text-anchor="middle">visiblilty="hidden"</text>
<text transform="rotate(-90,25,300)" x="25" y="300"
text-anchor="middle">display="none"</text>
<text transform="rotate(-90,25,390)" x="25" y="390"
text-anchor="middle">Update</text>
<g font-size="15">
<text x="110" y="22" text-anchor="end">none</text>
<text x="110" y="52" text-anchor="end">fill</text>
<text x="110" y="82" text-anchor="end">stroke</text>
<text x="110" y="112" text-anchor="end">fill+stroke</text>
<text x="110" y="142" text-anchor="end">none</text>
<text x="110" y="172" text-anchor="end">fill</text>
<text x="110" y="202" text-anchor="end">stroke</text>
<text x="110" y="232" text-anchor="end">fill+stroke</text>
<text x="110" y="262" text-anchor="end">none</text>
<text x="110" y="292" text-anchor="end">fill</text>
<text x="110" y="322" text-anchor="end">stroke</text>
<text x="110" y="352" text-anchor="end">fill+stroke</text>
<text x="110" y="382" text-anchor="end">none</text>
<text x="110" y="412" text-anchor="end">fill+stroke</text>
</g>
</g>
<g font-size="18" text-anchor="middle">
<g transform="translate(120,0)">
<g fill="none" stroke="none" stroke-width="3">
<path id="n-p" d="M 10,25 c 0,-40 60,20 60,-20z"/>
<text id="n-t" x="120" y="20" stroke-width=".5">getBBox</text>
<g id="n-u">
<use x="190" y="5" width="20" height="20" stroke-width="20"
xlink:href="#Batik_Squiggle"/>
</g>
<image id="n-i" x="261" y="5" width="43" height="20"
xlink:href="../../resources/images/tde.jpg"/>
</g>
</g>
<g transform="translate(120,30)">
<g fill="crimson" stroke="none" stroke-width="3">
<path id="nfp" d="M 10,25 c 0,-40 60,20 60,-20z"/>
<text id="nft" x="120" y="20" stroke-width=".5">getBBox</text>
<g id="nfu">
<use x="190" y="5" width="20" height="20" stroke-width="20"
xlink:href="#Batik_Squiggle"/>
</g>
<image id="nfi" x="261" y="5" width="43" height="20"
xlink:href="../../resources/images/tde.jpg"/>
</g>
</g>
<g transform="translate(120,60)">
<g fill="none" stroke="gold" stroke-width="3" >
<path id="nsp" d="M 10,25 c 0,-40 60,20 60,-20z"/>
<text id="nst" x="120" y="20" stroke-width=".5">getBBox</text>
<g id="nsu">
<use x="190" y="5" width="20" height="20" stroke-width="20"
xlink:href="#Batik_Squiggle"/>
</g>
<image id="nsi" x="261" y="5" width="43" height="20"
xlink:href="../../resources/images/tde.jpg"/>
</g>
</g>
<g transform="translate(120,90)">
<g fill="crimson" stroke="gold" stroke-width="3">
<path id="nfsp" d="M 10,25 c 0,-40 60,20 60,-20z"/>
<text id="nfst" x="120" y="20" stroke-width=".5">getBBox</text>
<g id="nfsu">
<use x="190" y="5" width="20" height="20" stroke-width="20"
xlink:href="#Batik_Squiggle"/>
</g>
<image id="nfsi" x="261" y="5" width="43" height="20"
xlink:href="../../resources/images/tde.jpg"/>
</g>
</g>
</g>
<g transform="translate(0, 120)" font-size="18" text-anchor="middle">
<g transform="translate(120,0)" >
<g fill="none" stroke="none" stroke-width="3" visibility="hidden">
<path id="v-p" d="M 10,25 c 0,-40 60,20 60,-20z"/>
<text id="v-t" x="120" y="20" stroke-width=".5">getBBox</text>
<g id="v-u">
<use x="190" y="5" width="20" height="20" stroke-width="20"
xlink:href="#Batik_Squiggle"/>
</g>
<image id="v-i" x="261" y="5" width="43" height="20"
xlink:href="../../resources/images/tde.jpg"/>
</g>
</g>
<g transform="translate(120,30)">
<g fill="crimson" stroke="none" stroke-width="3"
visibility="hidden">
<path id="vfp" d="M 10,25 c 0,-40 60,20 60,-20z"/>
<text id="vft" x="120" y="20" stroke-width=".5">getBBox</text>
<g id="vfu">
<use x="190" y="5" width="20" height="20" stroke-width="20"
xlink:href="#Batik_Squiggle"/>
</g>
<image id="vfi" x="261" y="5" width="43" height="20"
xlink:href="../../resources/images/tde.jpg"/>
</g>
</g>
<g transform="translate(120,60)">
<g fill="none" stroke="gold" stroke-width="3" visibility="hidden">
<path id="vsp" d="M 10,25 c 0,-40 60,20 60,-20z"/>
<text id="vst" x="120" y="20" stroke-width=".5">getBBox</text>
<g id="vsu">
<use x="190" y="5" width="20" height="20" stroke-width="20"
xlink:href="#Batik_Squiggle"/>
</g>
<image id="vsi" x="261" y="5" width="43" height="20"
xlink:href="../../resources/images/tde.jpg"/>
</g>
</g>
<g transform="translate(120,90)">
<g fill="crimson" stroke="gold" stroke-width="3"
visibility="hidden">
<path id="vfsp" d="M 10,25 c 0,-40 60,20 60,-20z"/>
<text id="vfst" x="120" y="20" stroke-width=".5">getBBox</text>
<g id="vfsu">
<use x="190" y="5" width="20" height="20" stroke-width="20"
xlink:href="#Batik_Squiggle"/>
</g>
<image id="vfsi" x="261" y="5" width="43" height="20"
xlink:href="../../resources/images/tde.jpg"/>
</g>
</g>
</g>
<g transform="translate(0, 240)" font-size="18" text-anchor="middle">
<g transform="translate(120,0)" >
<g fill="none" stroke="none" stroke-width="3" display="none">
<path id="d-p" d="M 10,25 c 0,-40 60,20 60,-20z"/>
<text id="d-t" x="120" y="20" stroke-width=".5">getBBox</text>
<g id="d-u">
<use x="190" y="5" width="20" height="20" stroke-width="20"
xlink:href="#Batik_Squiggle"/>
</g>
<image id="d-i" x="261" y="5" width="43" height="20"
xlink:href="../../resources/images/tde.jpg"/>
</g>
</g>
<g transform="translate(120,30)">
<g fill="crimson" stroke="none" stroke-width="3" display="none">
<path id="dfp" d="M 10,25 c 0,-40 60,20 60,-20z"/>
<text id="dft" x="120" y="20" stroke-width=".5">getBBox</text>
<g id="dfu">
<use x="190" y="5" width="20" height="20" stroke-width="20"
xlink:href="#Batik_Squiggle"/>
</g>
<image id="dfi" x="261" y="5" width="43" height="20"
xlink:href="../../resources/images/tde.jpg"/>
</g>
</g>
<g transform="translate(120,60)">
<g fill="none" stroke="gold" stroke-width="3" display="none">
<path id="dsp" d="M 10,25 c 0,-40 60,20 60,-20z"/>
<text id="dst" x="120" y="20" stroke-width=".5">getBBox</text>
<g id="dsu">
<use x="190" y="5" width="20" height="20" stroke-width="20"
xlink:href="#Batik_Squiggle"/>
</g>
<image id="dsi" x="261" y="5" width="43" height="20"
xlink:href="../../resources/images/tde.jpg"/>
</g>
</g>
<g transform="translate(120,90)">
<g fill="crimson" stroke="gold" stroke-width="3" display="none">
<path id="dfsp" d="M 10,25 c 0,-40 60,20 60,-20z"/>
<text id="dfst" x="120" y="20" stroke-width=".5">getBBox</text>
<g id="dfsu">
<use x="190" y="5" width="20" height="20" stroke-width="20"
xlink:href="#Batik_Squiggle"/>
</g>
<image id="dfsi" x="261" y="5" width="43" height="20"
xlink:href="../../resources/images/tde.jpg"/>
</g>
</g>
</g>
<g transform="translate(0, 360)" font-size="18" text-anchor="middle">
<g transform="translate(120,0)">
<g fill="none" stroke="none" stroke-width="3">
<path id="u-p" d="M 40,25 l-10,-10 l10,-10 l10,10 z"/>
<text id="u-t" x="120" y="20" stroke-width=".5">sm</text>
<g id="u-u"
><use x="195" y="10" width="10" height="10" stroke-width="20"
xlink:href="#Batik_Squiggle"/></g>
<image id="u-i" x="271.75" y="10" width="21.5" height="10"
xlink:href="../../resources/images/tde.jpg"/>
</g>
</g>
<g transform="translate(120,30)">
<g fill="crimson" stroke="gold" stroke-width="3">
<path id="ufsp" d="M 40,25 l-10,-10 l10,-10 l10,10 z"/>
<text id="ufst" x="120" y="20" stroke-width=".5">sm</text>
<g id="ufsu"
><use x="195" y="10" width="10" height="10" stroke-width="20"
xlink:href="#Batik_Squiggle"/></g>
<image id="ufsi" x="271.75" y="10" width="21.5" height="10"
xlink:href="../../resources/images/tde.jpg"/>
</g>
</g>
</g>
</g>
</svg>
1.2 +5 -5 xml-batik/samples/tests/spec12/text/flowText.svg
Index: flowText.svg
===================================================================
RCS file: /home/cvs/xml-batik/samples/tests/spec12/text/flowText.svg,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- flowText.svg 18 Nov 2004 01:46:52 -0000 1.1
+++ flowText.svg 30 Nov 2004 03:23:58 -0000 1.2
@@ -53,10 +53,10 @@
</flowRegion>
<flowDiv>
- <flowPara indent="20" bottom-margin="10" >This is an <flowSpan
font-size="40" fill="crimson">ex­ample</flowSpan> of a very long string
that is split ‍across multi­ple lines via text
wrap­ping.</flowPara>
- <flowPara justification="middle" top-margin="10" left-margin="10"
right-margin="10" bottom-margin="10"><flowLine>Now check if text wrapping
handles a number of tricky</flowLine> situations:
averylongrunonwordthatspansmultiplelines<flowSpan
font-weight="bold">with<flowSpan
fill="crimson">embedded</flowSpan>span</flowSpan>elements & <flowSpan
fill="green" dy="-.3em" font-size="80%">super</flowSpan><flowSpan dy=".3em"> or
</flowSpan><flowSpan fill="darkgreen" dy=".3em"
font-size="80%">sub</flowSpan><flowSpan dy="-.3em">
scripts.</flowSpan></flowPara>
- <flowPara top-margin="10" justification="end">Now we are just
<flowSpan font-size="30" fill="blue">about</flowSpan> to go to the next flow
rect <flowSpan font-size="10">(note if the 'about' were included on the last
line of the previous flow rect the line would not have fit and the whole line
would have moved here).</flowSpan></flowPara>
- <flowPara margin="10" justification="full"> I'll keep going
because I want to make sure that it properly stops when it hits the end of all
of the the flow regions defined. Also the last line includes text in a larger
font size so it will not fit. Thus the end of this sentence will be cut off
because the line size gets <flowSpan font-size="35">tall</flowSpan>er</flowPara>
+ <flowPara indent="20" margin-bottom="10" >This is an <flowSpan
font-size="40" fill="crimson">ex­ample</flowSpan> of a very long string
that is split ‍across multi­ple lines via text
wrap­ping.</flowPara>
+ <flowPara text-align="full" margin-top="10" margin-left="10"
margin-right="10" margin-bottom="10">Now check if text wrapping handles some
tricky stuff:
a­very­long­runon­word­that­spans­multiple­lines­<flowSpan
font-weight="bold">with­<flowSpan
fill="crimson">embed­</flowSpan>span</flowSpan>­elements &
<flowSpan fill="green" dy="-.3em" font-size="80%">super</flowSpan><flowSpan
dy=".3em"> or </flowSpan><flowSpan fill="darkgreen" dy=".3em"
font-size="80%">sub</flowSpan><flowSpan dy="-.3em">
scripts.</flowSpan></flowPara>
+ <flowPara margin-top="10pt" text-align="end">We are just <flowSpan
font-size="30" fill="blue">about</flowSpan> to go to the next flow rect
<flowSpan font-size="10">(NOTE: if the 'about' were included on the last line
of the previous flow the line would not have fit in the region, so it is moved
to this flowRegion).</flowSpan></flowPara>
+ <flowPara margin="10px" text-align="middle"> I want to make
sure that it stops when it hits the end of all of the flowRegions defined. Also
the last line includes text in a larger font size so it will not fit. The end
of this sentence will be cut off because the line size gets <flowSpan
font-size="35">tall</flowSpan>er</flowPara>
</flowDiv>
</flowRoot>
</g>
1.39 +19 -2
xml-batik/sources/org/apache/batik/bridge/AbstractGraphicsNodeBridge.java
Index: AbstractGraphicsNodeBridge.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/bridge/AbstractGraphicsNodeBridge.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- AbstractGraphicsNodeBridge.java 14 Oct 2004 09:42:00 -0000 1.38
+++ AbstractGraphicsNodeBridge.java 30 Nov 2004 03:23:58 -0000 1.39
@@ -17,16 +17,20 @@
*/
package org.apache.batik.bridge;
+import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
+import java.lang.ref.SoftReference;
import org.apache.batik.css.engine.CSSEngineEvent;
import org.apache.batik.css.engine.SVGCSSEngine;
import org.apache.batik.dom.svg.SVGContext;
import org.apache.batik.dom.svg.SVGOMElement;
+import org.apache.batik.ext.awt.geom.SegmentList;
import org.apache.batik.gvt.CanvasGraphicsNode;
import org.apache.batik.gvt.CompositeGraphicsNode;
import org.apache.batik.gvt.GraphicsNode;
+
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.events.MutationEvent;
@@ -312,6 +316,9 @@
}
+ protected SoftReference bboxShape = null;
+ protected Rectangle2D bbox = null;
+
/**
* Returns the tight bounding box in current user space (i.e.,
* after application of the transform attribute, if any) on the
@@ -319,7 +326,17 @@
* stroke-width and filter effects).
*/
public Rectangle2D getBBox() {
- return node.getPrimitiveBounds();
+ Shape s = node.getOutline();
+
+ if ((bboxShape != null) && (s == bboxShape.get())) return bbox;
+ bboxShape = new SoftReference(s); // don't keep this live.
+ bbox = null;
+ if (s == null) return bbox;
+
+ // SegmentList.getBounds2D gives tight BBox.
+ SegmentList sl = new SegmentList(s);
+ bbox = sl.getBounds2D();
+ return bbox;
}
/**
1.45 +11 -7
xml-batik/sources/org/apache/batik/bridge/SVGUseElementBridge.java
Index: SVGUseElementBridge.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGUseElementBridge.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- SVGUseElementBridge.java 20 Aug 2004 19:29:46 -0000 1.44
+++ SVGUseElementBridge.java 30 Nov 2004 03:23:58 -0000 1.45
@@ -405,14 +405,18 @@
String attrName = evt.getAttrName();
Node evtNode = evt.getRelatedNode();
- if (attrName.equals(SVG_X_ATTRIBUTE) ||
- attrName.equals(SVG_Y_ATTRIBUTE) ||
- attrName.equals(SVG_TRANSFORM_ATTRIBUTE)) {
+ if ((evtNode.getNamespaceURI() == null) &&
+ (attrName.equals(SVG_X_ATTRIBUTE) ||
+ attrName.equals(SVG_Y_ATTRIBUTE) ||
+ attrName.equals(SVG_TRANSFORM_ATTRIBUTE))) {
node.setTransform(computeTransform(e, ctx));
handleGeometryChanged();
- } else if (( XLinkSupport.XLINK_NAMESPACE_URI.equals
- (evtNode.getNamespaceURI()) )
- && SVG_HREF_ATTRIBUTE.equals(evtNode.getLocalName()) ){
+ } else if (((evtNode.getNamespaceURI() == null) &&
+ (attrName.equals(SVG_WIDTH_ATTRIBUTE) ||
+ attrName.equals(SVG_HEIGHT_ATTRIBUTE))) ||
+ (( XLinkSupport.XLINK_NAMESPACE_URI.equals
+ (evtNode.getNamespaceURI()) ) &&
+ SVG_HREF_ATTRIBUTE.equals(evtNode.getLocalName()))) {
buildCompositeGraphicsNode(ctx, e, (CompositeGraphicsNode)node);
}
}
1.10 +5 -1
xml-batik/sources/org/apache/batik/dom/svg/SVGLocatableSupport.java
Index: SVGLocatableSupport.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SVGLocatableSupport.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SVGLocatableSupport.java 18 Aug 2004 07:13:14 -0000 1.9
+++ SVGLocatableSupport.java 30 Nov 2004 03:23:58 -0000 1.10
@@ -71,6 +71,10 @@
*/
public static SVGRect getBBox(Element elt) {
final SVGOMElement svgelt = (SVGOMElement)elt;
+ SVGContext svgctx = svgelt.getSVGContext();
+ if (svgctx == null) return null;
+ if (svgctx.getBBox() == null) return null;
+
return new SVGRect() {
public float getX() {
return (float)svgelt.getSVGContext().getBBox().getX();
1.2 +14 -0
xml-batik/sources/org/apache/batik/ext/awt/geom/SegmentList.java
Index: SegmentList.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/ext/awt/geom/SegmentList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SegmentList.java 18 Nov 2004 01:46:58 -0000 1.1
+++ SegmentList.java 30 Nov 2004 03:23:58 -0000 1.2
@@ -67,6 +67,20 @@
}
}
+ public Rectangle2D getBounds2D() {
+ Iterator iter = iterator();
+ if (!iter.hasNext()) return null;
+
+ Rectangle2D ret;
+ ret = (Rectangle2D)((Segment)iter.next()).getBounds2D().clone();
+ while (iter.hasNext()) {
+ Segment seg = (Segment)iter.next();
+ Rectangle2D segB = seg.getBounds2D();
+ Rectangle2D.union(segB, ret, ret);
+ }
+ return ret;
+ }
+
public void add(Segment s) {
segments.add(s);
}
1.40 +13 -12
xml-batik/sources/org/apache/batik/gvt/CompositeGraphicsNode.java
Index: CompositeGraphicsNode.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/gvt/CompositeGraphicsNode.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- CompositeGraphicsNode.java 23 Oct 2004 17:11:03 -0000 1.39
+++ CompositeGraphicsNode.java 30 Nov 2004 03:23:58 -0000 1.40
@@ -446,17 +446,18 @@
* Returns the outline of this node.
*/
public Shape getOutline() {
- if (outline == null) {
- outline = new GeneralPath();
- for (int i = 0; i < count; i++) {
- Shape childOutline = children[i].getOutline();
- if (childOutline != null) {
- AffineTransform tr = children[i].getTransform();
- if (tr != null) {
-
((GeneralPath)outline).append(tr.createTransformedShape(childOutline), false);
- } else {
- ((GeneralPath)outline).append(childOutline, false);
- }
+ if (outline != null)
+ return outline;
+
+ outline = new GeneralPath();
+ for (int i = 0; i < count; i++) {
+ Shape childOutline = children[i].getOutline();
+ if (childOutline != null) {
+ AffineTransform tr = children[i].getTransform();
+ if (tr != null) {
+
((GeneralPath)outline).append(tr.createTransformedShape(childOutline), false);
+ } else {
+ ((GeneralPath)outline).append(childOutline, false);
}
}
}
1.30 +17 -16 xml-batik/sources/org/apache/batik/gvt/ShapeNode.java
Index: ShapeNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/ShapeNode.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- ShapeNode.java 21 Nov 2004 21:20:23 -0000 1.29
+++ ShapeNode.java 30 Nov 2004 03:23:58 -0000 1.30
@@ -226,21 +226,22 @@
* Returns the bounds of the area covered by this node's primitive paint.
*/
public Rectangle2D getPrimitiveBounds() {
- if (primitiveBounds == null) {
- if (shape == null)
- return null;
+ if (!isVisible) return null;
+ if (shape == null) return null;
+ if (primitiveBounds != null)
+ return primitiveBounds;
- if (shapePainter == null)
- primitiveBounds = shape.getBounds2D();
- else
- primitiveBounds = shapePainter.getPaintedBounds2D();
-
- // Check If we should halt early.
- if (HaltingThread.hasBeenHalted()) {
- // The Thread has been halted.
- // Invalidate any cached values and proceed.
- invalidateGeometryCache();
- }
+ if (shapePainter == null)
+ primitiveBounds = shape.getBounds2D();
+ else
+ primitiveBounds = shapePainter.getPaintedBounds2D();
+
+ // Check If we should halt early.
+ if (HaltingThread.hasBeenHalted()) {
+ // The Thread has been halted.
+ // Invalidate any cached values and proceed (this
+ // sets primitiveBounds to null).
+ invalidateGeometryCache();
}
return primitiveBounds;
}
1.2 +13 -10 xml-batik/sources/org/apache/batik/gvt/flow/LineInfo.java
Index: LineInfo.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/gvt/flow/LineInfo.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LineInfo.java 18 Nov 2004 01:46:59 -0000 1.1
+++ LineInfo.java 30 Nov 2004 03:23:58 -0000 1.2
@@ -140,7 +140,6 @@
if (delta < 0) break;
i++;
-
rangeAdvance += adv;
}
@@ -334,6 +333,7 @@
// of glpyhs in each range for use with full justification.
int []rangeGG = new int[numRanges];
int []rangeG = new int[numRanges];
+ GlyphGroupInfo []rangeLastGGI = new GlyphGroupInfo[numRanges];
GlyphGroupInfo ggi = ggis[0];
int r = ggi.getRange();
rangeGG[r]++;
@@ -341,8 +341,10 @@
for (int i=1; i<size; i++) {
ggi = ggis[i];
r = ggi.getRange();
- if (!ggi.getHideLast())
+ if ((rangeLastGGI[r]==null) || !rangeLastGGI[r].getHideLast())
rangeGG[r]++;
+ rangeLastGGI[r] = ggi;
+
rangeG [r] += ggi.getGlyphCount();
GlyphGroupInfo pggi = ggis[i-1];
@@ -355,7 +357,7 @@
int currRange = -1;
double locX=0, range=0, rAdv=0;
r=-1;
- ggi = ggis[0];
+ ggi = null;
for (int i=0; i<size; i++) {
GlyphGroupInfo pggi = ggi;
int prevRange = currRange;
@@ -388,10 +390,10 @@
case BlockInfo.ALIGN_MIDDLE: locX += (range-rAdv)/2; break;
case BlockInfo.ALIGN_END: locX += (range-rAdv); break;
}
- } else if (pggi.getHideLast()) {
+ } else if ((pggi!= null) && pggi.getHideLast()) {
// Hide last glyph from prev glyph group (soft hyphen etc).
- gv.setGlyphVisible(pggi.getEnd(), false);
- }
+ gv.setGlyphVisible(pggi.getEnd(), false);
+ }
int start = ggi.getStart();
int end = ggi.getEnd();
@@ -413,9 +415,10 @@
p2d = np2d;
advAdj -= gAdv;
}
- locX += ggi.getAdvance()-advAdj+ggAdv;
- prevRange = currRange;
- pggi = ggi;
+ if (ggi.getHideLast())
+ locX += ggi.getAdvance()-advAdj;
+ else
+ locX += ggi.getAdvance()-advAdj+ggAdv;
}
}
1.47 +2 -2
xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java
Index: JGVTComponent.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- JGVTComponent.java 20 Nov 2004 19:27:10 -0000 1.46
+++ JGVTComponent.java 30 Nov 2004 03:23:58 -0000 1.47
@@ -670,7 +670,7 @@
*/
protected boolean computeRenderingTransform() {
initialTransform = new AffineTransform();
- if (initialTransform != renderingTransform) {
+ if (!initialTransform.equals(renderingTransform)) {
setRenderingTransform(initialTransform, false);
return true;
}
1.4 +227 -205
xml-batik/test-references/samples/tests/spec/scripting/text_content.png
<<Binary file>>
1.3 +39 -44
xml-batik/test-references/samples/tests/spec/scripting/zeroSize.png
<<Binary file>>
1.1
xml-batik/test-references/samples/tests/spec/scripting/bbox.png
<<Binary file>>
1.121 +2 -1
xml-batik/test-resources/org/apache/batik/test/samplesRendering.xml
Index: samplesRendering.xml
===================================================================
RCS file:
/home/cvs/xml-batik/test-resources/org/apache/batik/test/samplesRendering.xml,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -r1.120 -r1.121
--- samplesRendering.xml 21 Nov 2004 21:20:23 -0000 1.120
+++ samplesRendering.xml 30 Nov 2004 03:23:58 -0000 1.121
@@ -347,6 +347,7 @@
<testGroup id="tests.spec.scripting">
<test id="samples/tests/spec/scripting/add.svg" />
+ <test id="samples/tests/spec/scripting/bbox.svg" />
<test id="samples/tests/spec/scripting/circle.svg" />
<test id="samples/tests/spec/scripting/display.svg" />
<test id="samples/tests/spec/scripting/ellipse.svg" />
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]