| 1 |
<?xml version="1.0" standalone="no"?> |
| 2 |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN" |
| 3 |
"http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd"> |
| 4 |
|
| 5 |
<!-- |
| 6 |
|
| 7 |
Licensed to the Apache Software Foundation (ASF) under one or more |
| 8 |
contributor license agreements. See the NOTICE file distributed with |
| 9 |
this work for additional information regarding copyright ownership. |
| 10 |
The ASF licenses this file to You under the Apache License, Version 2.0 |
| 11 |
(the "License"); you may not use this file except in compliance with |
| 12 |
the License. You may obtain a copy of the License at |
| 13 |
|
| 14 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 15 |
|
| 16 |
Unless required by applicable law or agreed to in writing, software |
| 17 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 18 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 |
See the License for the specific language governing permissions and |
| 20 |
limitations under the License. |
| 21 |
|
| 22 |
--> |
| 23 |
|
| 24 |
<!-- ====================================================================== --> |
| 25 |
<!-- Test of getBBox interface for various elements with various property --> |
| 26 |
<!-- values (fill, stroke, visibility, display). --> |
| 27 |
<!-- --> |
| 28 |
<!-- @author [email protected] --> |
| 29 |
<!-- @version $Id$ --> |
| 30 |
<!-- ====================================================================== --> |
| 31 |
|
| 32 |
<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> |
| 33 |
|
| 34 |
<svg id="body" width="450" height="500" viewBox="0 0 450 500" |
| 35 |
onload="start()"> |
| 36 |
<title>Test getBBox interface</title> |
| 37 |
<text x="50%" y="45" class="title">Test getBBox interface</text> |
| 38 |
|
| 39 |
<script type="text/ecmascript"><![CDATA[ |
| 40 |
var svgns = "http://www.w3.org/2000/svg"; |
| 41 |
var root; |
| 42 |
var pref = new Array("n", "v", "d" ); |
| 43 |
var fillStroke = new Array("-", "f", "s", "fs" ); |
| 44 |
var elemT = new Array("p", "t", "u", "i" ); |
| 45 |
var xLoc = new Array(35, 115, 195, 275); |
| 46 |
var yLoc = 10; |
| 47 |
|
| 48 |
function start() { |
| 49 |
root = document.getRootElement(); |
| 50 |
for (i=0; i<pref.length; i++) { |
| 51 |
for (j=0; j<fillStroke.length; j++) { |
| 52 |
for (k=0; k<elemT.length; k++) { |
| 53 |
doBBox(pref[i]+fillStroke[j]+elemT[k], xLoc[k], yLoc); |
| 54 |
} |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
updatePath("u-p"); |
| 59 |
updatePath("ufsp"); |
| 60 |
|
| 61 |
updateText("u-t"); |
| 62 |
updateText("ufst"); |
| 63 |
|
| 64 |
updateG("u-u"); |
| 65 |
updateG("ufsu"); |
| 66 |
|
| 67 |
updateImg("u-i"); |
| 68 |
updateImg("ufsi"); |
| 69 |
|
| 70 |
|
| 71 |
} |
| 72 |
|
| 73 |
function updatePath(id) { |
| 74 |
doBBox(id, xLoc[0], yLoc); |
| 75 |
var elem = root.getElementById(id); |
| 76 |
elem.setAttribute("d", "M 10,25 c 0,-40 60,20 60,-20z"); |
| 77 |
doBBox(id, xLoc[0], yLoc); |
| 78 |
} |
| 79 |
|
| 80 |
function updateText(id) { |
| 81 |
doBBox(id, xLoc[1], yLoc); |
| 82 |
var elem = root.getElementById(id); |
| 83 |
var txt = document.createTextNode("getBBox"); |
| 84 |
elem.replaceChild(txt,elem.firstChild); |
| 85 |
doBBox(id, xLoc[1], yLoc); |
| 86 |
} |
| 87 |
|
| 88 |
function updateG(id) { |
| 89 |
doBBox(id, xLoc[2], yLoc); |
| 90 |
var elem = root.getElementById(id); |
| 91 |
var use = elem.firstChild; |
| 92 |
use.setAttribute("x", "190"); |
| 93 |
use.setAttribute("y", "5"); |
| 94 |
use.setAttribute("width", "20"); |
| 95 |
use.setAttribute("height", "20"); |
| 96 |
|
| 97 |
doBBox(id, xLoc[1], yLoc); |
| 98 |
} |
| 99 |
|
| 100 |
function updateImg(id) { |
| 101 |
doBBox(id, xLoc[2], yLoc); |
| 102 |
var elem = root.getElementById(id); |
| 103 |
elem.setAttribute("x", "261"); |
| 104 |
elem.setAttribute("y", "5"); |
| 105 |
elem.setAttribute("width", "43"); |
| 106 |
elem.setAttribute("height", "20"); |
| 107 |
|
| 108 |
doBBox(id, xLoc[1], yLoc); |
| 109 |
} |
| 110 |
|
| 111 |
function doBBox(id, locX, locY) { |
| 112 |
var elem = root.getElementById(id); |
| 113 |
var bbox; |
| 114 |
if (elem) bbox = elem.getBBox(); |
| 115 |
var rect = document.createElementNS(svgns, "rect"); |
| 116 |
if (!bbox) { |
| 117 |
// No BBox undisplayed etc... use small crimson rect. |
| 118 |
rect.setAttribute("x", ""+locX); |
| 119 |
rect.setAttribute("y", ""+locY); |
| 120 |
rect.setAttribute("width", "10"); |
| 121 |
rect.setAttribute("height", "10"); |
| 122 |
rect.setAttribute("fill", "crimson"); |
| 123 |
} else { |
| 124 |
rect.setAttribute("x", ""+bbox.x); |
| 125 |
rect.setAttribute("y", ""+bbox.y); |
| 126 |
rect.setAttribute("width", ""+bbox.width); |
| 127 |
rect.setAttribute("height", ""+bbox.height); |
| 128 |
rect.setAttribute("fill", "none"); |
| 129 |
rect.setAttribute("stroke", "black"); |
| 130 |
rect.setAttribute("stroke-width", "2"); |
| 131 |
rect.setAttribute("stroke-opacity", "0.5"); |
| 132 |
} |
| 133 |
|
| 134 |
elem.getParentNode().getParentNode().appendChild(rect); |
| 135 |
} |
| 136 |
]]></script> |
| 137 |
<defs> |
| 138 |
<symbol id="Batik_Squiggle" viewBox="0 0 540 570"> |
| 139 |
<path id="Batik_Squiggle_Blue" |
| 140 |
d="M172,44C137,60,31,135,11,199c-8,27,22,48,44,33 |
| 141 |
C14,306-1,332,0,356c0,14,13,42,44,27c8-4,35-25,52-41 |
| 142 |
c14-1,24-11,42-28c17,14,36,10,52-7c22,2,82-78,44-108 |
| 143 |
c-3-24-30-37-53-18c-6-2-13-1-18,1c22-35,43-82,49-105 |
| 144 |
C219,47,188,36,172,44z"/> |
| 145 |
<path id="Batik_Squiggle_Red" |
| 146 |
d="M400,0c-18,3-49,31-49,31c-29,23-43,58-28,95 |
| 147 |
c-13,14-29,44-29,67c0,28,20,52,50,29c7,8,21,16,37,5 |
| 148 |
c-5,29,3,48,26,49c1,10,13,31,36,17c16-10,58-39,79-56 |
| 149 |
c25-23,25-94-18-89c33-59-3-96-27-84c-10,4-46,25-52,30 |
| 150 |
c-1-7-5-12-11-14C436,45,436-5,401,0z"/> |
| 151 |
<path id="Batik_Squiggle_Green" |
| 152 |
d="M275,353c-46,12-88,43-114,91c-9,16,6,37,25,33 |
| 153 |
c-14,24-40,67-15,81c28,16,52-8,60-15c18,21,50,10,81-17 |
| 154 |
c41,14,68-2,103-53c8-12,30-43,30-65c0-16-15-30-35-21 |
| 155 |
c-1-12-9-38-53-19c-10-6-31-5-54,17 |
| 156 |
C308,375,300,347,275,353z"/> |
| 157 |
</symbol> |
| 158 |
</defs> |
| 159 |
|
| 160 |
<g id="test-content" transform="translate(0, 60)" > |
| 161 |
<g> <!-- The test grid --> |
| 162 |
<g stroke="#000"> |
| 163 |
<rect x="10" y="0" width="20" height="120" fill="#eee"/> |
| 164 |
<rect x="10" y="120" width="20" height="120" fill="#ddd"/> |
| 165 |
<rect x="10" y="240" width="20" height="120" fill="#eee"/> |
| 166 |
<rect x="10" y="360" width="20" height="60" fill="#ddd"/> |
| 167 |
|
| 168 |
|
| 169 |
<rect x="30" y="0" width="410" height="30" fill="#f8f8f8"/> |
| 170 |
<rect x="30" y="30" width="410" height="30" fill="#f0f0f0"/> |
| 171 |
<rect x="30" y="60" width="410" height="30" fill="#f8f8f8"/> |
| 172 |
<rect x="30" y="90" width="410" height="30" fill="#f0f0f0"/> |
| 173 |
|
| 174 |
<rect x="30" y="120" width="410" height="30" fill="#e0e0e0"/> |
| 175 |
<rect x="30" y="150" width="410" height="30" fill="#d0d0d0"/> |
| 176 |
<rect x="30" y="180" width="410" height="30" fill="#e0e0e0"/> |
| 177 |
<rect x="30" y="210" width="410" height="30" fill="#d0d0d0"/> |
| 178 |
|
| 179 |
<rect x="30" y="240" width="410" height="30" fill="#f8f8f8"/> |
| 180 |
<rect x="30" y="270" width="410" height="30" fill="#f0f0f0"/> |
| 181 |
<rect x="30" y="300" width="410" height="30" fill="#f8f8f8"/> |
| 182 |
<rect x="30" y="330" width="410" height="30" fill="#f0f0f0"/> |
| 183 |
|
| 184 |
<rect x="30" y="360" width="410" height="30" fill="#e0e0e0"/> |
| 185 |
<rect x="30" y="390" width="410" height="30" fill="#d0d0d0"/> |
| 186 |
|
| 187 |
<line x1="120" x2="120" y1="0" y2="420"/> |
| 188 |
<line x1="200" x2="200" y1="0" y2="420"/> |
| 189 |
<line x1="280" x2="280" y1="0" y2="420"/> |
| 190 |
<line x1="360" x2="360" y1="0" y2="420"/> |
| 191 |
<line x1="10" x2="440" y1="120" y2="120" stroke-width="3"/> |
| 192 |
<line x1="10" x2="440" y1="240" y2="240" stroke-width="3"/> |
| 193 |
<line x1="10" x2="440" y1="360" y2="360" stroke-width="3"/> |
| 194 |
</g> |
| 195 |
<text transform="rotate(-90,25,60)" x="25" y="60" text-anchor="middle">Normal</text> |
| 196 |
<text transform="rotate(-90,25,180)" x="25" y="180" text-anchor="middle">visiblilty="hidden"</text> |
| 197 |
<text transform="rotate(-90,25,300)" x="25" y="300" text-anchor="middle">display="none"</text> |
| 198 |
<text transform="rotate(-90,25,390)" x="25" y="390" text-anchor="middle">Update</text> |
| 199 |
<g font-size="15"> |
| 200 |
<text x="110" y="22" text-anchor="end">none</text> |
| 201 |
<text x="110" y="52" text-anchor="end">fill</text> |
| 202 |
<text x="110" y="82" text-anchor="end">stroke</text> |
| 203 |
<text x="110" y="112" text-anchor="end">fill+stroke</text> |
| 204 |
|
| 205 |
<text x="110" y="142" text-anchor="end">none</text> |
| 206 |
<text x="110" y="172" text-anchor="end">fill</text> |
| 207 |
<text x="110" y="202" text-anchor="end">stroke</text> |
| 208 |
<text x="110" y="232" text-anchor="end">fill+stroke</text> |
| 209 |
|
| 210 |
<text x="110" y="262" text-anchor="end">none</text> |
| 211 |
<text x="110" y="292" text-anchor="end">fill</text> |
| 212 |
<text x="110" y="322" text-anchor="end">stroke</text> |
| 213 |
<text x="110" y="352" text-anchor="end">fill+stroke</text> |
| 214 |
|
| 215 |
<text x="110" y="382" text-anchor="end">none</text> |
| 216 |
<text x="110" y="412" text-anchor="end">fill+stroke</text> |
| 217 |
</g> |
| 218 |
</g> |
| 219 |
|
| 220 |
<g font-size="18" text-anchor="middle"> |
| 221 |
<g transform="translate(120,0)"> |
| 222 |
<g fill="none" stroke="none" stroke-width="3"> |
| 223 |
<path id="n-p" d="M 10,25 c 0,-40 60,20 60,-20z"/> |
| 224 |
<text id="n-t" x="120" y="20" stroke-width=".5">getBBox</text> |
| 225 |
<g id="n-u"> |
| 226 |
<use x="190" y="5" width="20" height="20" stroke-width="20" |
| 227 |
xlink:href="#Batik_Squiggle"/> |
| 228 |
</g> |
| 229 |
<image id="n-i" x="261" y="5" width="43" height="20" |
| 230 |
xlink:href="../../resources/images/tde.jpg"/> |
| 231 |
</g> |
| 232 |
</g> |
| 233 |
<g transform="translate(120,30)"> |
| 234 |
<g fill="crimson" stroke="none" stroke-width="3"> |
| 235 |
<path id="nfp" d="M 10,25 c 0,-40 60,20 60,-20z"/> |
| 236 |
<text id="nft" x="120" y="20" stroke-width=".5">getBBox</text> |
| 237 |
<g id="nfu"> |
| 238 |
<use x="190" y="5" width="20" height="20" stroke-width="20" |
| 239 |
xlink:href="#Batik_Squiggle"/> |
| 240 |
</g> |
| 241 |
<image id="nfi" x="261" y="5" width="43" height="20" |
| 242 |
xlink:href="../../resources/images/tde.jpg"/> |
| 243 |
</g> |
| 244 |
</g> |
| 245 |
<g transform="translate(120,60)"> |
| 246 |
<g fill="none" stroke="gold" stroke-width="3" > |
| 247 |
<path id="nsp" d="M 10,25 c 0,-40 60,20 60,-20z"/> |
| 248 |
<text id="nst" x="120" y="20" stroke-width=".5">getBBox</text> |
| 249 |
<g id="nsu"> |
| 250 |
<use x="190" y="5" width="20" height="20" stroke-width="20" |
| 251 |
xlink:href="#Batik_Squiggle"/> |
| 252 |
</g> |
| 253 |
<image id="nsi" x="261" y="5" width="43" height="20" |
| 254 |
xlink:href="../../resources/images/tde.jpg"/> |
| 255 |
</g> |
| 256 |
</g> |
| 257 |
<g transform="translate(120,90)"> |
| 258 |
<g fill="crimson" stroke="gold" stroke-width="3"> |
| 259 |
<path id="nfsp" d="M 10,25 c 0,-40 60,20 60,-20z"/> |
| 260 |
<text id="nfst" x="120" y="20" stroke-width=".5">getBBox</text> |
| 261 |
<g id="nfsu"> |
| 262 |
<use x="190" y="5" width="20" height="20" stroke-width="20" |
| 263 |
xlink:href="#Batik_Squiggle"/> |
| 264 |
</g> |
| 265 |
<image id="nfsi" x="261" y="5" width="43" height="20" |
| 266 |
xlink:href="../../resources/images/tde.jpg"/> |
| 267 |
</g> |
| 268 |
</g> |
| 269 |
</g> |
| 270 |
|
| 271 |
<g transform="translate(0, 120)" font-size="18" text-anchor="middle"> |
| 272 |
<g transform="translate(120,0)" > |
| 273 |
<g fill="none" stroke="none" stroke-width="3" visibility="hidden"> |
| 274 |
<path id="v-p" d="M 10,25 c 0,-40 60,20 60,-20z"/> |
| 275 |
<text id="v-t" x="120" y="20" stroke-width=".5">getBBox</text> |
| 276 |
<g id="v-u"> |
| 277 |
<use x="190" y="5" width="20" height="20" stroke-width="20" |
| 278 |
xlink:href="#Batik_Squiggle"/> |
| 279 |
</g> |
| 280 |
<image id="v-i" x="261" y="5" width="43" height="20" |
| 281 |
xlink:href="../../resources/images/tde.jpg"/> |
| 282 |
</g> |
| 283 |
</g> |
| 284 |
<g transform="translate(120,30)"> |
| 285 |
<g fill="crimson" stroke="none" stroke-width="3" |
| 286 |
visibility="hidden"> |
| 287 |
<path id="vfp" d="M 10,25 c 0,-40 60,20 60,-20z"/> |
| 288 |
<text id="vft" x="120" y="20" stroke-width=".5">getBBox</text> |
| 289 |
<g id="vfu"> |
| 290 |
<use x="190" y="5" width="20" height="20" stroke-width="20" |
| 291 |
xlink:href="#Batik_Squiggle"/> |
| 292 |
</g> |
| 293 |
<image id="vfi" x="261" y="5" width="43" height="20" |
| 294 |
xlink:href="../../resources/images/tde.jpg"/> |
| 295 |
</g> |
| 296 |
</g> |
| 297 |
<g transform="translate(120,60)"> |
| 298 |
<g fill="none" stroke="gold" stroke-width="3" visibility="hidden"> |
| 299 |
<path id="vsp" d="M 10,25 c 0,-40 60,20 60,-20z"/> |
| 300 |
<text id="vst" x="120" y="20" stroke-width=".5">getBBox</text> |
| 301 |
<g id="vsu"> |
| 302 |
<use x="190" y="5" width="20" height="20" stroke-width="20" |
| 303 |
xlink:href="#Batik_Squiggle"/> |
| 304 |
</g> |
| 305 |
<image id="vsi" x="261" y="5" width="43" height="20" |
| 306 |
xlink:href="../../resources/images/tde.jpg"/> |
| 307 |
</g> |
| 308 |
</g> |
| 309 |
<g transform="translate(120,90)"> |
| 310 |
<g fill="crimson" stroke="gold" stroke-width="3" |
| 311 |
visibility="hidden"> |
| 312 |
<path id="vfsp" d="M 10,25 c 0,-40 60,20 60,-20z"/> |
| 313 |
<text id="vfst" x="120" y="20" stroke-width=".5">getBBox</text> |
| 314 |
<g id="vfsu"> |
| 315 |
<use x="190" y="5" width="20" height="20" stroke-width="20" |
| 316 |
xlink:href="#Batik_Squiggle"/> |
| 317 |
</g> |
| 318 |
<image id="vfsi" x="261" y="5" width="43" height="20" |
| 319 |
xlink:href="../../resources/images/tde.jpg"/> |
| 320 |
</g> |
| 321 |
</g> |
| 322 |
</g> |
| 323 |
|
| 324 |
<g transform="translate(0, 240)" font-size="18" text-anchor="middle"> |
| 325 |
<g transform="translate(120,0)" > |
| 326 |
<g fill="none" stroke="none" stroke-width="3" display="none"> |
| 327 |
<path id="d-p" d="M 10,25 c 0,-40 60,20 60,-20z"/> |
| 328 |
<text id="d-t" x="120" y="20" stroke-width=".5">getBBox</text> |
| 329 |
<g id="d-u"> |
| 330 |
<use x="190" y="5" width="20" height="20" stroke-width="20" |
| 331 |
xlink:href="#Batik_Squiggle"/> |
| 332 |
</g> |
| 333 |
<image id="d-i" x="261" y="5" width="43" height="20" |
| 334 |
xlink:href="../../resources/images/tde.jpg"/> |
| 335 |
</g> |
| 336 |
</g> |
| 337 |
<g transform="translate(120,30)"> |
| 338 |
<g fill="crimson" stroke="none" stroke-width="3" display="none"> |
| 339 |
<path id="dfp" d="M 10,25 c 0,-40 60,20 60,-20z"/> |
| 340 |
<text id="dft" x="120" y="20" stroke-width=".5">getBBox</text> |
| 341 |
<g id="dfu"> |
| 342 |
<use x="190" y="5" width="20" height="20" stroke-width="20" |
| 343 |
xlink:href="#Batik_Squiggle"/> |
| 344 |
</g> |
| 345 |
<image id="dfi" x="261" y="5" width="43" height="20" |
| 346 |
xlink:href="../../resources/images/tde.jpg"/> |
| 347 |
</g> |
| 348 |
</g> |
| 349 |
<g transform="translate(120,60)"> |
| 350 |
<g fill="none" stroke="gold" stroke-width="3" display="none"> |
| 351 |
<path id="dsp" d="M 10,25 c 0,-40 60,20 60,-20z"/> |
| 352 |
<text id="dst" x="120" y="20" stroke-width=".5">getBBox</text> |
| 353 |
<g id="dsu"> |
| 354 |
<use x="190" y="5" width="20" height="20" stroke-width="20" |
| 355 |
xlink:href="#Batik_Squiggle"/> |
| 356 |
</g> |
| 357 |
<image id="dsi" x="261" y="5" width="43" height="20" |
| 358 |
xlink:href="../../resources/images/tde.jpg"/> |
| 359 |
</g> |
| 360 |
</g> |
| 361 |
<g transform="translate(120,90)"> |
| 362 |
<g fill="crimson" stroke="gold" stroke-width="3" display="none"> |
| 363 |
<path id="dfsp" d="M 10,25 c 0,-40 60,20 60,-20z"/> |
| 364 |
<text id="dfst" x="120" y="20" stroke-width=".5">getBBox</text> |
| 365 |
<g id="dfsu"> |
| 366 |
<use x="190" y="5" width="20" height="20" stroke-width="20" |
| 367 |
xlink:href="#Batik_Squiggle"/> |
| 368 |
</g> |
| 369 |
<image id="dfsi" x="261" y="5" width="43" height="20" |
| 370 |
xlink:href="../../resources/images/tde.jpg"/> |
| 371 |
</g> |
| 372 |
</g> |
| 373 |
</g> |
| 374 |
|
| 375 |
<g transform="translate(0, 360)" font-size="18" text-anchor="middle"> |
| 376 |
<g transform="translate(120,0)"> |
| 377 |
<g fill="none" stroke="none" stroke-width="3"> |
| 378 |
<path id="u-p" d="M 40,25 l-10,-10 l10,-10 l10,10 z"/> |
| 379 |
<text id="u-t" x="120" y="20" stroke-width=".5">sm</text> |
| 380 |
<g id="u-u" |
| 381 |
><use x="195" y="10" width="10" height="10" stroke-width="20" |
| 382 |
xlink:href="#Batik_Squiggle"/></g> |
| 383 |
<image id="u-i" x="271.75" y="10" width="21.5" height="10" |
| 384 |
xlink:href="../../resources/images/tde.jpg"/> |
| 385 |
</g> |
| 386 |
</g> |
| 387 |
<g transform="translate(120,30)"> |
| 388 |
<g fill="crimson" stroke="gold" stroke-width="3"> |
| 389 |
<path id="ufsp" d="M 40,25 l-10,-10 l10,-10 l10,10 z"/> |
| 390 |
<text id="ufst" x="120" y="20" stroke-width=".5">sm</text> |
| 391 |
<g id="ufsu" |
| 392 |
><use x="195" y="10" width="10" height="10" stroke-width="20" |
| 393 |
xlink:href="#Batik_Squiggle"/></g> |
| 394 |
<image id="ufsi" x="271.75" y="10" width="21.5" height="10" |
| 395 |
xlink:href="../../resources/images/tde.jpg"/> |
| 396 |
</g> |
| 397 |
</g> |
| 398 |
</g> |
| 399 |
</g> |
| 400 |
|
| 401 |
</svg> |
| 402 |
|
| 403 |
|