Debian Codegraph @

samples/tests/spec/scripting/imageUpdate.svg

raw
1 <?xml version="1.0" standalone="no"?>
2 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
3 "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.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 <!-- dynamic update for image -->
25 <!-- -->
26 <!-- @author [email protected] -->
27 <!-- @version $Id$ -->
28 <!-- ========================================================================= -->
29 <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>
30
31 <svg xmlns="http://www.w3.org/2000/svg"
32 xmlns:xlink="http://www.w3.org/1999/xlink"
33 id="body" width="450" height="500" viewBox="0 0 450 500">
34
35 <title>update on &lt;image&gt;</title>
36
37 <style type="text/css"><![CDATA[
38
39 ]]></style>
40 <script type="text/ecmascript" >
41 var SVGNS ="http://www.w3.org/2000/svg";
42 var xlinkNS = "http://www.w3.org/1999/xlink";
43 function setRef(name,ref){
44 var e = document.getElementById(name);
45 e.setAttributeNS(xlinkNS,"href",ref);
46 }
47 function setPosition(name,x,y,width,height){
48 var e = document.getElementById(name);
49 e.setAttribute("x",x);
50 e.setAttribute("y",y);
51 e.setAttribute("width",width);
52 e.setAttribute("height",height);
53 }
54 </script>
55
56 <g id="content">
57
58 <text class="title" x="50%" y="40">&lt;image&gt; dynamic tests</text>
59
60 <defs>
61 <rect id="Rect1" x="40" y="-20" width="100" height="40" />
62 <rect id="Rect2" x="60" y="-60" width="40" height="100" />
63 </defs>
64
65 <g transform="translate(70,150)">
66 <use xlink:href="#Rect1"
67 style="fill:none; stroke:blue; stroke-width:2;stroke-opacity:0.5"/>
68 <use xlink:href="#Rect2"
69 style="fill:none; stroke:blue; stroke-width:2"/>
70
71 <image id="image1" x="40" y="-20" width="100" height="40"
72 xlink:href="../../resources/images/svg.svg"
73 preserveAspectRatio="none"/>
74 <text font-size="10" x="35" y="60">
75 SVG image <tspan x="40" dy="12">ref,x,y,width,height update</tspan>
76 </text>
77 </g>
78
79 <g transform="translate(230,150)">
80 <use xlink:href="#Rect2"
81 style="fill:none; stroke:blue; stroke-width:2;stroke-opacity:0.5"/>
82 <use xlink:href="#Rect1"
83 style="fill:none; stroke:blue; stroke-width:2"/>
84
85 <image id="image2" x="60" y="-60" width="40" height="100"
86 preserveAspectRatio="none"
87 xlink:href="../../resources/images/svg.svg" />
88 <text font-size="10" x="35" y="60">SVG Image changed</text>
89 </g>
90
91
92
93 <rect x="70" y="300" width="50" height="50" stroke="black" fill="crimson"
94 onclick="setRef('image1','../../resources/images/svg.png');
95 setRef('image2','../../resources/images/svg3.svg')"/>
96
97 <rect x="150" y="300" width="50" height="50" stroke="black" fill="crimson"
98 onclick="setPosition('image1',60,-60,40,100);
99 setPosition('image2',40,-20,100,40)"/>
100
101 <text x="80" y="340" fill="black" font-weight="bold">1</text>
102 <text x="160" y="340" fill="black" font-weight="bold">2</text>
103
104 <text x="50%" y="400" text-anchor="middle" >
105 Click 1 and 2, the image should change
106 and its size and position
107 </text>
108
109 </g>
110
111
112
113 <script type="text/ecmascript"><![CDATA[
114 function onDone() {
115 if (!(regardTestInstance == null)) {
116 regardTestInstance.scriptDone();
117 } else {
118 alert("This button only works when run in the regard framework");
119 }
120 }
121 ]]></script>
122 <g id="done" transform="translate(195, 468)" cursor="pointer" onclick="onDone()">
123 <rect rx="5" ry="5" width="60" height="25" fill="#eeeeee" stroke="black" />
124 <text x="30" y="18" font-size="14" font-weight="bold" text-anchor="middle">Done</text>
125 </g>
126
127
128 <!-- ============================================================= -->
129 <!-- Batik sample mark -->
130 <!-- ============================================================= -->
131 <use xlink:href="../../../batikLogo.svg#Batik_Tag_Box" />
132
133 </svg>
134