summaryrefslogtreecommitdiffstats
path: root/src/main/java/xml
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/xml')
-rw-r--r--src/main/java/xml/formControls.js27
-rw-r--r--src/main/java/xml/postXform.html13
-rw-r--r--src/main/java/xml/postXform.svg142
-rw-r--r--src/main/java/xml/sampleForm.xml41
4 files changed, 223 insertions, 0 deletions
diff --git a/src/main/java/xml/formControls.js b/src/main/java/xml/formControls.js
new file mode 100644
index 0000000..7c951c2
--- /dev/null
+++ b/src/main/java/xml/formControls.js
@@ -0,0 +1,27 @@
+
+/**
+ * Layout a form control. Must be called to initialize and whenever the
+ * form's dimensions change.
+ */
+function pack()
+{
+}
+
+function moveLabel(name, x, y, width, height)
+{
+ var clipRect = svgDocument.getElementById(name + "-clip-rect");
+ clipRect.setAttribute("x", x);
+ clipRect.setAttribute("y", y);
+ clipRect.setAttribute("width", width);
+ clipRect.setAttribute("height", height);
+
+ var rect = svgDocument.getElementById(name + "-rect");
+ rect.setAttribute("x", x);
+ rect.setAttribute("y", y);
+ rect.setAttribute("width", width);
+ rect.setAttribute("height", height);
+
+ var text = svgDocument.getElementById(name + "-text");
+ rect.setAttribute("x", x);
+ rect.setAttribute("y", y);
+} \ No newline at end of file
diff --git a/src/main/java/xml/postXform.html b/src/main/java/xml/postXform.html
new file mode 100644
index 0000000..970f622
--- /dev/null
+++ b/src/main/java/xml/postXform.html
@@ -0,0 +1,13 @@
+<html>
+ <head>
+ <!--script type="text/ecmascript" src="formControls.js"/-->
+ <!--script type="javascript" src="formControls.js"/-->
+ </head>
+ <body>
+ <h3>SVG image</h3>
+
+ <p><object data="postXform.svg" width="500" height="500" type="image/svg-xml">
+ <embed src="postXform.svg" width="500" height="500" type="image/svg-xml" />
+ </object></p>
+ </body>
+</html> \ No newline at end of file
diff --git a/src/main/java/xml/postXform.svg b/src/main/java/xml/postXform.svg
new file mode 100644
index 0000000..6a360ea
--- /dev/null
+++ b/src/main/java/xml/postXform.svg
@@ -0,0 +1,142 @@
+<!--
+<svg onload="moveLabel('label1', 50, 50, 200, 24)">
+ <script type="text/ecmascript" src="formControls.js"/>
+ -->
+<!--svg onload="moveLabel('label1', 50, 50, 200, 24)"-->
+<!--svg onload="zzz.doIt(); m_label1.moveLabel(50, 50, 200, 24)"-->
+<svg onload="m_label1.setSize(200, 24);m_label1.setLocation(50, 50)">
+<!--svg-->
+
+
+ <script type="text/javascript">
+ <![CDATA[
+
+/**
+ * Fake inheritance in JS
+ */
+Object.prototype.inheritFrom=inheritFrom;
+Object.prototype.callSuper=callSuper;
+
+function inheritFrom(ancestor)
+{
+ this.ancestor=ancestor;
+ for (x in ancestor)
+ {
+ if (!(this [x])) this[x] = ancestor[x];
+ }
+}
+
+function callSuper(func)
+{
+ if (!this.ancestor) return;
+
+ var old = eval(this[func]);
+ this[func] = this.ancestor[func];
+ var temp = arguments;
+ var callString = (arguments.length == 1) ? "this[func]()" : "this[func](";
+
+ for (x=1; x<temp.length; x++)
+ {
+ callString += "temp[" + x + "]";
+ callString += (x == temp.length - 1) ? ")" : ",";
+ }
+
+ eval(callString);
+ this[func] = old;
+}
+
+
+
+function aaa()
+{
+ this.doIt = function() { alert("aaa"); }
+}
+
+function bbb()
+{
+ this.inheritFrom(new aaa());
+ this.doIt = function() { alert("bbb"); }
+}
+
+var zzz = new bbb();
+
+
+var m_label1 = new label("label1");
+
+/**
+ * Layout a form control. Must be called to initialize and whenever the
+ * form''s dimensions change.
+ */
+function pack()
+{
+}
+
+function container(name, x, y, width, height)
+{
+ this.name = name;
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+
+ this.getWidth = function() { return this.width; }
+ this.getHeight = function() { return this.height; }
+ this.getX = function() { return this.x; }
+ this.getY = function() { return this.y; }
+
+// this.setWidth = function(width) { this.width = width; }
+// this.setHeight = function(height) { this.height = height; }
+// this.setX = function(x) { this.x = x; }
+// this.setY = function(y) { this.y = y; }
+
+ this.setSize = function(width, height)
+ {
+ this.width = width;
+ this.height = height;
+
+ var rect = svgDocument.getElementById(this.name + "-rect");
+ rect.setAttribute("width", width);
+ rect.setAttribute("height", height);
+ }
+
+ this.setLocation = function(x, y)
+ {
+ this.x = x;
+ this.y = y;
+
+ var rect = svgDocument.getElementById(this.name + "-rect");
+ rect.setAttribute("x", x);
+ rect.setAttribute("y", y);
+ }
+}
+
+
+function label(name)
+{
+ this.inheritFrom(new container(name));
+
+ this.setLocation = function(x, y)
+ {
+ this.callSuper("setLocation", x, y);
+
+ var text = svgDocument.getElementById(this.name + "-text");
+ text.setAttribute("x", x);
+ text.setAttribute("y", y + this.getHeight());
+ }
+
+//http://www.javascriptkit.com/javatutors/object4.shtml
+}
+
+ // ]]>
+ </script>
+
+
+ <g name="label1">
+ <clipPath id="label1-clip">
+ <rect id="label1-rect" x="20" y="50" width="100" height="24" style="fill:lightGray;stroke:black;"/>
+ </clipPath>
+ <use xlink:href="#label1-rect"/>
+ <text id="label1-text" x="30" y="10" style="fill:black; font-size: 20;clip-path:url(#label1-clip)">Hello good day</text>
+ <!--text id="label1-text" x="30" y="10" style="fill:black; font-size: 20;">Hello good day</text-->
+ </g>
+</svg> \ No newline at end of file
diff --git a/src/main/java/xml/sampleForm.xml b/src/main/java/xml/sampleForm.xml
new file mode 100644
index 0000000..3e8479a
--- /dev/null
+++ b/src/main/java/xml/sampleForm.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Document : sampleForm.xml
+ Created on : October 21, 2004, 7:21 PM
+ Author : kitfox
+ Description:
+ Purpose of the document follows.
+-->
+
+<form x="0" y="0" width="640" height="480">
+ <radio-group name="stoplight"/>
+
+ <panel>
+ <border-layout>
+ <north>
+ <label text="My Window"/>
+ </north>
+ <center>
+ <panel>
+ <box-layout axis="y-axis">
+ <panel>
+ <flow-layout>
+ <label text="Press this button: "/>
+ <button text="Click Me!" onClick="alert('Hello there')"/>
+ </flow-layout>
+ </panel>
+ <panel>
+ <flow-layout>
+ <radio-button name="red" button-group="stoplight" text="red" selected="true"/>
+ <radio-button name="yellow" button-group="stoplight" text="yellow"/>
+ <radio-button name="green" button-group="stoplight" text="green"/>
+ </flow-layout>
+ </panel>
+ </box-layout>
+ </panel>
+ </center>
+ </border-layout>
+ </panel>
+
+</form>