Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1318 Rev 1422
1
/*
1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
3
	All Rights Reserved.
4
 
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
9
*/
-
 
10
 
-
 
11
 
10
 
12
 
11
dojo.provide("dojo.gfx.vml");
13
dojo.provide("dojo.gfx.vml");
12
dojo.require("dojo.dom");
14
dojo.require("dojo.dom");
13
dojo.require("dojo.math");
15
dojo.require("dojo.math");
14
dojo.require("dojo.lang.declare");
16
dojo.require("dojo.lang.declare");
15
dojo.require("dojo.lang.extras");
17
dojo.require("dojo.lang.extras");
16
dojo.require("dojo.string.*");
18
dojo.require("dojo.string.*");
17
dojo.require("dojo.html.metrics");
19
dojo.require("dojo.html.metrics");
18
dojo.require("dojo.gfx.color");
20
dojo.require("dojo.gfx.color");
19
dojo.require("dojo.gfx.common");
21
dojo.require("dojo.gfx.common");
20
dojo.require("dojo.gfx.shape");
22
dojo.require("dojo.gfx.shape");
21
dojo.require("dojo.gfx.path");
23
dojo.require("dojo.gfx.path");
22
dojo.require("dojo.experimental");
24
dojo.require("dojo.experimental");
23
dojo.experimental("dojo.gfx.vml");
25
dojo.experimental("dojo.gfx.vml");
24
dojo.gfx.vml.xmlns = "urn:schemas-microsoft-com:vml";
26
dojo.gfx.vml.xmlns = "urn:schemas-microsoft-com:vml";
25
dojo.gfx.vml._parseFloat = function (str) {
27
dojo.gfx.vml._parseFloat = function (str) {
26
	return str.match(/^\d+f$/i) ? parseInt(str) / 65536 : parseFloat(str);
28
	return str.match(/^\d+f$/i) ? parseInt(str) / 65536 : parseFloat(str);
27
};
29
};
28
dojo.gfx.vml.cm_in_pt = 72 / 2.54;
30
dojo.gfx.vml.cm_in_pt = 72 / 2.54;
29
dojo.gfx.vml.mm_in_pt = 7.2 / 2.54;
31
dojo.gfx.vml.mm_in_pt = 7.2 / 2.54;
30
dojo.gfx.vml.px_in_pt = function () {
32
dojo.gfx.vml.px_in_pt = function () {
31
	return dojo.html.getCachedFontMeasurements()["12pt"] / 12;
33
	return dojo.html.getCachedFontMeasurements()["12pt"] / 12;
32
};
34
};
33
dojo.gfx.vml.pt2px = function (len) {
35
dojo.gfx.vml.pt2px = function (len) {
34
	return len * this.px_in_pt();
36
	return len * this.px_in_pt();
35
};
37
};
36
dojo.gfx.vml.px2pt = function (len) {
38
dojo.gfx.vml.px2pt = function (len) {
37
	return len / this.px_in_pt();
39
	return len / this.px_in_pt();
38
};
40
};
39
dojo.gfx.vml.normalizedLength = function (len) {
41
dojo.gfx.vml.normalizedLength = function (len) {
40
	if (len.length == 0) {
42
	if (len.length == 0) {
41
		return 0;
43
		return 0;
42
	}
44
	}
43
	if (len.length > 2) {
45
	if (len.length > 2) {
44
		var px_in_pt = this.px_in_pt();
46
		var px_in_pt = this.px_in_pt();
45
		var val = parseFloat(len);
47
		var val = parseFloat(len);
46
		switch (len.slice(-2)) {
48
		switch (len.slice(-2)) {
47
		  case "px":
49
		  case "px":
48
			return val;
50
			return val;
49
		  case "pt":
51
		  case "pt":
50
			return val * px_in_pt;
52
			return val * px_in_pt;
51
		  case "in":
53
		  case "in":
52
			return val * 72 * px_in_pt;
54
			return val * 72 * px_in_pt;
53
		  case "pc":
55
		  case "pc":
54
			return val * 12 * px_in_pt;
56
			return val * 12 * px_in_pt;
55
		  case "mm":
57
		  case "mm":
56
			return val / this.mm_in_pt * px_in_pt;
58
			return val / this.mm_in_pt * px_in_pt;
57
		  case "cm":
59
		  case "cm":
58
			return val / this.cm_in_pt * px_in_pt;
60
			return val / this.cm_in_pt * px_in_pt;
59
		}
61
		}
60
	}
62
	}
61
	return parseFloat(len);
63
	return parseFloat(len);
62
};
64
};
63
dojo.lang.extend(dojo.gfx.Shape, {setFill:function (fill) {
65
dojo.lang.extend(dojo.gfx.Shape, {setFill:function (fill) {
64
	if (!fill) {
66
	if (!fill) {
65
		this.fillStyle = null;
67
		this.fillStyle = null;
66
		this.rawNode.filled = false;
68
		this.rawNode.filled = false;
67
		return this;
69
		return this;
68
	}
70
	}
69
	if (typeof (fill) == "object" && "type" in fill) {
71
	if (typeof (fill) == "object" && "type" in fill) {
70
		switch (fill.type) {
72
		switch (fill.type) {
71
		  case "linear":
73
		  case "linear":
72
			var f = dojo.gfx.makeParameters(dojo.gfx.defaultLinearGradient, fill);
74
			var f = dojo.gfx.makeParameters(dojo.gfx.defaultLinearGradient, fill);
73
			this.fillStyle = f;
75
			this.fillStyle = f;
74
			var s = "";
76
			var s = "";
75
			for (var i = 0; i < f.colors.length; ++i) {
77
			for (var i = 0; i < f.colors.length; ++i) {
76
				f.colors[i].color = dojo.gfx.normalizeColor(f.colors[i].color);
78
				f.colors[i].color = dojo.gfx.normalizeColor(f.colors[i].color);
77
				s += f.colors[i].offset.toFixed(8) + " " + f.colors[i].color.toHex() + ";";
79
				s += f.colors[i].offset.toFixed(8) + " " + f.colors[i].color.toHex() + ";";
78
			}
80
			}
79
			var fo = this.rawNode.fill;
81
			var fo = this.rawNode.fill;
80
			fo.colors.value = s;
82
			fo.colors.value = s;
81
			fo.method = "sigma";
83
			fo.method = "sigma";
82
			fo.type = "gradient";
84
			fo.type = "gradient";
83
			fo.angle = (dojo.math.radToDeg(Math.atan2(f.x2 - f.x1, f.y2 - f.y1)) + 180) % 360;
85
			fo.angle = (dojo.math.radToDeg(Math.atan2(f.x2 - f.x1, f.y2 - f.y1)) + 180) % 360;
84
			fo.on = true;
86
			fo.on = true;
85
			break;
87
			break;
86
		  case "radial":
88
		  case "radial":
87
			var f = dojo.gfx.makeParameters(dojo.gfx.defaultRadialGradient, fill);
89
			var f = dojo.gfx.makeParameters(dojo.gfx.defaultRadialGradient, fill);
88
			this.fillStyle = f;
90
			this.fillStyle = f;
89
			var w = parseFloat(this.rawNode.style.width);
91
			var w = parseFloat(this.rawNode.style.width);
90
			var h = parseFloat(this.rawNode.style.height);
92
			var h = parseFloat(this.rawNode.style.height);
91
			var c = isNaN(w) ? 1 : 2 * f.r / w;
93
			var c = isNaN(w) ? 1 : 2 * f.r / w;
92
			var i = f.colors.length - 1;
94
			var i = f.colors.length - 1;
93
			f.colors[i].color = dojo.gfx.normalizeColor(f.colors[i].color);
95
			f.colors[i].color = dojo.gfx.normalizeColor(f.colors[i].color);
94
			var s = "0 " + f.colors[i].color.toHex();
96
			var s = "0 " + f.colors[i].color.toHex();
95
			for (; i >= 0; --i) {
97
			for (; i >= 0; --i) {
96
				f.colors[i].color = dojo.gfx.normalizeColor(f.colors[i].color);
98
				f.colors[i].color = dojo.gfx.normalizeColor(f.colors[i].color);
97
				s += (1 - c * f.colors[i].offset).toFixed(8) + " " + f.colors[i].color.toHex() + ";";
99
				s += (1 - c * f.colors[i].offset).toFixed(8) + " " + f.colors[i].color.toHex() + ";";
98
			}
100
			}
99
			var fo = this.rawNode.fill;
101
			var fo = this.rawNode.fill;
100
			fo.colors.value = s;
102
			fo.colors.value = s;
101
			fo.method = "sigma";
103
			fo.method = "sigma";
102
			fo.type = "gradientradial";
104
			fo.type = "gradientradial";
103
			if (isNaN(w) || isNaN(h)) {
105
			if (isNaN(w) || isNaN(h)) {
104
				fo.focusposition = "0.5 0.5";
106
				fo.focusposition = "0.5 0.5";
105
			} else {
107
			} else {
106
				fo.focusposition = (f.cx / w).toFixed(8) + " " + (f.cy / h).toFixed(8);
108
				fo.focusposition = (f.cx / w).toFixed(8) + " " + (f.cy / h).toFixed(8);
107
			}
109
			}
108
			fo.focussize = "0 0";
110
			fo.focussize = "0 0";
109
			fo.on = true;
111
			fo.on = true;
110
			break;
112
			break;
111
		  case "pattern":
113
		  case "pattern":
112
			var f = dojo.gfx.makeParameters(dojo.gfx.defaultPattern, fill);
114
			var f = dojo.gfx.makeParameters(dojo.gfx.defaultPattern, fill);
113
			this.fillStyle = f;
115
			this.fillStyle = f;
114
			var fo = this.rawNode.fill;
116
			var fo = this.rawNode.fill;
115
			fo.type = "tile";
117
			fo.type = "tile";
116
			fo.src = f.src;
118
			fo.src = f.src;
117
			if (f.width && f.height) {
119
			if (f.width && f.height) {
118
				fo.size.x = dojo.gfx.vml.px2pt(f.width);
120
				fo.size.x = dojo.gfx.vml.px2pt(f.width);
119
				fo.size.y = dojo.gfx.vml.px2pt(f.height);
121
				fo.size.y = dojo.gfx.vml.px2pt(f.height);
120
			}
122
			}
121
			fo.alignShape = false;
123
			fo.alignShape = false;
122
			fo.position.x = 0;
124
			fo.position.x = 0;
123
			fo.position.y = 0;
125
			fo.position.y = 0;
124
			fo.origin.x = f.width ? f.x / f.width : 0;
126
			fo.origin.x = f.width ? f.x / f.width : 0;
125
			fo.origin.y = f.height ? f.y / f.height : 0;
127
			fo.origin.y = f.height ? f.y / f.height : 0;
126
			fo.on = true;
128
			fo.on = true;
127
			break;
129
			break;
128
		}
130
		}
129
		this.rawNode.fill.opacity = 1;
131
		this.rawNode.fill.opacity = 1;
130
		return this;
132
		return this;
131
	}
133
	}
132
	this.fillStyle = dojo.gfx.normalizeColor(fill);
134
	this.fillStyle = dojo.gfx.normalizeColor(fill);
133
	this.rawNode.fillcolor = this.fillStyle.toHex();
135
	this.rawNode.fillcolor = this.fillStyle.toHex();
134
	this.rawNode.fill.opacity = this.fillStyle.a;
136
	this.rawNode.fill.opacity = this.fillStyle.a;
135
	this.rawNode.filled = true;
137
	this.rawNode.filled = true;
136
	return this;
138
	return this;
137
}, setStroke:function (stroke) {
139
}, setStroke:function (stroke) {
138
	if (!stroke) {
140
	if (!stroke) {
139
		this.strokeStyle = null;
141
		this.strokeStyle = null;
140
		this.rawNode.stroked = false;
142
		this.rawNode.stroked = false;
141
		return this;
143
		return this;
142
	}
144
	}
143
	this.strokeStyle = dojo.gfx.makeParameters(dojo.gfx.defaultStroke, stroke);
145
	this.strokeStyle = dojo.gfx.makeParameters(dojo.gfx.defaultStroke, stroke);
144
	this.strokeStyle.color = dojo.gfx.normalizeColor(this.strokeStyle.color);
146
	this.strokeStyle.color = dojo.gfx.normalizeColor(this.strokeStyle.color);
145
	var s = this.strokeStyle;
147
	var s = this.strokeStyle;
146
	this.rawNode.stroked = true;
148
	this.rawNode.stroked = true;
147
	this.rawNode.strokecolor = s.color.toCss();
149
	this.rawNode.strokecolor = s.color.toCss();
148
	this.rawNode.strokeweight = s.width + "px";
150
	this.rawNode.strokeweight = s.width + "px";
149
	if (this.rawNode.stroke) {
151
	if (this.rawNode.stroke) {
150
		this.rawNode.stroke.opacity = s.color.a;
152
		this.rawNode.stroke.opacity = s.color.a;
151
		this.rawNode.stroke.endcap = this._translate(this._capMap, s.cap);
153
		this.rawNode.stroke.endcap = this._translate(this._capMap, s.cap);
152
		if (typeof (s.join) == "number") {
154
		if (typeof (s.join) == "number") {
153
			this.rawNode.stroke.joinstyle = "miter";
155
			this.rawNode.stroke.joinstyle = "miter";
154
			this.rawNode.stroke.miterlimit = s.join;
156
			this.rawNode.stroke.miterlimit = s.join;
155
		} else {
157
		} else {
156
			this.rawNode.stroke.joinstyle = s.join;
158
			this.rawNode.stroke.joinstyle = s.join;
157
		}
159
		}
158
	}
160
	}
159
	return this;
161
	return this;
160
}, _capMap:{butt:"flat"}, _capMapReversed:{flat:"butt"}, _translate:function (dict, value) {
162
}, _capMap:{butt:"flat"}, _capMapReversed:{flat:"butt"}, _translate:function (dict, value) {
161
	return (value in dict) ? dict[value] : value;
163
	return (value in dict) ? dict[value] : value;
162
}, _applyTransform:function () {
164
}, _applyTransform:function () {
163
	var matrix = this._getRealMatrix();
165
	var matrix = this._getRealMatrix();
164
	if (!matrix) {
166
	if (!matrix) {
165
		return this;
167
		return this;
166
	}
168
	}
167
	var skew = this.rawNode.skew;
169
	var skew = this.rawNode.skew;
168
	if (typeof (skew) == "undefined") {
170
	if (typeof (skew) == "undefined") {
169
		for (var i = 0; i < this.rawNode.childNodes.length; ++i) {
171
		for (var i = 0; i < this.rawNode.childNodes.length; ++i) {
170
			if (this.rawNode.childNodes[i].tagName == "skew") {
172
			if (this.rawNode.childNodes[i].tagName == "skew") {
171
				skew = this.rawNode.childNodes[i];
173
				skew = this.rawNode.childNodes[i];
172
				break;
174
				break;
173
			}
175
			}
174
		}
176
		}
175
	}
177
	}
176
	if (skew) {
178
	if (skew) {
177
		skew.on = false;
179
		skew.on = false;
178
		var mt = matrix.xx.toFixed(8) + " " + matrix.xy.toFixed(8) + " " + matrix.yx.toFixed(8) + " " + matrix.yy.toFixed(8) + " 0 0";
180
		var mt = matrix.xx.toFixed(8) + " " + matrix.xy.toFixed(8) + " " + matrix.yx.toFixed(8) + " " + matrix.yy.toFixed(8) + " 0 0";
179
		var offset = Math.floor(matrix.dx).toFixed() + "px " + Math.floor(matrix.dy).toFixed() + "px";
181
		var offset = Math.floor(matrix.dx).toFixed() + "px " + Math.floor(matrix.dy).toFixed() + "px";
180
		var l = parseFloat(this.rawNode.style.left);
182
		var l = parseFloat(this.rawNode.style.left);
181
		var t = parseFloat(this.rawNode.style.top);
183
		var t = parseFloat(this.rawNode.style.top);
182
		var w = parseFloat(this.rawNode.style.width);
184
		var w = parseFloat(this.rawNode.style.width);
183
		var h = parseFloat(this.rawNode.style.height);
185
		var h = parseFloat(this.rawNode.style.height);
184
		if (isNaN(l)) {
186
		if (isNaN(l)) {
185
			l = 0;
187
			l = 0;
186
		}
188
		}
187
		if (isNaN(t)) {
189
		if (isNaN(t)) {
188
			t = 0;
190
			t = 0;
189
		}
191
		}
190
		if (isNaN(w)) {
192
		if (isNaN(w)) {
191
			w = 1;
193
			w = 1;
192
		}
194
		}
193
		if (isNaN(h)) {
195
		if (isNaN(h)) {
194
			h = 1;
196
			h = 1;
195
		}
197
		}
196
		var origin = (-l / w - 0.5).toFixed(8) + " " + (-t / h - 0.5).toFixed(8);
198
		var origin = (-l / w - 0.5).toFixed(8) + " " + (-t / h - 0.5).toFixed(8);
197
		skew.matrix = mt;
199
		skew.matrix = mt;
198
		skew.origin = origin;
200
		skew.origin = origin;
199
		skew.offset = offset;
201
		skew.offset = offset;
200
		skew.on = true;
202
		skew.on = true;
201
	}
203
	}
202
	return this;
204
	return this;
203
}, setRawNode:function (rawNode) {
205
}, setRawNode:function (rawNode) {
204
	rawNode.stroked = false;
206
	rawNode.stroked = false;
205
	rawNode.filled = false;
207
	rawNode.filled = false;
206
	this.rawNode = rawNode;
208
	this.rawNode = rawNode;
207
}, attachFill:function (rawNode) {
209
}, attachFill:function (rawNode) {
208
	var fillStyle = null;
210
	var fillStyle = null;
209
	var fo = rawNode.fill;
211
	var fo = rawNode.fill;
210
	if (rawNode) {
212
	if (rawNode) {
211
		if (fo.on && fo.type == "gradient") {
213
		if (fo.on && fo.type == "gradient") {
212
			var fillStyle = dojo.lang.shallowCopy(dojo.gfx.defaultLinearGradient, true);
214
			var fillStyle = dojo.lang.shallowCopy(dojo.gfx.defaultLinearGradient, true);
213
			var rad = dojo.math.degToRad(fo.angle);
215
			var rad = dojo.math.degToRad(fo.angle);
214
			fillStyle.x2 = Math.cos(rad);
216
			fillStyle.x2 = Math.cos(rad);
215
			fillStyle.y2 = Math.sin(rad);
217
			fillStyle.y2 = Math.sin(rad);
216
			fillStyle.colors = [];
218
			fillStyle.colors = [];
217
			var stops = fo.colors.value.split(";");
219
			var stops = fo.colors.value.split(";");
218
			for (var i = 0; i < stops.length; ++i) {
220
			for (var i = 0; i < stops.length; ++i) {
219
				var t = stops[i].match(/\S+/g);
221
				var t = stops[i].match(/\S+/g);
220
				if (!t || t.length != 2) {
222
				if (!t || t.length != 2) {
221
					continue;
223
					continue;
222
				}
224
				}
223
				fillStyle.colors.push({offset:dojo.gfx.vml._parseFloat(t[0]), color:new dojo.gfx.color.Color(t[1])});
225
				fillStyle.colors.push({offset:dojo.gfx.vml._parseFloat(t[0]), color:new dojo.gfx.color.Color(t[1])});
224
			}
226
			}
225
		} else {
227
		} else {
226
			if (fo.on && fo.type == "gradientradial") {
228
			if (fo.on && fo.type == "gradientradial") {
227
				var fillStyle = dojo.lang.shallowCopy(dojo.gfx.defaultRadialGradient, true);
229
				var fillStyle = dojo.lang.shallowCopy(dojo.gfx.defaultRadialGradient, true);
228
				var w = parseFloat(rawNode.style.width);
230
				var w = parseFloat(rawNode.style.width);
229
				var h = parseFloat(rawNode.style.height);
231
				var h = parseFloat(rawNode.style.height);
230
				fillStyle.cx = isNaN(w) ? 0 : fo.focusposition.x * w;
232
				fillStyle.cx = isNaN(w) ? 0 : fo.focusposition.x * w;
231
				fillStyle.cy = isNaN(h) ? 0 : fo.focusposition.y * h;
233
				fillStyle.cy = isNaN(h) ? 0 : fo.focusposition.y * h;
232
				fillStyle.r = isNaN(w) ? 1 : w / 2;
234
				fillStyle.r = isNaN(w) ? 1 : w / 2;
233
				fillStyle.colors = [];
235
				fillStyle.colors = [];
234
				var stops = fo.colors.value.split(";");
236
				var stops = fo.colors.value.split(";");
235
				for (var i = stops.length - 1; i >= 0; --i) {
237
				for (var i = stops.length - 1; i >= 0; --i) {
236
					var t = stops[i].match(/\S+/g);
238
					var t = stops[i].match(/\S+/g);
237
					if (!t || t.length != 2) {
239
					if (!t || t.length != 2) {
238
						continue;
240
						continue;
239
					}
241
					}
240
					fillStyle.colors.push({offset:dojo.gfx.vml._parseFloat(t[0]), color:new dojo.gfx.color.Color(t[1])});
242
					fillStyle.colors.push({offset:dojo.gfx.vml._parseFloat(t[0]), color:new dojo.gfx.color.Color(t[1])});
241
				}
243
				}
242
			} else {
244
			} else {
243
				if (fo.on && fo.type == "tile") {
245
				if (fo.on && fo.type == "tile") {
244
					var fillStyle = dojo.lang.shallowCopy(dojo.gfx.defaultPattern, true);
246
					var fillStyle = dojo.lang.shallowCopy(dojo.gfx.defaultPattern, true);
245
					fillStyle.width = dojo.gfx.vml.pt2px(fo.size.x);
247
					fillStyle.width = dojo.gfx.vml.pt2px(fo.size.x);
246
					fillStyle.height = dojo.gfx.vml.pt2px(fo.size.y);
248
					fillStyle.height = dojo.gfx.vml.pt2px(fo.size.y);
247
					fillStyle.x = fo.origin.x * fillStyle.width;
249
					fillStyle.x = fo.origin.x * fillStyle.width;
248
					fillStyle.y = fo.origin.y * fillStyle.height;
250
					fillStyle.y = fo.origin.y * fillStyle.height;
249
					fillStyle.src = fo.src;
251
					fillStyle.src = fo.src;
250
				} else {
252
				} else {
251
					if (fo.on && rawNode.fillcolor) {
253
					if (fo.on && rawNode.fillcolor) {
252
						fillStyle = new dojo.gfx.color.Color(rawNode.fillcolor + "");
254
						fillStyle = new dojo.gfx.color.Color(rawNode.fillcolor + "");
253
						fillStyle.a = fo.opacity;
255
						fillStyle.a = fo.opacity;
254
					}
256
					}
255
				}
257
				}
256
			}
258
			}
257
		}
259
		}
258
	}
260
	}
259
	return fillStyle;
261
	return fillStyle;
260
}, attachStroke:function (rawNode) {
262
}, attachStroke:function (rawNode) {
261
	var strokeStyle = dojo.lang.shallowCopy(dojo.gfx.defaultStroke, true);
263
	var strokeStyle = dojo.lang.shallowCopy(dojo.gfx.defaultStroke, true);
262
	if (rawNode && rawNode.stroked) {
264
	if (rawNode && rawNode.stroked) {
263
		strokeStyle.color = new dojo.gfx.color.Color(rawNode.strokecolor.value);
265
		strokeStyle.color = new dojo.gfx.color.Color(rawNode.strokecolor.value);
264
		dojo.debug("We are expecting an .75pt here, instead of strokeweight = " + rawNode.strokeweight);
266
		dojo.debug("We are expecting an .75pt here, instead of strokeweight = " + rawNode.strokeweight);
265
		strokeStyle.width = dojo.gfx.vml.normalizedLength(rawNode.strokeweight + "");
267
		strokeStyle.width = dojo.gfx.vml.normalizedLength(rawNode.strokeweight + "");
266
		strokeStyle.color.a = rawNode.stroke.opacity;
268
		strokeStyle.color.a = rawNode.stroke.opacity;
267
		strokeStyle.cap = this._translate(this._capMapReversed, rawNode.stroke.endcap);
269
		strokeStyle.cap = this._translate(this._capMapReversed, rawNode.stroke.endcap);
268
		strokeStyle.join = rawNode.stroke.joinstyle == "miter" ? rawNode.stroke.miterlimit : rawNode.stroke.joinstyle;
270
		strokeStyle.join = rawNode.stroke.joinstyle == "miter" ? rawNode.stroke.miterlimit : rawNode.stroke.joinstyle;
269
	} else {
271
	} else {
270
		return null;
272
		return null;
271
	}
273
	}
272
	return strokeStyle;
274
	return strokeStyle;
273
}, attachTransform:function (rawNode) {
275
}, attachTransform:function (rawNode) {
274
	var matrix = {};
276
	var matrix = {};
275
	if (rawNode) {
277
	if (rawNode) {
276
		var s = rawNode.skew;
278
		var s = rawNode.skew;
277
		matrix.xx = s.matrix.xtox;
279
		matrix.xx = s.matrix.xtox;
278
		matrix.xy = s.matrix.ytox;
280
		matrix.xy = s.matrix.ytox;
279
		matrix.yx = s.matrix.xtoy;
281
		matrix.yx = s.matrix.xtoy;
280
		matrix.yy = s.matrix.ytoy;
282
		matrix.yy = s.matrix.ytoy;
281
		matrix.dx = dojo.gfx.vml.pt2px(s.offset.x);
283
		matrix.dx = dojo.gfx.vml.pt2px(s.offset.x);
282
		matrix.dy = dojo.gfx.vml.pt2px(s.offset.y);
284
		matrix.dy = dojo.gfx.vml.pt2px(s.offset.y);
283
	}
285
	}
284
	return dojo.gfx.matrix.normalize(matrix);
286
	return dojo.gfx.matrix.normalize(matrix);
285
}, attach:function (rawNode) {
287
}, attach:function (rawNode) {
286
	if (rawNode) {
288
	if (rawNode) {
287
		this.rawNode = rawNode;
289
		this.rawNode = rawNode;
288
		this.shape = this.attachShape(rawNode);
290
		this.shape = this.attachShape(rawNode);
289
		this.fillStyle = this.attachFill(rawNode);
291
		this.fillStyle = this.attachFill(rawNode);
290
		this.strokeStyle = this.attachStroke(rawNode);
292
		this.strokeStyle = this.attachStroke(rawNode);
291
		this.matrix = this.attachTransform(rawNode);
293
		this.matrix = this.attachTransform(rawNode);
292
	}
294
	}
293
}});
295
}});
294
dojo.declare("dojo.gfx.Group", dojo.gfx.shape.VirtualGroup, {add:function (shape) {
296
dojo.declare("dojo.gfx.Group", dojo.gfx.shape.VirtualGroup, {add:function (shape) {
295
	if (this != shape.getParent()) {
297
	if (this != shape.getParent()) {
296
		this.rawNode.appendChild(shape.rawNode);
298
		this.rawNode.appendChild(shape.rawNode);
297
		dojo.gfx.Group.superclass.add.apply(this, arguments);
299
		dojo.gfx.Group.superclass.add.apply(this, arguments);
298
	}
300
	}
299
	return this;
301
	return this;
300
}, remove:function (shape, silently) {
302
}, remove:function (shape, silently) {
301
	if (this == shape.getParent()) {
303
	if (this == shape.getParent()) {
302
		if (this.rawNode == shape.rawNode.parentNode) {
304
		if (this.rawNode == shape.rawNode.parentNode) {
303
			this.rawNode.removeChild(shape.rawNode);
305
			this.rawNode.removeChild(shape.rawNode);
304
		}
306
		}
305
		dojo.gfx.Group.superclass.remove.apply(this, arguments);
307
		dojo.gfx.Group.superclass.remove.apply(this, arguments);
306
	}
308
	}
307
	return this;
309
	return this;
308
}, attach:function (rawNode) {
310
}, attach:function (rawNode) {
309
	if (rawNode) {
311
	if (rawNode) {
310
		this.rawNode = rawNode;
312
		this.rawNode = rawNode;
311
		this.shape = null;
313
		this.shape = null;
312
		this.fillStyle = null;
314
		this.fillStyle = null;
313
		this.strokeStyle = null;
315
		this.strokeStyle = null;
314
		this.matrix = null;
316
		this.matrix = null;
315
	}
317
	}
316
}});
318
}});
317
dojo.gfx.Group.nodeType = "group";
319
dojo.gfx.Group.nodeType = "group";
318
var zIndex = {moveToFront:function () {
320
var zIndex = {moveToFront:function () {
319
	this.rawNode.parentNode.appendChild(this.rawNode);
321
	this.rawNode.parentNode.appendChild(this.rawNode);
320
	return this;
322
	return this;
321
}, moveToBack:function () {
323
}, moveToBack:function () {
322
	this.rawNode.parentNode.insertBefore(this.rawNode, this.rawNode.parentNode.firstChild);
324
	this.rawNode.parentNode.insertBefore(this.rawNode, this.rawNode.parentNode.firstChild);
323
	return this;
325
	return this;
324
}};
326
}};
325
dojo.lang.extend(dojo.gfx.Shape, zIndex);
327
dojo.lang.extend(dojo.gfx.Shape, zIndex);
326
dojo.lang.extend(dojo.gfx.Group, zIndex);
328
dojo.lang.extend(dojo.gfx.Group, zIndex);
327
delete zIndex;
329
delete zIndex;
328
dojo.declare("dojo.gfx.Rect", dojo.gfx.shape.Rect, {attachShape:function (rawNode) {
330
dojo.declare("dojo.gfx.Rect", dojo.gfx.shape.Rect, {attachShape:function (rawNode) {
329
	var arcsize = rawNode.outerHTML.match(/arcsize = \"(\d*\.?\d+[%f]?)\"/)[1];
331
	var arcsize = rawNode.outerHTML.match(/arcsize = \"(\d*\.?\d+[%f]?)\"/)[1];
330
	arcsize = (arcsize.indexOf("%") >= 0) ? parseFloat(arcsize) / 100 : dojo.gfx.vml._parseFloat(arcsize);
332
	arcsize = (arcsize.indexOf("%") >= 0) ? parseFloat(arcsize) / 100 : dojo.gfx.vml._parseFloat(arcsize);
331
	var style = rawNode.style;
333
	var style = rawNode.style;
332
	var width = parseFloat(style.width);
334
	var width = parseFloat(style.width);
333
	var height = parseFloat(style.height);
335
	var height = parseFloat(style.height);
334
	var o = dojo.gfx.makeParameters(dojo.gfx.defaultRect, {x:parseInt(style.left), y:parseInt(style.top), width:width, height:height, r:Math.min(width, height) * arcsize});
336
	var o = dojo.gfx.makeParameters(dojo.gfx.defaultRect, {x:parseInt(style.left), y:parseInt(style.top), width:width, height:height, r:Math.min(width, height) * arcsize});
335
	return o;
337
	return o;
336
}, setShape:function (newShape) {
338
}, setShape:function (newShape) {
337
	var shape = this.shape = dojo.gfx.makeParameters(this.shape, newShape);
339
	var shape = this.shape = dojo.gfx.makeParameters(this.shape, newShape);
338
	this.bbox = null;
340
	this.bbox = null;
339
	var style = this.rawNode.style;
341
	var style = this.rawNode.style;
340
	style.left = shape.x.toFixed();
342
	style.left = shape.x.toFixed();
341
	style.top = shape.y.toFixed();
343
	style.top = shape.y.toFixed();
342
	style.width = (typeof (shape.width) == "string" && shape.width.indexOf("%") >= 0) ? shape.width : shape.width.toFixed();
344
	style.width = (typeof (shape.width) == "string" && shape.width.indexOf("%") >= 0) ? shape.width : shape.width.toFixed();
343
	style.height = (typeof (shape.width) == "string" && shape.height.indexOf("%") >= 0) ? shape.height : shape.height.toFixed();
345
	style.height = (typeof (shape.width) == "string" && shape.height.indexOf("%") >= 0) ? shape.height : shape.height.toFixed();
344
	var r = Math.min(1, (shape.r / Math.min(parseFloat(shape.width), parseFloat(shape.height)))).toFixed(8);
346
	var r = Math.min(1, (shape.r / Math.min(parseFloat(shape.width), parseFloat(shape.height)))).toFixed(8);
345
	var parent = this.rawNode.parentNode;
347
	var parent = this.rawNode.parentNode;
346
	var before = null;
348
	var before = null;
347
	if (parent) {
349
	if (parent) {
348
		if (parent.lastChild != this.rawNode) {
350
		if (parent.lastChild != this.rawNode) {
349
			for (var i = 0; i < parent.childNodes.length; ++i) {
351
			for (var i = 0; i < parent.childNodes.length; ++i) {
350
				if (parent.childNodes[i] == this.rawNode) {
352
				if (parent.childNodes[i] == this.rawNode) {
351
					before = parent.childNodes[i + 1];
353
					before = parent.childNodes[i + 1];
352
					break;
354
					break;
353
				}
355
				}
354
			}
356
			}
355
		}
357
		}
356
		parent.removeChild(this.rawNode);
358
		parent.removeChild(this.rawNode);
357
	}
359
	}
358
	this.rawNode.arcsize = r;
360
	this.rawNode.arcsize = r;
359
	if (parent) {
361
	if (parent) {
360
		if (before) {
362
		if (before) {
361
			parent.insertBefore(this.rawNode, before);
363
			parent.insertBefore(this.rawNode, before);
362
		} else {
364
		} else {
363
			parent.appendChild(this.rawNode);
365
			parent.appendChild(this.rawNode);
364
		}
366
		}
365
	}
367
	}
366
	return this.setTransform(this.matrix);
368
	return this.setTransform(this.matrix);
367
}});
369
}});
368
dojo.gfx.Rect.nodeType = "roundrect";
370
dojo.gfx.Rect.nodeType = "roundrect";
369
dojo.declare("dojo.gfx.Ellipse", dojo.gfx.shape.Ellipse, {attachShape:function (rawNode) {
371
dojo.declare("dojo.gfx.Ellipse", dojo.gfx.shape.Ellipse, {attachShape:function (rawNode) {
370
	var style = this.rawNode.style;
372
	var style = this.rawNode.style;
371
	var rx = parseInt(style.width) / 2;
373
	var rx = parseInt(style.width) / 2;
372
	var ry = parseInt(style.height) / 2;
374
	var ry = parseInt(style.height) / 2;
373
	var o = dojo.gfx.makeParameters(dojo.gfx.defaultEllipse, {cx:parseInt(style.left) + rx, cy:parseInt(style.top) + ry, rx:rx, ry:ry});
375
	var o = dojo.gfx.makeParameters(dojo.gfx.defaultEllipse, {cx:parseInt(style.left) + rx, cy:parseInt(style.top) + ry, rx:rx, ry:ry});
374
	return o;
376
	return o;
375
}, setShape:function (newShape) {
377
}, setShape:function (newShape) {
376
	var shape = this.shape = dojo.gfx.makeParameters(this.shape, newShape);
378
	var shape = this.shape = dojo.gfx.makeParameters(this.shape, newShape);
377
	this.bbox = null;
379
	this.bbox = null;
378
	var style = this.rawNode.style;
380
	var style = this.rawNode.style;
379
	style.left = (shape.cx - shape.rx).toFixed();
381
	style.left = (shape.cx - shape.rx).toFixed();
380
	style.top = (shape.cy - shape.ry).toFixed();
382
	style.top = (shape.cy - shape.ry).toFixed();
381
	style.width = (shape.rx * 2).toFixed();
383
	style.width = (shape.rx * 2).toFixed();
382
	style.height = (shape.ry * 2).toFixed();
384
	style.height = (shape.ry * 2).toFixed();
383
	return this.setTransform(this.matrix);
385
	return this.setTransform(this.matrix);
384
}});
386
}});
385
dojo.gfx.Ellipse.nodeType = "oval";
387
dojo.gfx.Ellipse.nodeType = "oval";
386
dojo.declare("dojo.gfx.Circle", dojo.gfx.shape.Circle, {attachShape:function (rawNode) {
388
dojo.declare("dojo.gfx.Circle", dojo.gfx.shape.Circle, {attachShape:function (rawNode) {
387
	var style = this.rawNode.style;
389
	var style = this.rawNode.style;
388
	var r = parseInt(style.width) / 2;
390
	var r = parseInt(style.width) / 2;
389
	var o = dojo.gfx.makeParameters(dojo.gfx.defaultCircle, {cx:parseInt(style.left) + r, cy:parseInt(style.top) + r, r:r});
391
	var o = dojo.gfx.makeParameters(dojo.gfx.defaultCircle, {cx:parseInt(style.left) + r, cy:parseInt(style.top) + r, r:r});
390
	return o;
392
	return o;
391
}, setShape:function (newShape) {
393
}, setShape:function (newShape) {
392
	var shape = this.shape = dojo.gfx.makeParameters(this.shape, newShape);
394
	var shape = this.shape = dojo.gfx.makeParameters(this.shape, newShape);
393
	this.bbox = null;
395
	this.bbox = null;
394
	var style = this.rawNode.style;
396
	var style = this.rawNode.style;
395
	style.left = (shape.cx - shape.r).toFixed();
397
	style.left = (shape.cx - shape.r).toFixed();
396
	style.top = (shape.cy - shape.r).toFixed();
398
	style.top = (shape.cy - shape.r).toFixed();
397
	style.width = (shape.r * 2).toFixed();
399
	style.width = (shape.r * 2).toFixed();
398
	style.height = (shape.r * 2).toFixed();
400
	style.height = (shape.r * 2).toFixed();
399
	return this;
401
	return this;
400
}});
402
}});
401
dojo.gfx.Circle.nodeType = "oval";
403
dojo.gfx.Circle.nodeType = "oval";
402
dojo.declare("dojo.gfx.Line", dojo.gfx.shape.Line, function (rawNode) {
404
dojo.declare("dojo.gfx.Line", dojo.gfx.shape.Line, function (rawNode) {
403
	if (rawNode) {
405
	if (rawNode) {
404
		rawNode.setAttribute("dojoGfxType", "line");
406
		rawNode.setAttribute("dojoGfxType", "line");
405
	}
407
	}
406
}, {attachShape:function (rawNode) {
408
}, {attachShape:function (rawNode) {
407
	var p = rawNode.path.v.match(dojo.gfx.pathRegExp);
409
	var p = rawNode.path.v.match(dojo.gfx.pathRegExp);
408
	var shape = {};
410
	var shape = {};
409
	do {
411
	do {
410
		if (p.length < 7 || p[0] != "m" || p[3] != "l" || p[6] != "e") {
412
		if (p.length < 7 || p[0] != "m" || p[3] != "l" || p[6] != "e") {
411
			break;
413
			break;
412
		}
414
		}
413
		shape.x1 = parseInt(p[1]);
415
		shape.x1 = parseInt(p[1]);
414
		shape.y1 = parseInt(p[2]);
416
		shape.y1 = parseInt(p[2]);
415
		shape.x2 = parseInt(p[4]);
417
		shape.x2 = parseInt(p[4]);
416
		shape.y2 = parseInt(p[5]);
418
		shape.y2 = parseInt(p[5]);
417
	} while (false);
419
	} while (false);
418
	return dojo.gfx.makeParameters(dojo.gfx.defaultLine, shape);
420
	return dojo.gfx.makeParameters(dojo.gfx.defaultLine, shape);
419
}, setShape:function (newShape) {
421
}, setShape:function (newShape) {
420
	var shape = this.shape = dojo.gfx.makeParameters(this.shape, newShape);
422
	var shape = this.shape = dojo.gfx.makeParameters(this.shape, newShape);
421
	this.bbox = null;
423
	this.bbox = null;
422
	this.rawNode.path.v = "m" + shape.x1.toFixed() + " " + shape.y1.toFixed() + "l" + shape.x2.toFixed() + " " + shape.y2.toFixed() + "e";
424
	this.rawNode.path.v = "m" + shape.x1.toFixed() + " " + shape.y1.toFixed() + "l" + shape.x2.toFixed() + " " + shape.y2.toFixed() + "e";
423
	return this.setTransform(this.matrix);
425
	return this.setTransform(this.matrix);
424
}});
426
}});
425
dojo.gfx.Line.nodeType = "shape";
427
dojo.gfx.Line.nodeType = "shape";
426
dojo.declare("dojo.gfx.Polyline", dojo.gfx.shape.Polyline, function (rawNode) {
428
dojo.declare("dojo.gfx.Polyline", dojo.gfx.shape.Polyline, function (rawNode) {
427
	if (rawNode) {
429
	if (rawNode) {
428
		rawNode.setAttribute("dojoGfxType", "polyline");
430
		rawNode.setAttribute("dojoGfxType", "polyline");
429
	}
431
	}
430
}, {attachShape:function (rawNode) {
432
}, {attachShape:function (rawNode) {
431
	var shape = dojo.lang.shallowCopy(dojo.gfx.defaultPolyline, true);
433
	var shape = dojo.lang.shallowCopy(dojo.gfx.defaultPolyline, true);
432
	var p = rawNode.path.v.match(dojo.gfx.pathRegExp);
434
	var p = rawNode.path.v.match(dojo.gfx.pathRegExp);
433
	do {
435
	do {
434
		if (p.length < 3 || p[0] != "m") {
436
		if (p.length < 3 || p[0] != "m") {
435
			break;
437
			break;
436
		}
438
		}
437
		var x = parseInt(p[0]);
439
		var x = parseInt(p[0]);
438
		var y = parseInt(p[1]);
440
		var y = parseInt(p[1]);
439
		if (isNaN(x) || isNaN(y)) {
441
		if (isNaN(x) || isNaN(y)) {
440
			break;
442
			break;
441
		}
443
		}
442
		shape.points.push({x:x, y:y});
444
		shape.points.push({x:x, y:y});
443
		if (p.length < 6 || p[3] != "l") {
445
		if (p.length < 6 || p[3] != "l") {
444
			break;
446
			break;
445
		}
447
		}
446
		for (var i = 4; i < p.length; i += 2) {
448
		for (var i = 4; i < p.length; i += 2) {
447
			x = parseInt(p[i]);
449
			x = parseInt(p[i]);
448
			y = parseInt(p[i + 1]);
450
			y = parseInt(p[i + 1]);
449
			if (isNaN(x) || isNaN(y)) {
451
			if (isNaN(x) || isNaN(y)) {
450
				break;
452
				break;
451
			}
453
			}
452
			shape.points.push({x:x, y:y});
454
			shape.points.push({x:x, y:y});
453
		}
455
		}
454
	} while (false);
456
	} while (false);
455
	return shape;
457
	return shape;
456
}, setShape:function (points, closed) {
458
}, setShape:function (points, closed) {
457
	if (points && points instanceof Array) {
459
	if (points && points instanceof Array) {
458
		this.shape = dojo.gfx.makeParameters(this.shape, {points:points});
460
		this.shape = dojo.gfx.makeParameters(this.shape, {points:points});
459
		if (closed && this.shape.points.length) {
461
		if (closed && this.shape.points.length) {
460
			this.shape.points.push(this.shape.points[0]);
462
			this.shape.points.push(this.shape.points[0]);
461
		}
463
		}
462
	} else {
464
	} else {
463
		this.shape = dojo.gfx.makeParameters(this.shape, points);
465
		this.shape = dojo.gfx.makeParameters(this.shape, points);
464
	}
466
	}
465
	this.bbox = null;
467
	this.bbox = null;
466
	var attr = [];
468
	var attr = [];
467
	var p = this.shape.points;
469
	var p = this.shape.points;
468
	if (p.length > 0) {
470
	if (p.length > 0) {
469
		attr.push("m");
471
		attr.push("m");
470
		attr.push(p[0].x.toFixed());
472
		attr.push(p[0].x.toFixed());
471
		attr.push(p[0].y.toFixed());
473
		attr.push(p[0].y.toFixed());
472
		if (p.length > 1) {
474
		if (p.length > 1) {
473
			attr.push("l");
475
			attr.push("l");
474
			for (var i = 1; i < p.length; ++i) {
476
			for (var i = 1; i < p.length; ++i) {
475
				attr.push(p[i].x.toFixed());
477
				attr.push(p[i].x.toFixed());
476
				attr.push(p[i].y.toFixed());
478
				attr.push(p[i].y.toFixed());
477
			}
479
			}
478
		}
480
		}
479
	}
481
	}
480
	attr.push("e");
482
	attr.push("e");
481
	this.rawNode.path.v = attr.join(" ");
483
	this.rawNode.path.v = attr.join(" ");
482
	return this.setTransform(this.matrix);
484
	return this.setTransform(this.matrix);
483
}});
485
}});
484
dojo.gfx.Polyline.nodeType = "shape";
486
dojo.gfx.Polyline.nodeType = "shape";
485
dojo.declare("dojo.gfx.Image", dojo.gfx.shape.Image, {getEventSource:function () {
487
dojo.declare("dojo.gfx.Image", dojo.gfx.shape.Image, {getEventSource:function () {
486
	return this.rawNode ? this.rawNode.firstChild : null;
488
	return this.rawNode ? this.rawNode.firstChild : null;
487
}, attachShape:function (rawNode) {
489
}, attachShape:function (rawNode) {
488
	var shape = dojo.lang.shallowCopy(dojo.gfx.defaultImage, true);
490
	var shape = dojo.lang.shallowCopy(dojo.gfx.defaultImage, true);
489
	shape.src = rawNode.firstChild.src;
491
	shape.src = rawNode.firstChild.src;
490
	return shape;
492
	return shape;
491
}, setShape:function (newShape) {
493
}, setShape:function (newShape) {
492
	var shape = this.shape = dojo.gfx.makeParameters(this.shape, newShape);
494
	var shape = this.shape = dojo.gfx.makeParameters(this.shape, newShape);
493
	this.bbox = null;
495
	this.bbox = null;
494
	var firstChild = this.rawNode.firstChild;
496
	var firstChild = this.rawNode.firstChild;
495
	firstChild.src = shape.src;
497
	firstChild.src = shape.src;
496
	if (shape.width || shape.height) {
498
	if (shape.width || shape.height) {
497
		firstChild.style.width = shape.width;
499
		firstChild.style.width = shape.width;
498
		firstChild.style.height = shape.height;
500
		firstChild.style.height = shape.height;
499
	}
501
	}
500
	return this.setTransform(this.matrix);
502
	return this.setTransform(this.matrix);
501
}, setStroke:function () {
503
}, setStroke:function () {
502
	return this;
504
	return this;
503
}, setFill:function () {
505
}, setFill:function () {
504
	return this;
506
	return this;
505
}, attachStroke:function (rawNode) {
507
}, attachStroke:function (rawNode) {
506
	return null;
508
	return null;
507
}, attachFill:function (rawNode) {
509
}, attachFill:function (rawNode) {
508
	return null;
510
	return null;
509
}, attachTransform:function (rawNode) {
511
}, attachTransform:function (rawNode) {
510
	var matrix = {};
512
	var matrix = {};
511
	if (rawNode) {
513
	if (rawNode) {
512
		var m = rawNode.filters["DXImageTransform.Microsoft.Matrix"];
514
		var m = rawNode.filters["DXImageTransform.Microsoft.Matrix"];
513
		matrix.xx = m.M11;
515
		matrix.xx = m.M11;
514
		matrix.xy = m.M12;
516
		matrix.xy = m.M12;
515
		matrix.yx = m.M21;
517
		matrix.yx = m.M21;
516
		matrix.yy = m.M22;
518
		matrix.yy = m.M22;
517
		matrix.dx = m.Dx;
519
		matrix.dx = m.Dx;
518
		matrix.dy = m.Dy;
520
		matrix.dy = m.Dy;
519
	}
521
	}
520
	return dojo.gfx.matrix.normalize(matrix);
522
	return dojo.gfx.matrix.normalize(matrix);
521
}, _applyTransform:function () {
523
}, _applyTransform:function () {
522
	var matrix = this._getRealMatrix();
524
	var matrix = this._getRealMatrix();
523
	if (!matrix) {
525
	if (!matrix) {
524
		return this;
526
		return this;
525
	}
527
	}
526
	with (this.rawNode.filters["DXImageTransform.Microsoft.Matrix"]) {
528
	with (this.rawNode.filters["DXImageTransform.Microsoft.Matrix"]) {
527
		M11 = matrix.xx;
529
		M11 = matrix.xx;
528
		M12 = matrix.xy;
530
		M12 = matrix.xy;
529
		M21 = matrix.yx;
531
		M21 = matrix.yx;
530
		M22 = matrix.yy;
532
		M22 = matrix.yy;
531
		Dx = matrix.dx;
533
		Dx = matrix.dx;
532
		Dy = matrix.dy;
534
		Dy = matrix.dy;
533
	}
535
	}
534
	return this;
536
	return this;
535
}});
537
}});
536
dojo.gfx.Image.nodeType = "image";
538
dojo.gfx.Image.nodeType = "image";
537
dojo.gfx.path._calcArc = function (alpha) {
539
dojo.gfx.path._calcArc = function (alpha) {
538
	var cosa = Math.cos(alpha);
540
	var cosa = Math.cos(alpha);
539
	var sina = Math.sin(alpha);
541
	var sina = Math.sin(alpha);
540
	var p2 = {x:cosa + (4 / 3) * (1 - cosa), y:sina - (4 / 3) * cosa * (1 - cosa) / sina};
542
	var p2 = {x:cosa + (4 / 3) * (1 - cosa), y:sina - (4 / 3) * cosa * (1 - cosa) / sina};
541
	return {s:{x:cosa, y:sina}, c1:p2, c2:{x:p2.x, y:-p2.y}, e:{x:cosa, y:-sina}};
543
	return {s:{x:cosa, y:sina}, c1:p2, c2:{x:p2.x, y:-p2.y}, e:{x:cosa, y:-sina}};
542
};
544
};
543
dojo.declare("dojo.gfx.Path", dojo.gfx.path.Path, function (rawNode) {
545
dojo.declare("dojo.gfx.Path", dojo.gfx.path.Path, function (rawNode) {
544
	if (rawNode) {
546
	if (rawNode) {
545
		rawNode.setAttribute("dojoGfxType", "path");
547
		rawNode.setAttribute("dojoGfxType", "path");
546
	}
548
	}
547
	this.vmlPath = "";
549
	this.vmlPath = "";
548
	this.lastControl = {};
550
	this.lastControl = {};
549
}, {_updateWithSegment:function (segment) {
551
}, {_updateWithSegment:function (segment) {
550
	var last = dojo.lang.shallowCopy(this.last);
552
	var last = dojo.lang.shallowCopy(this.last);
551
	dojo.gfx.Path.superclass._updateWithSegment.apply(this, arguments);
553
	dojo.gfx.Path.superclass._updateWithSegment.apply(this, arguments);
552
	var path = this[this.renderers[segment.action]](segment, last);
554
	var path = this[this.renderers[segment.action]](segment, last);
553
	if (typeof (this.vmlPath) == "string") {
555
	if (typeof (this.vmlPath) == "string") {
554
		this.vmlPath += path.join("");
556
		this.vmlPath += path.join("");
555
	} else {
557
	} else {
556
		this.vmlPath = this.vmlPath.concat(path);
558
		this.vmlPath = this.vmlPath.concat(path);
557
	}
559
	}
558
	if (typeof (this.vmlPath) == "string") {
560
	if (typeof (this.vmlPath) == "string") {
559
		this.rawNode.path.v = this.vmlPath + " e";
561
		this.rawNode.path.v = this.vmlPath + " e";
560
	}
562
	}
561
}, attachShape:function (rawNode) {
563
}, attachShape:function (rawNode) {
562
	var shape = dojo.lang.shallowCopy(dojo.gfx.defaultPath, true);
564
	var shape = dojo.lang.shallowCopy(dojo.gfx.defaultPath, true);
563
	var p = rawNode.path.v.match(dojo.gfx.pathRegExp);
565
	var p = rawNode.path.v.match(dojo.gfx.pathRegExp);
564
	var t = [], skip = false;
566
	var t = [], skip = false;
565
	for (var i = 0; i < p.length; ++p) {
567
	for (var i = 0; i < p.length; ++p) {
566
		var s = p[i];
568
		var s = p[i];
567
		if (s in this._pathVmlToSvgMap) {
569
		if (s in this._pathVmlToSvgMap) {
568
			skip = false;
570
			skip = false;
569
			t.push(this._pathVmlToSvgMap[s]);
571
			t.push(this._pathVmlToSvgMap[s]);
570
		} else {
572
		} else {
571
			if (!skip) {
573
			if (!skip) {
572
				var n = parseInt(s);
574
				var n = parseInt(s);
573
				if (isNaN(n)) {
575
				if (isNaN(n)) {
574
					skip = true;
576
					skip = true;
575
				} else {
577
				} else {
576
					t.push(n);
578
					t.push(n);
577
				}
579
				}
578
			}
580
			}
579
		}
581
		}
580
	}
582
	}
581
	if (t.length) {
583
	if (t.length) {
582
		shape.path = t.join(" ");
584
		shape.path = t.join(" ");
583
	}
585
	}
584
	return shape;
586
	return shape;
585
}, setShape:function (newShape) {
587
}, setShape:function (newShape) {
586
	this.vmlPath = [];
588
	this.vmlPath = [];
587
	this.lastControl = {};
589
	this.lastControl = {};
588
	dojo.gfx.Path.superclass.setShape.apply(this, arguments);
590
	dojo.gfx.Path.superclass.setShape.apply(this, arguments);
589
	this.vmlPath = this.vmlPath.join("");
591
	this.vmlPath = this.vmlPath.join("");
590
	this.rawNode.path.v = this.vmlPath + " e";
592
	this.rawNode.path.v = this.vmlPath + " e";
591
	return this;
593
	return this;
592
}, _pathVmlToSvgMap:{m:"M", l:"L", t:"m", r:"l", c:"C", v:"c", qb:"Q", x:"z", e:""}, renderers:{M:"_moveToA", m:"_moveToR", L:"_lineToA", l:"_lineToR", H:"_hLineToA", h:"_hLineToR", V:"_vLineToA", v:"_vLineToR", C:"_curveToA", c:"_curveToR", S:"_smoothCurveToA", s:"_smoothCurveToR", Q:"_qCurveToA", q:"_qCurveToR", T:"_qSmoothCurveToA", t:"_qSmoothCurveToR", A:"_arcTo", a:"_arcTo", Z:"_closePath", z:"_closePath"}, _addArgs:function (path, args, from, upto) {
594
}, _pathVmlToSvgMap:{m:"M", l:"L", t:"m", r:"l", c:"C", v:"c", qb:"Q", x:"z", e:""}, renderers:{M:"_moveToA", m:"_moveToR", L:"_lineToA", l:"_lineToR", H:"_hLineToA", h:"_hLineToR", V:"_vLineToA", v:"_vLineToR", C:"_curveToA", c:"_curveToR", S:"_smoothCurveToA", s:"_smoothCurveToR", Q:"_qCurveToA", q:"_qCurveToR", T:"_qSmoothCurveToA", t:"_qSmoothCurveToR", A:"_arcTo", a:"_arcTo", Z:"_closePath", z:"_closePath"}, _addArgs:function (path, args, from, upto) {
593
	if (typeof (upto) == "undefined") {
595
	if (typeof (upto) == "undefined") {
594
		upto = args.length;
596
		upto = args.length;
595
	}
597
	}
596
	if (typeof (from) == "undefined") {
598
	if (typeof (from) == "undefined") {
597
		from = 0;
599
		from = 0;
598
	}
600
	}
599
	for (var i = from; i < upto; ++i) {
601
	for (var i = from; i < upto; ++i) {
600
		path.push(" ");
602
		path.push(" ");
601
		path.push(args[i].toFixed());
603
		path.push(args[i].toFixed());
602
	}
604
	}
603
}, _addArgsAdjusted:function (path, last, args, from, upto) {
605
}, _addArgsAdjusted:function (path, last, args, from, upto) {
604
	if (typeof (upto) == "undefined") {
606
	if (typeof (upto) == "undefined") {
605
		upto = args.length;
607
		upto = args.length;
606
	}
608
	}
607
	if (typeof (from) == "undefined") {
609
	if (typeof (from) == "undefined") {
608
		from = 0;
610
		from = 0;
609
	}
611
	}
610
	for (var i = from; i < upto; i += 2) {
612
	for (var i = from; i < upto; i += 2) {
611
		path.push(" ");
613
		path.push(" ");
612
		path.push((last.x + args[i]).toFixed());
614
		path.push((last.x + args[i]).toFixed());
613
		path.push(" ");
615
		path.push(" ");
614
		path.push((last.y + args[i + 1]).toFixed());
616
		path.push((last.y + args[i + 1]).toFixed());
615
	}
617
	}
616
}, _moveToA:function (segment) {
618
}, _moveToA:function (segment) {
617
	var p = [" m"];
619
	var p = [" m"];
618
	var n = segment.args;
620
	var n = segment.args;
619
	var l = n.length;
621
	var l = n.length;
620
	if (l == 2) {
622
	if (l == 2) {
621
		this._addArgs(p, n);
623
		this._addArgs(p, n);
622
	} else {
624
	} else {
623
		this._addArgs(p, n, 0, 2);
625
		this._addArgs(p, n, 0, 2);
624
		p.push(" l");
626
		p.push(" l");
625
		this._addArgs(p, n, 2);
627
		this._addArgs(p, n, 2);
626
	}
628
	}
627
	this.lastControl = {};
629
	this.lastControl = {};
628
	return p;
630
	return p;
629
}, _moveToR:function (segment, last) {
631
}, _moveToR:function (segment, last) {
630
	var p = ["x" in last ? " t" : " m"];
632
	var p = ["x" in last ? " t" : " m"];
631
	var n = segment.args;
633
	var n = segment.args;
632
	var l = n.length;
634
	var l = n.length;
633
	if (l == 2) {
635
	if (l == 2) {
634
		this._addArgs(p, n);
636
		this._addArgs(p, n);
635
	} else {
637
	} else {
636
		this._addArgs(p, n, 0, 2);
638
		this._addArgs(p, n, 0, 2);
637
		p.push(" r");
639
		p.push(" r");
638
		this._addArgs(p, n, 2);
640
		this._addArgs(p, n, 2);
639
	}
641
	}
640
	this.lastControl = {};
642
	this.lastControl = {};
641
	return p;
643
	return p;
642
}, _lineToA:function (segment) {
644
}, _lineToA:function (segment) {
643
	var p = [" l"];
645
	var p = [" l"];
644
	this._addArgs(p, segment.args);
646
	this._addArgs(p, segment.args);
645
	this.lastControl = {};
647
	this.lastControl = {};
646
	return p;
648
	return p;
647
}, _lineToR:function (segment) {
649
}, _lineToR:function (segment) {
648
	var p = [" r"];
650
	var p = [" r"];
649
	this._addArgs(p, segment.args);
651
	this._addArgs(p, segment.args);
650
	this.lastControl = {};
652
	this.lastControl = {};
651
	return p;
653
	return p;
652
}, _hLineToA:function (segment, last) {
654
}, _hLineToA:function (segment, last) {
653
	var p = [" l"];
655
	var p = [" l"];
654
	var n = segment.args;
656
	var n = segment.args;
655
	var l = n.length;
657
	var l = n.length;
656
	var y = " " + last.y.toFixed();
658
	var y = " " + last.y.toFixed();
657
	for (var i = 0; i < l; ++i) {
659
	for (var i = 0; i < l; ++i) {
658
		p.push(" ");
660
		p.push(" ");
659
		p.push(n[i].toFixed());
661
		p.push(n[i].toFixed());
660
		p.push(y);
662
		p.push(y);
661
	}
663
	}
662
	this.lastControl = {};
664
	this.lastControl = {};
663
	return p;
665
	return p;
664
}, _hLineToR:function (segment) {
666
}, _hLineToR:function (segment) {
665
	var p = [" r"];
667
	var p = [" r"];
666
	var n = segment.args;
668
	var n = segment.args;
667
	var l = n.length;
669
	var l = n.length;
668
	for (var i = 0; i < l; ++i) {
670
	for (var i = 0; i < l; ++i) {
669
		p.push(" ");
671
		p.push(" ");
670
		p.push(n[i].toFixed());
672
		p.push(n[i].toFixed());
671
		p.push(" 0");
673
		p.push(" 0");
672
	}
674
	}
673
	this.lastControl = {};
675
	this.lastControl = {};
674
	return p;
676
	return p;
675
}, _vLineToA:function (segment, last) {
677
}, _vLineToA:function (segment, last) {
676
	var p = [" l"];
678
	var p = [" l"];
677
	var n = segment.args;
679
	var n = segment.args;
678
	var l = n.length;
680
	var l = n.length;
679
	var x = " " + last.x.toFixed();
681
	var x = " " + last.x.toFixed();
680
	for (var i = 0; i < l; ++i) {
682
	for (var i = 0; i < l; ++i) {
681
		p.push(x);
683
		p.push(x);
682
		p.push(" ");
684
		p.push(" ");
683
		p.push(n[i].toFixed());
685
		p.push(n[i].toFixed());
684
	}
686
	}
685
	this.lastControl = {};
687
	this.lastControl = {};
686
	return p;
688
	return p;
687
}, _vLineToR:function (segment) {
689
}, _vLineToR:function (segment) {
688
	var p = [" r"];
690
	var p = [" r"];
689
	var n = segment.args;
691
	var n = segment.args;
690
	var l = n.length;
692
	var l = n.length;
691
	for (var i = 0; i < l; ++i) {
693
	for (var i = 0; i < l; ++i) {
692
		p.push(" 0 ");
694
		p.push(" 0 ");
693
		p.push(n[i].toFixed());
695
		p.push(n[i].toFixed());
694
	}
696
	}
695
	this.lastControl = {};
697
	this.lastControl = {};
696
	return p;
698
	return p;
697
}, _curveToA:function (segment) {
699
}, _curveToA:function (segment) {
698
	var p = [];
700
	var p = [];
699
	var n = segment.args;
701
	var n = segment.args;
700
	var l = n.length;
702
	var l = n.length;
701
	for (var i = 0; i < l; i += 6) {
703
	for (var i = 0; i < l; i += 6) {
702
		p.push(" c");
704
		p.push(" c");
703
		this._addArgs(p, n, i, i + 6);
705
		this._addArgs(p, n, i, i + 6);
704
	}
706
	}
705
	this.lastControl = {x:n[l - 4], y:n[l - 3], type:"C"};
707
	this.lastControl = {x:n[l - 4], y:n[l - 3], type:"C"};
706
	return p;
708
	return p;
707
}, _curveToR:function (segment, last) {
709
}, _curveToR:function (segment, last) {
708
	var p = [];
710
	var p = [];
709
	var n = segment.args;
711
	var n = segment.args;
710
	var l = n.length;
712
	var l = n.length;
711
	for (var i = 0; i < l; i += 6) {
713
	for (var i = 0; i < l; i += 6) {
712
		p.push(" v");
714
		p.push(" v");
713
		this._addArgs(p, n, i, i + 6);
715
		this._addArgs(p, n, i, i + 6);
714
		this.lastControl = {x:last.x + n[i + 2], y:last.y + n[i + 3]};
716
		this.lastControl = {x:last.x + n[i + 2], y:last.y + n[i + 3]};
715
		last.x += n[i + 4];
717
		last.x += n[i + 4];
716
		last.y += n[i + 5];
718
		last.y += n[i + 5];
717
	}
719
	}
718
	this.lastControl.type = "C";
720
	this.lastControl.type = "C";
719
	return p;
721
	return p;
720
}, _smoothCurveToA:function (segment, last) {
722
}, _smoothCurveToA:function (segment, last) {
721
	var p = [];
723
	var p = [];
722
	var n = segment.args;
724
	var n = segment.args;
723
	var l = n.length;
725
	var l = n.length;
724
	for (var i = 0; i < l; i += 4) {
726
	for (var i = 0; i < l; i += 4) {
725
		p.push(" c");
727
		p.push(" c");
726
		if (this.lastControl.type == "C") {
728
		if (this.lastControl.type == "C") {
727
			this._addArgs(p, [2 * last.x - this.lastControl.x, 2 * last.y - this.lastControl.y]);
729
			this._addArgs(p, [2 * last.x - this.lastControl.x, 2 * last.y - this.lastControl.y]);
728
		} else {
730
		} else {
729
			this._addArgs(p, [last.x, last.y]);
731
			this._addArgs(p, [last.x, last.y]);
730
		}
732
		}
731
		this._addArgs(p, n, i, i + 4);
733
		this._addArgs(p, n, i, i + 4);
732
	}
734
	}
733
	this.lastControl = {x:n[l - 4], y:n[l - 3], type:"C"};
735
	this.lastControl = {x:n[l - 4], y:n[l - 3], type:"C"};
734
	return p;
736
	return p;
735
}, _smoothCurveToR:function (segment, last) {
737
}, _smoothCurveToR:function (segment, last) {
736
	var p = [];
738
	var p = [];
737
	var n = segment.args;
739
	var n = segment.args;
738
	var l = n.length;
740
	var l = n.length;
739
	for (var i = 0; i < l; i += 4) {
741
	for (var i = 0; i < l; i += 4) {
740
		p.push(" v");
742
		p.push(" v");
741
		if (this.lastControl.type == "C") {
743
		if (this.lastControl.type == "C") {
742
			this._addArgs(p, [last.x - this.lastControl.x, last.y - this.lastControl.y]);
744
			this._addArgs(p, [last.x - this.lastControl.x, last.y - this.lastControl.y]);
743
		} else {
745
		} else {
744
			this._addArgs(p, [0, 0]);
746
			this._addArgs(p, [0, 0]);
745
		}
747
		}
746
		this._addArgs(p, n, i, i + 4);
748
		this._addArgs(p, n, i, i + 4);
747
		this.lastControl = {x:last.x + n[i], y:last.y + n[i + 1]};
749
		this.lastControl = {x:last.x + n[i], y:last.y + n[i + 1]};
748
		last.x += n[i + 2];
750
		last.x += n[i + 2];
749
		last.y += n[i + 3];
751
		last.y += n[i + 3];
750
	}
752
	}
751
	this.lastControl.type = "C";
753
	this.lastControl.type = "C";
752
	return p;
754
	return p;
753
}, _qCurveToA:function (segment) {
755
}, _qCurveToA:function (segment) {
754
	var p = [];
756
	var p = [];
755
	var n = segment.args;
757
	var n = segment.args;
756
	var l = n.length;
758
	var l = n.length;
757
	for (var i = 0; i < l; i += 4) {
759
	for (var i = 0; i < l; i += 4) {
758
		p.push(" qb");
760
		p.push(" qb");
759
		this._addArgs(p, n, i, i + 4);
761
		this._addArgs(p, n, i, i + 4);
760
	}
762
	}
761
	this.lastControl = {x:n[l - 4], y:n[l - 3], type:"Q"};
763
	this.lastControl = {x:n[l - 4], y:n[l - 3], type:"Q"};
762
	return p;
764
	return p;
763
}, _qCurveToR:function (segment, last) {
765
}, _qCurveToR:function (segment, last) {
764
	var p = [];
766
	var p = [];
765
	var n = segment.args;
767
	var n = segment.args;
766
	var l = n.length;
768
	var l = n.length;
767
	for (var i = 0; i < l; i += 4) {
769
	for (var i = 0; i < l; i += 4) {
768
		p.push(" qb");
770
		p.push(" qb");
769
		this._addArgsAdjusted(p, last, n, i, i + 4);
771
		this._addArgsAdjusted(p, last, n, i, i + 4);
770
		this.lastControl = {x:last.x + n[i], y:last.y + n[i + 1]};
772
		this.lastControl = {x:last.x + n[i], y:last.y + n[i + 1]};
771
		last.x += n[i + 2];
773
		last.x += n[i + 2];
772
		last.y += n[i + 3];
774
		last.y += n[i + 3];
773
	}
775
	}
774
	this.lastControl.type = "Q";
776
	this.lastControl.type = "Q";
775
	return p;
777
	return p;
776
}, _qSmoothCurveToA:function (segment, last) {
778
}, _qSmoothCurveToA:function (segment, last) {
777
	var p = [];
779
	var p = [];
778
	var n = segment.args;
780
	var n = segment.args;
779
	var l = n.length;
781
	var l = n.length;
780
	for (var i = 0; i < l; i += 2) {
782
	for (var i = 0; i < l; i += 2) {
781
		p.push(" qb");
783
		p.push(" qb");
782
		if (this.lastControl.type == "Q") {
784
		if (this.lastControl.type == "Q") {
783
			this._addArgs(p, [this.lastControl.x = 2 * last.x - this.lastControl.x, this.lastControl.y = 2 * last.y - this.lastControl.y]);
785
			this._addArgs(p, [this.lastControl.x = 2 * last.x - this.lastControl.x, this.lastControl.y = 2 * last.y - this.lastControl.y]);
784
		} else {
786
		} else {
785
			this._addArgs(p, [this.lastControl.x = last.x, this.lastControl.y = last.y]);
787
			this._addArgs(p, [this.lastControl.x = last.x, this.lastControl.y = last.y]);
786
		}
788
		}
787
		this._addArgs(p, n, i, i + 2);
789
		this._addArgs(p, n, i, i + 2);
788
	}
790
	}
789
	this.lastControl.type = "Q";
791
	this.lastControl.type = "Q";
790
	return p;
792
	return p;
791
}, _qSmoothCurveToR:function (segment, last) {
793
}, _qSmoothCurveToR:function (segment, last) {
792
	var p = [];
794
	var p = [];
793
	var n = segment.args;
795
	var n = segment.args;
794
	var l = n.length;
796
	var l = n.length;
795
	for (var i = 0; i < l; i += 2) {
797
	for (var i = 0; i < l; i += 2) {
796
		p.push(" qb");
798
		p.push(" qb");
797
		if (this.lastControl.type == "Q") {
799
		if (this.lastControl.type == "Q") {
798
			this._addArgs(p, [this.lastControl.x = 2 * last.x - this.lastControl.x, this.lastControl.y = 2 * last.y - this.lastControl.y]);
800
			this._addArgs(p, [this.lastControl.x = 2 * last.x - this.lastControl.x, this.lastControl.y = 2 * last.y - this.lastControl.y]);
799
		} else {
801
		} else {
800
			this._addArgs(p, [this.lastControl.x = last.x, this.lastControl.y = last.y]);
802
			this._addArgs(p, [this.lastControl.x = last.x, this.lastControl.y = last.y]);
801
		}
803
		}
802
		this._addArgsAdjusted(p, last, n, i, i + 2);
804
		this._addArgsAdjusted(p, last, n, i, i + 2);
803
	}
805
	}
804
	this.lastControl.type = "Q";
806
	this.lastControl.type = "Q";
805
	return p;
807
	return p;
806
}, _PI4:Math.PI / 4, _curvePI4:dojo.gfx.path._calcArc(Math.PI / 8), _calcArcTo:function (path, last, rx, ry, xRotg, large, cw, x, y) {
808
}, _PI4:Math.PI / 4, _curvePI4:dojo.gfx.path._calcArc(Math.PI / 8), _calcArcTo:function (path, last, rx, ry, xRotg, large, cw, x, y) {
807
	var m = dojo.gfx.matrix;
809
	var m = dojo.gfx.matrix;
808
	var xRot = -dojo.math.degToRad(xRotg);
810
	var xRot = -dojo.math.degToRad(xRotg);
809
	var rx2 = rx * rx;
811
	var rx2 = rx * rx;
810
	var ry2 = ry * ry;
812
	var ry2 = ry * ry;
811
	var pa = m.multiplyPoint(m.rotate(-xRot), {x:(last.x - x) / 2, y:(last.y - y) / 2});
813
	var pa = m.multiplyPoint(m.rotate(-xRot), {x:(last.x - x) / 2, y:(last.y - y) / 2});
812
	var pax2 = pa.x * pa.x;
814
	var pax2 = pa.x * pa.x;
813
	var pay2 = pa.y * pa.y;
815
	var pay2 = pa.y * pa.y;
814
	var c1 = Math.sqrt((rx2 * ry2 - rx2 * pay2 - ry2 * pax2) / (rx2 * pay2 + ry2 * pax2));
816
	var c1 = Math.sqrt((rx2 * ry2 - rx2 * pay2 - ry2 * pax2) / (rx2 * pay2 + ry2 * pax2));
815
	var ca = {x:c1 * rx * pa.y / ry, y:-c1 * ry * pa.x / rx};
817
	var ca = {x:c1 * rx * pa.y / ry, y:-c1 * ry * pa.x / rx};
816
	if (large == cw) {
818
	if (large == cw) {
817
		ca = {x:-ca.x, y:-ca.y};
819
		ca = {x:-ca.x, y:-ca.y};
818
	}
820
	}
819
	var c = m.multiplyPoint([m.translate((last.x + x) / 2, (last.y + y) / 2), m.rotate(xRot)], ca);
821
	var c = m.multiplyPoint([m.translate((last.x + x) / 2, (last.y + y) / 2), m.rotate(xRot)], ca);
820
	var startAngle = Math.atan2(c.y - last.y, last.x - c.x) - xRot;
822
	var startAngle = Math.atan2(c.y - last.y, last.x - c.x) - xRot;
821
	var endAngle = Math.atan2(c.y - y, x - c.x) - xRot;
823
	var endAngle = Math.atan2(c.y - y, x - c.x) - xRot;
822
	var theta = cw ? startAngle - endAngle : endAngle - startAngle;
824
	var theta = cw ? startAngle - endAngle : endAngle - startAngle;
823
	if (theta < 0) {
825
	if (theta < 0) {
824
		theta += this._2PI;
826
		theta += this._2PI;
825
	} else {
827
	} else {
826
		if (theta > this._2PI) {
828
		if (theta > this._2PI) {
827
			theta = this._2PI;
829
			theta = this._2PI;
828
		}
830
		}
829
	}
831
	}
830
	var elliptic_transform = m.normalize([m.translate(c.x, c.y), m.rotate(xRot), m.scale(rx, ry)]);
832
	var elliptic_transform = m.normalize([m.translate(c.x, c.y), m.rotate(xRot), m.scale(rx, ry)]);
831
	var alpha = this._PI4 / 2;
833
	var alpha = this._PI4 / 2;
832
	var curve = this._curvePI4;
834
	var curve = this._curvePI4;
833
	var step = cw ? -alpha : alpha;
835
	var step = cw ? -alpha : alpha;
834
	for (var angle = theta; angle > 0; angle -= this._PI4) {
836
	for (var angle = theta; angle > 0; angle -= this._PI4) {
835
		if (angle < this._PI4) {
837
		if (angle < this._PI4) {
836
			alpha = angle / 2;
838
			alpha = angle / 2;
837
			curve = dojo.gfx.path._calcArc(alpha);
839
			curve = dojo.gfx.path._calcArc(alpha);
838
			step = cw ? -alpha : alpha;
840
			step = cw ? -alpha : alpha;
839
		}
841
		}
840
		var c1, c2, e;
842
		var c1, c2, e;
841
		var M = m.normalize([elliptic_transform, m.rotate(startAngle + step)]);
843
		var M = m.normalize([elliptic_transform, m.rotate(startAngle + step)]);
842
		if (cw) {
844
		if (cw) {
843
			c1 = m.multiplyPoint(M, curve.c2);
845
			c1 = m.multiplyPoint(M, curve.c2);
844
			c2 = m.multiplyPoint(M, curve.c1);
846
			c2 = m.multiplyPoint(M, curve.c1);
845
			e = m.multiplyPoint(M, curve.s);
847
			e = m.multiplyPoint(M, curve.s);
846
		} else {
848
		} else {
847
			c1 = m.multiplyPoint(M, curve.c1);
849
			c1 = m.multiplyPoint(M, curve.c1);
848
			c2 = m.multiplyPoint(M, curve.c2);
850
			c2 = m.multiplyPoint(M, curve.c2);
849
			e = m.multiplyPoint(M, curve.e);
851
			e = m.multiplyPoint(M, curve.e);
850
		}
852
		}
851
		path.push(" c");
853
		path.push(" c");
852
		this._addArgs(path, [c1.x, c1.y, c2.x, c2.y, e.x, e.y]);
854
		this._addArgs(path, [c1.x, c1.y, c2.x, c2.y, e.x, e.y]);
853
		startAngle += 2 * step;
855
		startAngle += 2 * step;
854
	}
856
	}
855
}, _arcTo:function (segment, last) {
857
}, _arcTo:function (segment, last) {
856
	var p = [];
858
	var p = [];
857
	var n = segment.args;
859
	var n = segment.args;
858
	var l = n.length;
860
	var l = n.length;
859
	var relative = segment.action == "a";
861
	var relative = segment.action == "a";
860
	for (var i = 0; i < l; i += 7) {
862
	for (var i = 0; i < l; i += 7) {
861
		var x1 = n[i + 5];
863
		var x1 = n[i + 5];
862
		var y1 = n[i + 6];
864
		var y1 = n[i + 6];
863
		if (relative) {
865
		if (relative) {
864
			x1 += last.x;
866
			x1 += last.x;
865
			y1 += last.y;
867
			y1 += last.y;
866
		}
868
		}
867
		this._calcArcTo(p, last, n[i], n[i + 1], n[i + 2], n[i + 3] ? 1 : 0, n[i + 4] ? 1 : 0, x1, y1);
869
		this._calcArcTo(p, last, n[i], n[i + 1], n[i + 2], n[i + 3] ? 1 : 0, n[i + 4] ? 1 : 0, x1, y1);
868
		last = {x:x1, y:y1};
870
		last = {x:x1, y:y1};
869
	}
871
	}
870
	this.lastControl = {};
872
	this.lastControl = {};
871
	return p;
873
	return p;
872
}, _closePath:function () {
874
}, _closePath:function () {
873
	this.lastControl = {};
875
	this.lastControl = {};
874
	return ["x"];
876
	return ["x"];
875
}});
877
}});
876
dojo.gfx.Path.nodeType = "shape";
878
dojo.gfx.Path.nodeType = "shape";
877
dojo.gfx._creators = {createPath:function (path) {
879
dojo.gfx._creators = {createPath:function (path) {
878
	return this.createObject(dojo.gfx.Path, path, true);
880
	return this.createObject(dojo.gfx.Path, path, true);
879
}, createRect:function (rect) {
881
}, createRect:function (rect) {
880
	return this.createObject(dojo.gfx.Rect, rect);
882
	return this.createObject(dojo.gfx.Rect, rect);
881
}, createCircle:function (circle) {
883
}, createCircle:function (circle) {
882
	return this.createObject(dojo.gfx.Circle, circle);
884
	return this.createObject(dojo.gfx.Circle, circle);
883
}, createEllipse:function (ellipse) {
885
}, createEllipse:function (ellipse) {
884
	return this.createObject(dojo.gfx.Ellipse, ellipse);
886
	return this.createObject(dojo.gfx.Ellipse, ellipse);
885
}, createLine:function (line) {
887
}, createLine:function (line) {
886
	return this.createObject(dojo.gfx.Line, line, true);
888
	return this.createObject(dojo.gfx.Line, line, true);
887
}, createPolyline:function (points) {
889
}, createPolyline:function (points) {
888
	return this.createObject(dojo.gfx.Polyline, points, true);
890
	return this.createObject(dojo.gfx.Polyline, points, true);
889
}, createImage:function (image) {
891
}, createImage:function (image) {
890
	if (!this.rawNode) {
892
	if (!this.rawNode) {
891
		return null;
893
		return null;
892
	}
894
	}
893
	var shape = new dojo.gfx.Image();
895
	var shape = new dojo.gfx.Image();
894
	var node = document.createElement("div");
896
	var node = document.createElement("div");
895
	node.style.position = "relative";
897
	node.style.position = "relative";
896
	node.style.width = this.rawNode.style.width;
898
	node.style.width = this.rawNode.style.width;
897
	node.style.height = this.rawNode.style.height;
899
	node.style.height = this.rawNode.style.height;
898
	node.style.filter = "progid:DXImageTransform.Microsoft.Matrix(M11=1, M12=0, M21=0, M22=1, Dx=0, Dy=0)";
900
	node.style.filter = "progid:DXImageTransform.Microsoft.Matrix(M11=1, M12=0, M21=0, M22=1, Dx=0, Dy=0)";
899
	var img = document.createElement("img");
901
	var img = document.createElement("img");
900
	node.appendChild(img);
902
	node.appendChild(img);
901
	shape.setRawNode(node);
903
	shape.setRawNode(node);
902
	this.rawNode.appendChild(node);
904
	this.rawNode.appendChild(node);
903
	shape.setShape(image);
905
	shape.setShape(image);
904
	this.add(shape);
906
	this.add(shape);
905
	return shape;
907
	return shape;
906
}, createGroup:function () {
908
}, createGroup:function () {
907
	return this.createObject(dojo.gfx.Group, null, true);
909
	return this.createObject(dojo.gfx.Group, null, true);
908
}, createObject:function (shapeType, rawShape, overrideSize) {
910
}, createObject:function (shapeType, rawShape, overrideSize) {
909
	if (!this.rawNode) {
911
	if (!this.rawNode) {
910
		return null;
912
		return null;
911
	}
913
	}
912
	var shape = new shapeType();
914
	var shape = new shapeType();
913
	var node = document.createElement("v:" + shapeType.nodeType);
915
	var node = document.createElement("v:" + shapeType.nodeType);
914
	shape.setRawNode(node);
916
	shape.setRawNode(node);
915
	this.rawNode.appendChild(node);
917
	this.rawNode.appendChild(node);
916
	if (overrideSize) {
918
	if (overrideSize) {
917
		this._overrideSize(node);
919
		this._overrideSize(node);
918
	}
920
	}
919
	shape.setShape(rawShape);
921
	shape.setShape(rawShape);
920
	this.add(shape);
922
	this.add(shape);
921
	return shape;
923
	return shape;
922
}, _overrideSize:function (node) {
924
}, _overrideSize:function (node) {
923
	node.style.width = this.rawNode.style.width;
925
	node.style.width = this.rawNode.style.width;
924
	node.style.height = this.rawNode.style.height;
926
	node.style.height = this.rawNode.style.height;
925
	node.coordsize = parseFloat(node.style.width) + " " + parseFloat(node.style.height);
927
	node.coordsize = parseFloat(node.style.width) + " " + parseFloat(node.style.height);
926
}};
928
}};
927
dojo.lang.extend(dojo.gfx.Group, dojo.gfx._creators);
929
dojo.lang.extend(dojo.gfx.Group, dojo.gfx._creators);
928
dojo.lang.extend(dojo.gfx.Surface, dojo.gfx._creators);
930
dojo.lang.extend(dojo.gfx.Surface, dojo.gfx._creators);
929
delete dojo.gfx._creators;
931
delete dojo.gfx._creators;
930
dojo.gfx.attachNode = function (node) {
932
dojo.gfx.attachNode = function (node) {
931
	if (!node) {
933
	if (!node) {
932
		return null;
934
		return null;
933
	}
935
	}
934
	var s = null;
936
	var s = null;
935
	switch (node.tagName.toLowerCase()) {
937
	switch (node.tagName.toLowerCase()) {
936
	  case dojo.gfx.Rect.nodeType:
938
	  case dojo.gfx.Rect.nodeType:
937
		s = new dojo.gfx.Rect();
939
		s = new dojo.gfx.Rect();
938
		break;
940
		break;
939
	  case dojo.gfx.Ellipse.nodeType:
941
	  case dojo.gfx.Ellipse.nodeType:
940
		s = (node.style.width == node.style.height) ? new dojo.gfx.Circle() : new dojo.gfx.Ellipse();
942
		s = (node.style.width == node.style.height) ? new dojo.gfx.Circle() : new dojo.gfx.Ellipse();
941
		break;
943
		break;
942
	  case dojo.gfx.Path.nodeType:
944
	  case dojo.gfx.Path.nodeType:
943
		switch (node.getAttribute("dojoGfxType")) {
945
		switch (node.getAttribute("dojoGfxType")) {
944
		  case "line":
946
		  case "line":
945
			s = new dojo.gfx.Line();
947
			s = new dojo.gfx.Line();
946
			break;
948
			break;
947
		  case "polyline":
949
		  case "polyline":
948
			s = new dojo.gfx.Polyline();
950
			s = new dojo.gfx.Polyline();
949
			break;
951
			break;
950
		  case "path":
952
		  case "path":
951
			s = new dojo.gfx.Path();
953
			s = new dojo.gfx.Path();
952
			break;
954
			break;
953
		}
955
		}
954
		break;
956
		break;
955
	  case dojo.gfx.Image.nodeType:
957
	  case dojo.gfx.Image.nodeType:
956
		s = new dojo.gfx.Image();
958
		s = new dojo.gfx.Image();
957
		break;
959
		break;
958
	  default:
960
	  default:
959
		dojo.debug("FATAL ERROR! tagName = " + node.tagName);
961
		dojo.debug("FATAL ERROR! tagName = " + node.tagName);
960
	}
962
	}
961
	s.attach(node);
963
	s.attach(node);
962
	return s;
964
	return s;
963
};
965
};
964
dojo.lang.extend(dojo.gfx.Surface, {setDimensions:function (width, height) {
966
dojo.lang.extend(dojo.gfx.Surface, {setDimensions:function (width, height) {
965
	if (!this.rawNode) {
967
	if (!this.rawNode) {
966
		return this;
968
		return this;
967
	}
969
	}
968
	this.rawNode.style.width = width;
970
	this.rawNode.style.width = width;
969
	this.rawNode.style.height = height;
971
	this.rawNode.style.height = height;
970
	this.rawNode.coordsize = width + " " + height;
972
	this.rawNode.coordsize = width + " " + height;
971
	return this;
973
	return this;
972
}, getDimensions:function () {
974
}, getDimensions:function () {
973
	return this.rawNode ? {width:this.rawNode.style.width, height:this.rawNode.style.height} : null;
975
	return this.rawNode ? {width:this.rawNode.style.width, height:this.rawNode.style.height} : null;
974
}, add:function (shape) {
976
}, add:function (shape) {
975
	var oldParent = shape.getParent();
977
	var oldParent = shape.getParent();
976
	if (this != oldParent) {
978
	if (this != oldParent) {
977
		this.rawNode.appendChild(shape.rawNode);
979
		this.rawNode.appendChild(shape.rawNode);
978
		if (oldParent) {
980
		if (oldParent) {
979
			oldParent.remove(shape, true);
981
			oldParent.remove(shape, true);
980
		}
982
		}
981
		shape._setParent(this, null);
983
		shape._setParent(this, null);
982
	}
984
	}
983
	return this;
985
	return this;
984
}, remove:function (shape, silently) {
986
}, remove:function (shape, silently) {
985
	if (this == shape.getParent()) {
987
	if (this == shape.getParent()) {
986
		if (this.rawNode == shape.rawNode.parentNode) {
988
		if (this.rawNode == shape.rawNode.parentNode) {
987
			this.rawNode.removeChild(shape.rawNode);
989
			this.rawNode.removeChild(shape.rawNode);
988
		}
990
		}
989
		shape._setParent(null, null);
991
		shape._setParent(null, null);
990
	}
992
	}
991
	return this;
993
	return this;
992
}});
994
}});
993
dojo.gfx.createSurface = function (parentNode, width, height) {
995
dojo.gfx.createSurface = function (parentNode, width, height) {
994
	var s = new dojo.gfx.Surface();
996
	var s = new dojo.gfx.Surface();
995
	s.rawNode = document.createElement("v:group");
997
	s.rawNode = document.createElement("v:group");
996
	s.rawNode.style.width = width ? width : "100%";
998
	s.rawNode.style.width = width ? width : "100%";
997
	s.rawNode.style.height = height ? height : "100%";
999
	s.rawNode.style.height = height ? height : "100%";
998
	s.rawNode.coordsize = (width && height) ? (parseFloat(width) + " " + parseFloat(height)) : "100% 100%";
1000
	s.rawNode.coordsize = (width && height) ? (parseFloat(width) + " " + parseFloat(height)) : "100% 100%";
999
	s.rawNode.coordorigin = "0 0";
1001
	s.rawNode.coordorigin = "0 0";
1000
	dojo.byId(parentNode).appendChild(s.rawNode);
1002
	dojo.byId(parentNode).appendChild(s.rawNode);
1001
	return s;
1003
	return s;
1002
};
1004
};
1003
dojo.gfx.attachSurface = function (node) {
1005
dojo.gfx.attachSurface = function (node) {
1004
	var s = new dojo.gfx.Surface();
1006
	var s = new dojo.gfx.Surface();
1005
	s.rawNode = node;
1007
	s.rawNode = node;
1006
	return s;
1008
	return s;
1007
};
1009
};
1008
 
1010