Debian Codegraph @

samples/tests/spec/scripting/enclosureList.svg

raw
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 <!-- Testing the getEnclosureList interface on the svg:svg element. -->
26 <!-- -->
27 <!-- @author [email protected] -->
28 <!-- @version $Id$ -->
29 <!-- ====================================================================== -->
30
31 <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>
32
33 <svg id="body" width="450" height="500" viewBox="0 0 450 500"
34 onload="testEnclosure()"
35 xmlns="http://www.w3.org/2000/svg"
36 xmlns:xlink="http://www.w3.org/1999/xlink" >
37 <title>Test of getEnclosureList interface</title>
38 <text x="50%" y="45" class="title">Test of getEnclosureList interface</text>
39
40 <script type="text/ecmascript"><![CDATA[
41 var svgns = "http://www.w3.org/2000/svg";
42
43 function doCheck(svg, rect, end, attr, val) {
44 var lst = svg.getEnclosureList(rect, end);
45 var i=0, sz = lst.getLength();
46 while (i < sz) {
47 var e = lst.item(i);
48 e.setAttribute(attr, val);
49 i++;
50 }
51 }
52
53 function setRect(rect, x, y, w, h) {
54 rect.x = x;
55 rect.y = y;
56 rect.width = w;
57 rect.height = h;
58 }
59
60 function makeRect(parent, rect, stroke) {
61 var outline = document.createElementNS(svgns, "rect");
62 outline.setAttribute("x", "" + rect.x);
63 outline.setAttribute("y", "" + rect.y);
64 outline.setAttribute("width", "" + rect.width);
65 outline.setAttribute("height", "" + rect.height);
66 outline.setAttribute("fill", "none");
67 outline.setAttribute("stroke", stroke);
68 parent.appendChild(outline);
69 }
70
71 function checkEnclosure(svg, rect, elem, attr, val1, val2) {
72 if (svg.checkEnclosure(elem, rect))
73 elem.setAttribute(attr, val1);
74 else
75 elem.setAttribute(attr, val2);
76 }
77
78 function testEnclosure() {
79 var root = document.getRootElement();
80 var rect = root.createSVGRect();
81 setRect(rect, 25, 70, 100, 100);
82
83 doCheck(root, rect, null, "fill", "blue");
84
85 var middle = root.getElementById("tb1-middle");
86 doCheck(root, rect, middle, "stroke", "red");
87 makeRect(root, rect, "red");
88
89 var tb2 = root.getElementById("testblock2");
90 setRect(rect, 45, 45, 450, 50);
91 doCheck(tb2, rect, null, "fill", "green");
92 makeRect(tb2, rect, "green");
93
94 setRect(rect, 187.5, 131.5, 224, 25);
95 doCheck(root, rect, null, "stroke", "pink");
96 makeRect(root, rect, "pink");
97
98 setRect(rect, 82.35, 267.15, 35.25, 35.25);
99 doCheck(root, rect, null, "stroke", "lightgreen");
100 makeRect(root, rect, "lightgreen");
101
102 setRect(rect, 90.65, 275.25, 19, 19);
103 doCheck(root, rect, null, "fill", "purple");
104 makeRect(root, rect, "purple");
105
106 var tb5 = root.getElementById("testblock5");
107 var tb5_m = root.getElementById("tb5-middle");
108 setRect(rect, 45, 160, 150, 20);
109 doCheck(tb5, rect, tb5_m, "fill", "crimson");
110 makeRect(tb5, rect, "crimson");
111
112
113 var ts = root.getElementById("ts1");
114 setRect(rect, 208, 202, 23, 25);
115 doCheck(root, rect, null, "stroke", "blue");
116 makeRect(root, rect, "blue");
117
118 setRect(rect, 225, 204, 20, 25);
119 doCheck(root, rect, ts, "fill", "orange");
120 doCheck(root, rect, null, "text-decoration", "underline");
121 makeRect(root, rect, "orange");
122
123 setRect(rect, 237, 202, 40, 25);
124 doCheck(root, rect, null, "stroke", "crimson");
125 makeRect(root, rect, "crimson");
126
127 setRect(rect, 15, 420, 135, 47);
128 doCheck(root, rect, null, "text-decoration", "overline");
129 makeRect(root, rect, "black");
130
131 setRect(rect, 310, 420, 120, 47);
132 doCheck(root, rect, null, "text-decoration", "line-through");
133 makeRect(root, rect, "black");
134
135
136 var tb6 = root.getElementById("testblock6");
137 var tb6_m = root.getElementById("tb6-middle");
138
139 var tb6_11 = root.getElementById("tb6-11");
140 var tb6_21 = root.getElementById("tb6-21");
141 var tb6_31 = root.getElementById("tb6-31");
142 var tb6_41 = root.getElementById("tb6-41");
143
144 var tb6_12 = root.getElementById("tb6-12");
145 var tb6_22 = root.getElementById("tb6-22");
146 var tb6_32 = root.getElementById("tb6-32");
147 var tb6_42 = root.getElementById("tb6-42");
148
149 var tb6_13 = root.getElementById("tb6-13");
150 var tb6_23 = root.getElementById("tb6-23");
151 var tb6_43 = root.getElementById("tb6-43");
152
153 var tb6_14 = root.getElementById("tb6-14");
154 var tb6_24 = root.getElementById("tb6-24");
155 var tb6_34 = root.getElementById("tb6-34");
156 var tb6_44 = root.getElementById("tb6-44");
157
158 setRect(rect, 190, 300, 70, 70);
159 checkEnclosure(root, rect, tb6_11, "fill", "blue", "crimson");
160 checkEnclosure(root, rect, tb6_21, "fill", "blue", "crimson");
161 checkEnclosure(root, rect, tb6_31, "fill", "blue", "crimson");
162 checkEnclosure(root, rect, tb6_41, "fill", "blue", "crimson");
163
164 checkEnclosure(root, rect, tb6_12, "fill", "blue", "crimson");
165 checkEnclosure(root, rect, tb6_22, "fill", "blue", "crimson");
166 checkEnclosure(root, rect, tb6_32, "fill", "blue", "crimson");
167 checkEnclosure(root, rect, tb6_42, "fill", "blue", "crimson");
168
169 checkEnclosure(root, rect, tb6_13, "fill", "blue", "crimson");
170 checkEnclosure(root, rect, tb6_23, "fill", "blue", "crimson");
171 checkEnclosure(root, rect, tb6_m, "fill", "blue", "crimson");
172 checkEnclosure(root, rect, tb6_43, "fill", "blue", "crimson");
173
174 checkEnclosure(root, rect, tb6_14, "fill", "blue", "crimson");
175 checkEnclosure(root, rect, tb6_24, "fill", "blue", "crimson");
176 checkEnclosure(root, rect, tb6_34, "fill", "blue", "crimson");
177 checkEnclosure(root, rect, tb6_44, "fill", "blue", "crimson");
178
179 makeRect(root, rect, "blue");
180
181 }
182 ]]></script>
183
184 <g id="test-content" >
185 <svg id="testblock1" overflow="visible"
186 x="15" y="60" width="120" height="120" viewBox="-.5 -.5 241 241"
187 style="fill:yellow; stroke:black; stroke-width:2; fill-opacity:.5;">
188 <path d="M 10 10 h 220 v 220 h -220 z m 20 20 v 180 h 180 v -180 z"/>
189
190 <rect x="0" y="0" width="40" height="40"/>
191 <rect x="50" y="0" width="40" height="40"/>
192 <rect x="100" y="0" width="40" height="40"/>
193 <rect x="150" y="0" width="40" height="40"/>
194 <rect x="200" y="0" width="40" height="40"/>
195
196 <rect x="0" y="50" width="40" height="40"/>
197 <rect x="50" y="50" width="40" height="40"/>
198 <rect x="100" y="50" width="40" height="40"/>
199 <rect x="150" y="50" width="40" height="40"/>
200 <rect x="200" y="50" width="40" height="40"/>
201
202 <rect x="0" y="100" width="40" height="40"/>
203 <rect x="50" y="100" width="40" height="40"/>
204 <rect id="tb1-middle" x="100" y="100" width="40" height="40"/>
205 <rect x="150" y="100" width="40" height="40"/>
206 <rect x="200" y="100" width="40" height="40"/>
207
208 <rect x="0" y="150" width="40" height="40"/>
209 <rect x="50" y="150" width="40" height="40"/>
210 <rect x="100" y="150" width="40" height="40"/>
211 <rect x="150" y="150" width="40" height="40"/>
212 <rect x="200" y="150" width="40" height="40"/>
213
214 <rect x="0" y="200" width="40" height="40"/>
215 <rect x="50" y="200" width="40" height="40"/>
216 <rect x="100" y="200" width="40" height="40"/>
217 <rect x="150" y="200" width="40" height="40"/>
218 <rect x="200" y="200" width="40" height="40"/>
219 </svg>
220
221 <svg id="testblock2" overflow="visible"
222 x="165" y="60" width="120" height="120" viewBox="-.5 -.5 241 241"
223 style="fill:yellow; stroke:black; stroke-width:2; fill-opacity:.5;">
224 <path d="M 10 10 h 220 v 220 h -220 z m 20 20 v 180 h 180 v -180 z"/>
225
226 <rect x="0" y="0" width="40" height="40"/>
227 <rect x="50" y="0" width="40" height="40"/>
228 <rect x="100" y="0" width="40" height="40"/>
229 <rect x="150" y="0" width="40" height="40"/>
230 <rect x="200" y="0" width="40" height="40"/>
231
232 <rect x="0" y="50" width="40" height="40"/>
233 <rect x="50" y="50" width="40" height="40"/>
234 <rect x="100" y="50" width="40" height="40"/>
235 <rect x="150" y="50" width="40" height="40"/>
236 <rect x="200" y="50" width="40" height="40"/>
237
238 <rect x="0" y="100" width="40" height="40"/>
239 <rect x="50" y="100" width="40" height="40"/>
240 <rect id="tb2-middle" x="100" y="100" width="40" height="40"/>
241 <rect x="150" y="100" width="40" height="40"/>
242 <rect x="200" y="100" width="40" height="40"/>
243
244 <rect x="0" y="150" width="40" height="40"/>
245 <rect x="50" y="150" width="40" height="40"/>
246 <rect x="100" y="150" width="40" height="40"/>
247 <rect x="150" y="150" width="40" height="40"/>
248 <rect x="200" y="150" width="40" height="40"/>
249
250 <rect x="0" y="200" width="40" height="40"/>
251 <rect x="50" y="200" width="40" height="40"/>
252 <rect x="100" y="200" width="40" height="40"/>
253 <rect x="150" y="200" width="40" height="40"/>
254 <rect x="200" y="200" width="40" height="40"/>
255 </svg>
256
257 <svg id="testblock3" overflow="visible"
258 x="315" y="60" width="120" height="120" viewBox="-.5 -.5 241 241"
259 style="fill:yellow; stroke:black; stroke-width:2; fill-opacity:.5;">
260 <path d="M 10 10 h 220 v 220 h -220 z m 20 20 v 180 h 180 v -180 z"/>
261
262 <rect x="0" y="0" width="40" height="40"/>
263 <rect x="50" y="0" width="40" height="40"/>
264 <rect x="100" y="0" width="40" height="40"/>
265 <rect x="150" y="0" width="40" height="40"/>
266 <rect x="200" y="0" width="40" height="40"/>
267
268 <rect x="0" y="50" width="40" height="40"/>
269 <rect x="50" y="50" width="40" height="40"/>
270 <rect x="100" y="50" width="40" height="40"/>
271 <rect x="150" y="50" width="40" height="40"/>
272 <rect x="200" y="50" width="40" height="40"/>
273
274 <rect x="0" y="100" width="40" height="40"/>
275 <rect x="50" y="100" width="40" height="40"/>
276 <rect id="tb3-middle" x="100" y="100" width="40" height="40"/>
277 <rect x="150" y="100" width="40" height="40"/>
278 <rect x="200" y="100" width="40" height="40"/>
279
280 <rect x="0" y="150" width="40" height="40"/>
281 <rect x="50" y="150" width="40" height="40"/>
282 <rect x="100" y="150" width="40" height="40"/>
283 <rect x="150" y="150" width="40" height="40"/>
284 <rect x="200" y="150" width="40" height="40"/>
285
286 <rect x="0" y="200" width="40" height="40"/>
287 <rect x="50" y="200" width="40" height="40"/>
288 <rect x="100" y="200" width="40" height="40"/>
289 <rect x="150" y="200" width="40" height="40"/>
290 <rect x="200" y="200" width="40" height="40"/>
291 </svg>
292
293 <g transform="translate(100,200) rotate(45)">
294 <svg id="testblock4" overflow="visible"
295 width="120" height="120" viewBox="-.5 -.5 241 241"
296 style="fill:yellow; stroke:black; stroke-width:2; fill-opacity:.5;">
297 <path d="M 10 10 h 220 v 220 h -220 z m 20 20 v 180 h 180 v -180 z"/>
298
299 <rect x="0" y="0" width="40" height="40"/>
300 <rect x="50" y="0" width="40" height="40"/>
301 <rect x="100" y="0" width="40" height="40"/>
302 <rect x="150" y="0" width="40" height="40"/>
303 <rect x="200" y="0" width="40" height="40"/>
304
305 <rect x="0" y="50" width="40" height="40"/>
306 <rect x="50" y="50" width="40" height="40"/>
307 <rect x="100" y="50" width="40" height="40"/>
308 <rect x="150" y="50" width="40" height="40"/>
309 <rect x="200" y="50" width="40" height="40"/>
310
311 <rect x="0" y="100" width="40" height="40"/>
312 <rect x="50" y="100" width="40" height="40"/>
313 <g >
314 <rect id="tb4-middle" x="100" y="100" width="40" height="40"/>
315 </g>
316 <rect x="150" y="100" width="40" height="40"/>
317 <rect x="200" y="100" width="40" height="40"/>
318
319 <rect x="0" y="150" width="40" height="40"/>
320 <rect x="50" y="150" width="40" height="40"/>
321 <rect x="100" y="150" width="40" height="40"/>
322 <rect x="150" y="150" width="40" height="40"/>
323 <rect x="200" y="150" width="40" height="40"/>
324
325 <rect x="0" y="200" width="40" height="40"/>
326 <rect x="50" y="200" width="40" height="40"/>
327 <rect x="100" y="200" width="40" height="40"/>
328 <rect x="150" y="200" width="40" height="40"/>
329 <rect x="200" y="200" width="40" height="40"/>
330 </svg>
331 </g>
332
333 <g transform="translate(350,200) rotate(45)">
334 <svg id="testblock5" overflow="visible"
335 width="120" height="120" viewBox="-.5 -.5 241 241"
336 style="fill:yellow; stroke:black; stroke-width:2; fill-opacity:.5;">
337 <path d="M 10 10 h 220 v 220 h -220 z m 20 20 v 180 h 180 v -180 z"/>
338
339 <rect x="0" y="0" width="40" height="40"/>
340 <rect x="50" y="0" width="40" height="40"/>
341 <rect x="100" y="0" width="40" height="40"/>
342 <rect x="150" y="0" width="40" height="40"/>
343 <rect x="200" y="0" width="40" height="40"/>
344
345 <rect x="0" y="50" width="40" height="40"/>
346 <rect x="50" y="50" width="40" height="40"/>
347 <rect x="100" y="50" width="40" height="40"/>
348 <rect x="150" y="50" width="40" height="40"/>
349 <rect x="200" y="50" width="40" height="40"/>
350
351 <rect x="0" y="100" width="40" height="40"/>
352 <rect x="50" y="100" width="40" height="40"/>
353 <g >
354 <rect id="tb5-middle" x="100" y="100" width="40" height="40"/>
355 </g>
356 <rect x="150" y="100" width="40" height="40"/>
357 <rect x="200" y="100" width="40" height="40"/>
358
359 <rect x="0" y="150" width="40" height="40"/>
360 <rect x="50" y="150" width="40" height="40"/>
361 <rect x="100" y="150" width="40" height="40"/>
362 <rect x="150" y="150" width="40" height="40"/>
363 <rect x="200" y="150" width="40" height="40"/>
364
365 <rect x="0" y="200" width="40" height="40"/>
366 <rect x="50" y="200" width="40" height="40"/>
367 <rect x="100" y="200" width="40" height="40"/>
368 <rect x="150" y="200" width="40" height="40"/>
369 <rect x="200" y="200" width="40" height="40"/>
370 </svg>
371 </g>
372
373 <g transform="translate(225,285) rotate(45)">
374 <svg id="testblock6" overflow="visible"
375 width="120" height="120" viewBox="-.5 -.5 241 241"
376 style="fill:yellow; stroke:black; stroke-width:2; fill-opacity:.5;">
377 <path d="M 10 10 h 220 v 220 h -220 z m 20 20 v 180 h 180 v -180 z"/>
378
379 <rect id="tb6-11" x="0" y="0" width="40" height="40"/>
380 <rect id="tb6-21" x="50" y="0" width="40" height="40"/>
381 <rect id="tb6-31" x="100" y="0" width="40" height="40"/>
382 <rect id="tb6-41" x="150" y="0" width="40" height="40"/>
383 <rect id="tb6-51" x="200" y="0" width="40" height="40"/>
384
385 <rect id="tb6-12" x="0" y="50" width="40" height="40"/>
386 <rect id="tb6-22" x="50" y="50" width="40" height="40"
387 pointer-events="none"/>
388 <rect id="tb6-32" x="100" y="50" width="40" height="40"/>
389 <rect id="tb6-42" x="150" y="50" width="40" height="40"/>
390 <rect id="tb6-52" x="200" y="50" width="40" height="40"/>
391
392 <rect id="tb6-13" x="0" y="100" width="40" height="40"/>
393 <rect id="tb6-23" x="50" y="100" width="40" height="40"/>
394 <g >
395 <rect id="tb6-middle" x="100" y="100" width="40" height="40"/>
396 </g>
397 <rect id="tb6-43" x="150" y="100" width="40" height="40"/>
398 <rect id="tb6-53" x="200" y="100" width="40" height="40"/>
399
400 <rect id="tb6-14" x="0" y="150" width="40" height="40"/>
401 <rect id="tb6-24" x="50" y="150" width="40" height="40"/>
402 <rect id="tb6-34" x="100" y="150" width="40" height="40"/>
403 <rect id="tb6-44" x="150" y="150" width="40" height="40"/>
404 <rect id="tb6-54" x="200" y="150" width="40" height="40"/>
405
406 <rect id="tb6-15" x="0" y="200" width="40" height="40"/>
407 <rect id="tb6-25" x="50" y="200" width="40" height="40"/>
408 <rect id="tb6-35" x="100" y="200" width="40" height="40"/>
409 <rect id="tb6-45" x="150" y="200" width="40" height="40"/>
410 <rect id="tb6-55" x="200" y="200" width="40" height="40"/>
411 </svg>
412 </g>
413
414 <text x="225" y="220" text-anchor="middle" font-size="15"
415 >This <tspan id="ts1" font-weight="bold">is <tspan font-style="italic"
416 >a</tspan> test </tspan><tspan x="225" dy="20" text-anchor="middle"
417 >of text encolsure!!!</tspan></text>
418
419 <text x="85" y="440" text-anchor="middle" font-size="15"
420 >This <tspan id="ts2" font-weight="bold">is <tspan font-style="italic"
421 >a</tspan> test </tspan><tspan x="85" dy="20" text-anchor="middle"
422 >of text encolsure!!!</tspan></text>
423
424 <text x="365" y="440" text-anchor="middle" font-size="15"
425 >This <tspan id="ts3" font-weight="bold">is <tspan font-style="italic"
426 >a</tspan> test </tspan><tspan x="365" dy="20" text-anchor="middle"
427 >of text encolsure!!!!</tspan></text>
428 </g>
429 </svg>
430
431