summaryrefslogtreecommitdiffstats
path: root/src/main/java/xml/postXform.svg
blob: 6a360eaef7f9fa079d7ac711a872ac0dcdce3b55 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
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>