2 <?xml-stylesheet href="svg.css" type="text/css"?>
3 <!DOCTYPE svg SYSTEM "SVG-20000202.dtd" >
4 <!--<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 10 January 2000//EN" -->
5 <!-- "http://www.w3.org/Graphics/SVG/SVG-19991203.dtd"> -->
6 <svg xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.svg"
7 xmlns:html="http://www.w3.org/1999/xhtml">
13 var barXPnts = new Array();
14 var barYPnts = new Array();
16 var nodes = new Array();
25 dump("----------------\n");
26 nodes[0] = findNode(document.documentElement, "bar21");
27 nodes[1] = findNode(document.documentElement, "bar22");
28 nodes[2] = findNode(document.documentElement, "bar23");
29 nodes[3] = findNode(document.documentElement, "bargrid21");
30 nodes[4] = findNode(document.documentElement, "bargrid22");
31 nodes[5] = findNode(document.documentElement, "bargrid23");
32 dump("----------------\n");
34 setTimeout("moveit()", 100);
40 function ChangeBar(name, height)
43 stime = today.getMilliseconds();
44 dump("----------------\n");
46 node = findNode(document.documentElement, str);
47 //node = document.getElementById(str);
49 etime = today.getMilliseconds();
50 dump("1----------------"+(etime-stime)+"\n");
51 attr = document.createAttribute("points");
52 attr.value = "30 " + height + " 30 210 50 210 50 " + height;
53 node.attributes.setNamedItem(attr);
55 stime = today.getMilliseconds();
56 dump("2----------------"+(stime-etime)+"\n");
59 node = findNode(document.documentElement, str);
60 dump("3----------------\n");
61 attr.value = "30 " + height + " 50 " + height + " 60 " + (height-10) + " 40 " + (height-10);
62 node.attributes.setNamedItem(attr);
63 dump("4----------------\n");
66 node = findNode(document.documentElement, str);
67 dump("5----------------\n");
68 attr.value = "50 " + height + " 60 " + (height-10) + " 60 200 50 210";
69 node.attributes.setNamedItem(attr);
70 dump("=================\n");
73 function ChangeBarWithNodes(node1, node2, node3, height)
75 attr = document.createAttribute("points");
76 attr.value = "30 " + height + " 30 210 50 210 50 " + height;
77 node1.attributes.setNamedItem(attr);
79 attr.value = "30 " + height + " 50 " + height + " 60 " + (height-10) + " 40 " + (height-10);
80 node2.attributes.setNamedItem(attr);
82 attr.value = "50 " + height + " 60 " + (height-10) + " 60 200 50 210";
83 node3.attributes.setNamedItem(attr);
88 //ChangeBar("bar2", 150);
89 //ChangeBar("bargrid2", 150);
91 ChangeBarWithNodes(nodes[0], nodes[1], nodes[2], gHeight);
92 ChangeBarWithNodes(nodes[3], nodes[4], nodes[5], gHeight);
96 //dump("gHeight: "+gHeight+" gBarCount: "+gBarCount+" gBarDir: "+gBarDir+"\n");
97 if (gHeight > gBarMax || gHeight < 1) {
99 gBarCount = (Math.random() * 15)+3;
100 //dump("Changining directions: "+gBarDir+"\n");
101 if (gHeight > gBarMax) {
109 gBarCount = (Math.random() * 15)+3;
110 //dump("----> "+gBarCount+"\n");
114 setTimeout("moveit()", 100);
119 function findNode(node, nodename)
121 var type = node.nodeType;
122 if (type == Node.ELEMENT_NODE) {
125 //dump("\<" + node.tagName);
127 // dump the attributes if any
128 attributes = node.attributes;
129 if (null != attributes) {
130 var countAttrs = attributes.length;
132 while(index < countAttrs) {
133 att = attributes[index];
135 //dump(" " + att.name + "=" + att.value+" ["+nodename+"]\n");
136 if (att.name == "id" && att.value == nodename) {
137 //dump("Found it!\n");
145 // recursively dump the children
146 if (node.hasChildNodes()) {
151 var children = node.childNodes;
152 var length = children.length;
154 while(count < length) {
155 child = children[count];
156 fndNode = findNode(child, nodename);
157 if (fndNode != null) {
162 //dump("</" + node.tagName + ">");
170 // if it's a piece of text just dump the text
171 else if (type == Node.TEXT_NODE) {
181 <polyline x="55" y="10" id="bg" points="20 0 220 0 220 200 20 200"/>
182 <polyline x="55" y="10" id="bg" points="20 0 20 200 0 220 0 20 0 20 20 0"/>
183 <polyline x="55" y="10" id="bg" points="20 200 220 200 200 220 0 220"/>
185 <polyline x="55" y="10" id="grid" points="20 0 220 0 220 200 20 200"/>
186 <polyline x="55" y="10" id="grid" points="20 0 20 200 0 220 0 20 0 20"/>
187 <polyline x="55" y="10" id="grid" points="20 200 220 200 200 220 0 220"/>
189 <polyline x="55" y="10" id="grid" points="20 220 40 200 40 0"/>
190 <polyline x="55" y="10" id="grid" points="40 220 60 200 60 0"/>
191 <polyline x="55" y="10" id="grid" points="60 220 80 200 80 0"/>
192 <polyline x="55" y="10" id="grid" points="80 220 100 200 100 0"/>
193 <polyline x="55" y="10" id="grid" points="100 220 120 200 120 0"/>
194 <polyline x="55" y="10" id="grid" points="120 220 140 200 140 0"/>
195 <polyline x="55" y="10" id="grid" points="140 220 160 200 160 0"/>
196 <polyline x="55" y="10" id="grid" points="160 220 180 200 180 0"/>
197 <polyline x="55" y="10" id="grid" points="180 220 200 200 200 0"/>
199 <polygon x="55" y="10" id="bar1" points="30 60 30 210 50 210 50 60"/>
200 <polygon x="55" y="10" id="bar1" points="30 60 50 60 60 50 40 50"/>
201 <polygon x="55" y="10" id="bar1" points="50 60 60 50 60 200 50 210"/>
203 <polyline x="55" y="10" id="grid" points="30 60 30 210 50 210 50 60"/>
204 <polyline x="55" y="10" id="grid" points="30 60 50 60 60 50 40 50"/>
205 <polyline x="55" y="10" id="grid" points="50 60 60 50 60 200 50 210"/>
208 <polygon x="95" y="10" id="bar21" points="30 80 30 210 50 210 50 80"/>
209 <polygon x="95" y="10" id="bar22" points="30 80 50 80 60 70 40 70"/>
210 <polygon x="95" y="10" id="bar23" points="50 80 60 70 60 200 50 210"/>
212 <polyline x="95" y="10" id="bargrid21" points="30 80 30 210 50 210 50 80"/>
213 <polyline x="95" y="10" id="bargrid22" points="30 80 50 80 60 70 40 70"/>
214 <polyline x="95" y="10" id="bargrid23" points="50 80 60 70 60 200 50 210"/>
216 <polygon x="400" y="20" id="rect" points="10 10 50 10 50 50"/>
217 <polygon x="400" y="75" id="poly" points="10 10 50 10 50 50 45 70 32 32 80 20"/>
218 <polyline x="400" y="150" id="poly" points="10 10 50 10 50 50 45 70 32 32 80 20"/>
222 <html:div style="position:absolute;top:5px;left:385px;">Simple Polygons</html:div>
223 <html:div style="position:absolute;top:240px;left:115px;">A Simple Graph</html:div>
224 <html:input type="button" style="position:absolute;top:260px;left:350px;" onclick="init();" value="Start"/>
225 <html:input type="button" style="position:absolute;top:260px;left:390px;" onclick="stop();" value="Stop"/>