root / trunk / web / dojo / dojox / gfx / vml.js @ 10
History | View | Annotate | Download (22.7 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.gfx.vml"]){ |
9 |
dojo._hasResource["dojox.gfx.vml"]=true; |
10 |
dojo.provide("dojox.gfx.vml");
|
11 |
dojo.require("dojox.gfx._base");
|
12 |
dojo.require("dojox.gfx.shape");
|
13 |
dojo.require("dojox.gfx.path");
|
14 |
dojo.require("dojox.gfx.arc");
|
15 |
dojo.require("dojox.gfx.gradient");
|
16 |
(function(){
|
17 |
var d=dojo,g=dojox.gfx,m=g.matrix,gs=g.shape,_1=g.vml;
|
18 |
_1.xmlns="urn:schemas-microsoft-com:vml";
|
19 |
_1.text_alignment={start:"left",middle:"center",end:"right"}; |
20 |
_1._parseFloat=function(_2){ |
21 |
return _2.match(/^\d+f$/i)?parseInt(_2)/65536:parseFloat(_2); |
22 |
}; |
23 |
_1._bool={"t":1,"true":1}; |
24 |
d.extend(g.Shape,{setFill:function(_3){ |
25 |
if(!_3){
|
26 |
this.fillStyle=null; |
27 |
this.rawNode.filled="f"; |
28 |
return this; |
29 |
} |
30 |
var i,f,fo,a,s;
|
31 |
if(typeof _3=="object"&&"type" in _3){ |
32 |
switch(_3.type){
|
33 |
case "linear": |
34 |
var _4=this._getRealMatrix(),_5=this.getBoundingBox(),_6=this._getRealBBox?this._getRealBBox():this.getTransformedBoundingBox(); |
35 |
s=[]; |
36 |
if(this.fillStyle!==_3){ |
37 |
this.fillStyle=g.makeParameters(g.defaultLinearGradient,_3);
|
38 |
} |
39 |
f=g.gradient.project(_4,this.fillStyle,{x:_5.x,y:_5.y},{x:_5.x+_5.width,y:_5.y+_5.height},_6[0],_6[2]); |
40 |
a=f.colors; |
41 |
if(a[0].offset.toFixed(5)!="0.00000"){ |
42 |
s.push("0 "+g.normalizeColor(a[0].color).toHex()); |
43 |
} |
44 |
for(i=0;i<a.length;++i){ |
45 |
s.push(a[i].offset.toFixed(5)+" "+g.normalizeColor(a[i].color).toHex()); |
46 |
} |
47 |
i=a.length-1;
|
48 |
if(a[i].offset.toFixed(5)!="1.00000"){ |
49 |
s.push("1 "+g.normalizeColor(a[i].color).toHex());
|
50 |
} |
51 |
fo=this.rawNode.fill;
|
52 |
fo.colors.value=s.join(";");
|
53 |
fo.method="sigma";
|
54 |
fo.type="gradient";
|
55 |
fo.angle=(270-m._radToDeg(f.angle))%360; |
56 |
fo.on=true;
|
57 |
break;
|
58 |
case "radial": |
59 |
f=g.makeParameters(g.defaultRadialGradient,_3); |
60 |
this.fillStyle=f;
|
61 |
var l=parseFloat(this.rawNode.style.left),t=parseFloat(this.rawNode.style.top),w=parseFloat(this.rawNode.style.width),h=parseFloat(this.rawNode.style.height),c=isNaN(w)?1:2*f.r/w; |
62 |
a=[]; |
63 |
if(f.colors[0].offset>0){ |
64 |
a.push({offset:1,color:g.normalizeColor(f.colors[0].color)}); |
65 |
} |
66 |
d.forEach(f.colors,function(v,i){
|
67 |
a.push({offset:1-v.offset*c,color:g.normalizeColor(v.color)}); |
68 |
}); |
69 |
i=a.length-1;
|
70 |
while(i>=0&&a[i].offset<0){ |
71 |
--i; |
72 |
} |
73 |
if(i<a.length-1){ |
74 |
var q=a[i],p=a[i+1]; |
75 |
p.color=d.blendColors(q.color,p.color,q.offset/(q.offset-p.offset)); |
76 |
p.offset=0;
|
77 |
while(a.length-i>2){ |
78 |
a.pop(); |
79 |
} |
80 |
} |
81 |
i=a.length-1,s=[];
|
82 |
if(a[i].offset>0){ |
83 |
s.push("0 "+a[i].color.toHex());
|
84 |
} |
85 |
for(;i>=0;--i){ |
86 |
s.push(a[i].offset.toFixed(5)+" "+a[i].color.toHex()); |
87 |
} |
88 |
fo=this.rawNode.fill;
|
89 |
fo.colors.value=s.join(";");
|
90 |
fo.method="sigma";
|
91 |
fo.type="gradientradial";
|
92 |
if(isNaN(w)||isNaN(h)||isNaN(l)||isNaN(t)){
|
93 |
fo.focusposition="0.5 0.5";
|
94 |
}else{
|
95 |
fo.focusposition=((f.cx-l)/w).toFixed(5)+" "+((f.cy-t)/h).toFixed(5); |
96 |
} |
97 |
fo.focussize="0 0";
|
98 |
fo.on=true;
|
99 |
break;
|
100 |
case "pattern": |
101 |
f=g.makeParameters(g.defaultPattern,_3); |
102 |
this.fillStyle=f;
|
103 |
fo=this.rawNode.fill;
|
104 |
fo.type="tile";
|
105 |
fo.src=f.src; |
106 |
if(f.width&&f.height){
|
107 |
fo.size.x=g.px2pt(f.width); |
108 |
fo.size.y=g.px2pt(f.height); |
109 |
} |
110 |
fo.alignShape="f";
|
111 |
fo.position.x=0;
|
112 |
fo.position.y=0;
|
113 |
fo.origin.x=f.width?f.x/f.width:0;
|
114 |
fo.origin.y=f.height?f.y/f.height:0;
|
115 |
fo.on=true;
|
116 |
break;
|
117 |
} |
118 |
this.rawNode.fill.opacity=1; |
119 |
return this; |
120 |
} |
121 |
this.fillStyle=g.normalizeColor(_3);
|
122 |
fo=this.rawNode.fill;
|
123 |
if(!fo){
|
124 |
fo=this.rawNode.ownerDocument.createElement("v:fill"); |
125 |
} |
126 |
fo.method="any";
|
127 |
fo.type="solid";
|
128 |
fo.opacity=this.fillStyle.a;
|
129 |
this.rawNode.fillcolor=this.fillStyle.toHex(); |
130 |
this.rawNode.filled=true; |
131 |
return this; |
132 |
},setStroke:function(_7){ |
133 |
if(!_7){
|
134 |
this.strokeStyle=null; |
135 |
this.rawNode.stroked="f"; |
136 |
return this; |
137 |
} |
138 |
if(typeof _7=="string"||d.isArray(_7)||_7 instanceof d.Color){ |
139 |
_7={color:_7};
|
140 |
} |
141 |
var s=this.strokeStyle=g.makeParameters(g.defaultStroke,_7); |
142 |
s.color=g.normalizeColor(s.color); |
143 |
var rn=this.rawNode; |
144 |
rn.stroked=true;
|
145 |
rn.strokecolor=s.color.toCss(); |
146 |
rn.strokeweight=s.width+"px";
|
147 |
if(rn.stroke){
|
148 |
rn.stroke.opacity=s.color.a; |
149 |
rn.stroke.endcap=this._translate(this._capMap,s.cap); |
150 |
if(typeof s.join=="number"){ |
151 |
rn.stroke.joinstyle="miter";
|
152 |
rn.stroke.miterlimit=s.join; |
153 |
}else{
|
154 |
rn.stroke.joinstyle=s.join; |
155 |
} |
156 |
rn.stroke.dashstyle=s.style=="none"?"Solid":s.style; |
157 |
} |
158 |
return this; |
159 |
},_capMap:{butt:"flat"},_capMapReversed:{flat:"butt"},_translate:function(_8,_9){ |
160 |
return (_9 in _8)?_8[_9]:_9; |
161 |
},_applyTransform:function(){ |
162 |
var _a=this._getRealMatrix(); |
163 |
if(_a){
|
164 |
var _b=this.rawNode.skew; |
165 |
if(typeof _b=="undefined"){ |
166 |
for(var i=0;i<this.rawNode.childNodes.length;++i){ |
167 |
if(this.rawNode.childNodes[i].tagName=="skew"){ |
168 |
_b=this.rawNode.childNodes[i];
|
169 |
break;
|
170 |
} |
171 |
} |
172 |
} |
173 |
if(_b){
|
174 |
_b.on="f";
|
175 |
var mt=_a.xx.toFixed(8)+" "+_a.xy.toFixed(8)+" "+_a.yx.toFixed(8)+" "+_a.yy.toFixed(8)+" 0 0",_c=Math.floor(_a.dx).toFixed()+"px "+Math.floor(_a.dy).toFixed()+"px",s=this.rawNode.style,l=parseFloat(s.left),t=parseFloat(s.top),w=parseFloat(s.width),h=parseFloat(s.height); |
176 |
if(isNaN(l)){
|
177 |
l=0;
|
178 |
} |
179 |
if(isNaN(t)){
|
180 |
t=0;
|
181 |
} |
182 |
if(isNaN(w)||!w){
|
183 |
w=1;
|
184 |
} |
185 |
if(isNaN(h)||!h){
|
186 |
h=1;
|
187 |
} |
188 |
var _d=(-l/w-0.5).toFixed(8)+" "+(-t/h-0.5).toFixed(8); |
189 |
_b.matrix=mt; |
190 |
_b.origin=_d; |
191 |
_b.offset=_c; |
192 |
_b.on=true;
|
193 |
} |
194 |
} |
195 |
if(this.fillStyle&&this.fillStyle.type=="linear"){ |
196 |
this.setFill(this.fillStyle); |
197 |
} |
198 |
return this; |
199 |
},_setDimensions:function(_e,_f){ |
200 |
return this; |
201 |
},setRawNode:function(_10){ |
202 |
_10.stroked="f";
|
203 |
_10.filled="f";
|
204 |
this.rawNode=_10;
|
205 |
},_moveToFront:function(){ |
206 |
this.rawNode.parentNode.appendChild(this.rawNode); |
207 |
return this; |
208 |
},_moveToBack:function(){ |
209 |
var r=this.rawNode,p=r.parentNode,n=p.firstChild; |
210 |
p.insertBefore(r,n); |
211 |
if(n.tagName=="rect"){ |
212 |
n.swapNode(r); |
213 |
} |
214 |
return this; |
215 |
},_getRealMatrix:function(){ |
216 |
return this.parentMatrix?new g.Matrix2D([this.parentMatrix,this.matrix]):this.matrix; |
217 |
}}); |
218 |
dojo.declare("dojox.gfx.Group",g.Shape,{constructor:function(){ |
219 |
_1.Container._init.call(this);
|
220 |
},_applyTransform:function(){ |
221 |
var _11=this._getRealMatrix(); |
222 |
for(var i=0;i<this.children.length;++i){ |
223 |
this.children[i]._updateParentMatrix(_11);
|
224 |
} |
225 |
return this; |
226 |
},_setDimensions:function(_12,_13){ |
227 |
var r=this.rawNode,rs=r.style,bs=this.bgNode.style; |
228 |
rs.width=_12; |
229 |
rs.height=_13; |
230 |
r.coordsize=_12+" "+_13;
|
231 |
bs.width=_12; |
232 |
bs.height=_13; |
233 |
for(var i=0;i<this.children.length;++i){ |
234 |
this.children[i]._setDimensions(_12,_13);
|
235 |
} |
236 |
return this; |
237 |
}}); |
238 |
g.Group.nodeType="group";
|
239 |
dojo.declare("dojox.gfx.Rect",gs.Rect,{setShape:function(_14){ |
240 |
var _15=this.shape=g.makeParameters(this.shape,_14); |
241 |
this.bbox=null; |
242 |
var r=Math.min(1,(_15.r/Math.min(parseFloat(_15.width),parseFloat(_15.height)))).toFixed(8); |
243 |
var _16=this.rawNode.parentNode,_17=null; |
244 |
if(_16){
|
245 |
if(_16.lastChild!==this.rawNode){ |
246 |
for(var i=0;i<_16.childNodes.length;++i){ |
247 |
if(_16.childNodes[i]===this.rawNode){ |
248 |
_17=_16.childNodes[i+1];
|
249 |
break;
|
250 |
} |
251 |
} |
252 |
} |
253 |
_16.removeChild(this.rawNode);
|
254 |
} |
255 |
if(d.isIE>7){ |
256 |
var _18=this.rawNode.ownerDocument.createElement("v:roundrect"); |
257 |
_18.arcsize=r; |
258 |
_18.style.display="inline-block";
|
259 |
this.rawNode=_18;
|
260 |
}else{
|
261 |
this.rawNode.arcsize=r;
|
262 |
} |
263 |
if(_16){
|
264 |
if(_17){
|
265 |
_16.insertBefore(this.rawNode,_17);
|
266 |
}else{
|
267 |
_16.appendChild(this.rawNode);
|
268 |
} |
269 |
} |
270 |
var _19=this.rawNode.style; |
271 |
_19.left=_15.x.toFixed(); |
272 |
_19.top=_15.y.toFixed(); |
273 |
_19.width=(typeof _15.width=="string"&&_15.width.indexOf("%")>=0)?_15.width:_15.width.toFixed(); |
274 |
_19.height=(typeof _15.width=="string"&&_15.height.indexOf("%")>=0)?_15.height:_15.height.toFixed(); |
275 |
return this.setTransform(this.matrix).setFill(this.fillStyle).setStroke(this.strokeStyle); |
276 |
}}); |
277 |
g.Rect.nodeType="roundrect";
|
278 |
dojo.declare("dojox.gfx.Ellipse",gs.Ellipse,{setShape:function(_1a){ |
279 |
var _1b=this.shape=g.makeParameters(this.shape,_1a); |
280 |
this.bbox=null; |
281 |
var _1c=this.rawNode.style; |
282 |
_1c.left=(_1b.cx-_1b.rx).toFixed(); |
283 |
_1c.top=(_1b.cy-_1b.ry).toFixed(); |
284 |
_1c.width=(_1b.rx*2).toFixed();
|
285 |
_1c.height=(_1b.ry*2).toFixed();
|
286 |
return this.setTransform(this.matrix); |
287 |
}}); |
288 |
g.Ellipse.nodeType="oval";
|
289 |
dojo.declare("dojox.gfx.Circle",gs.Circle,{setShape:function(_1d){ |
290 |
var _1e=this.shape=g.makeParameters(this.shape,_1d); |
291 |
this.bbox=null; |
292 |
var _1f=this.rawNode.style; |
293 |
_1f.left=(_1e.cx-_1e.r).toFixed(); |
294 |
_1f.top=(_1e.cy-_1e.r).toFixed(); |
295 |
_1f.width=(_1e.r*2).toFixed();
|
296 |
_1f.height=(_1e.r*2).toFixed();
|
297 |
return this; |
298 |
}}); |
299 |
g.Circle.nodeType="oval";
|
300 |
dojo.declare("dojox.gfx.Line",gs.Line,{constructor:function(_20){ |
301 |
if(_20){
|
302 |
_20.setAttribute("dojoGfxType","line"); |
303 |
} |
304 |
},setShape:function(_21){ |
305 |
var _22=this.shape=g.makeParameters(this.shape,_21); |
306 |
this.bbox=null; |
307 |
this.rawNode.path.v="m"+_22.x1.toFixed()+" "+_22.y1.toFixed()+"l"+_22.x2.toFixed()+" "+_22.y2.toFixed()+"e"; |
308 |
return this.setTransform(this.matrix); |
309 |
}}); |
310 |
g.Line.nodeType="shape";
|
311 |
dojo.declare("dojox.gfx.Polyline",gs.Polyline,{constructor:function(_23){ |
312 |
if(_23){
|
313 |
_23.setAttribute("dojoGfxType","polyline"); |
314 |
} |
315 |
},setShape:function(_24,_25){ |
316 |
if(_24&&_24 instanceof Array){ |
317 |
this.shape=g.makeParameters(this.shape,{points:_24}); |
318 |
if(_25&&this.shape.points.length){ |
319 |
this.shape.points.push(this.shape.points[0]); |
320 |
} |
321 |
}else{
|
322 |
this.shape=g.makeParameters(this.shape,_24); |
323 |
} |
324 |
this.bbox=null; |
325 |
this._normalizePoints();
|
326 |
var _26=[],p=this.shape.points; |
327 |
if(p.length>0){ |
328 |
_26.push("m");
|
329 |
_26.push(p[0].x.toFixed(),p[0].y.toFixed()); |
330 |
if(p.length>1){ |
331 |
_26.push("l");
|
332 |
for(var i=1;i<p.length;++i){ |
333 |
_26.push(p[i].x.toFixed(),p[i].y.toFixed()); |
334 |
} |
335 |
} |
336 |
} |
337 |
_26.push("e");
|
338 |
this.rawNode.path.v=_26.join(" "); |
339 |
return this.setTransform(this.matrix); |
340 |
}}); |
341 |
g.Polyline.nodeType="shape";
|
342 |
dojo.declare("dojox.gfx.Image",gs.Image,{setShape:function(_27){ |
343 |
var _28=this.shape=g.makeParameters(this.shape,_27); |
344 |
this.bbox=null; |
345 |
this.rawNode.firstChild.src=_28.src;
|
346 |
return this.setTransform(this.matrix); |
347 |
},_applyTransform:function(){ |
348 |
var _29=this._getRealMatrix(),_2a=this.rawNode,s=_2a.style,_2b=this.shape; |
349 |
if(_29){
|
350 |
_29=m.multiply(_29,{dx:_2b.x,dy:_2b.y}); |
351 |
}else{
|
352 |
_29=m.normalize({dx:_2b.x,dy:_2b.y}); |
353 |
} |
354 |
if(_29.xy==0&&_29.yx==0&&_29.xx>0&&_29.yy>0){ |
355 |
s.filter="";
|
356 |
s.width=Math.floor(_29.xx*_2b.width); |
357 |
s.height=Math.floor(_29.yy*_2b.height); |
358 |
s.left=Math.floor(_29.dx); |
359 |
s.top=Math.floor(_29.dy); |
360 |
}else{
|
361 |
var ps=_2a.parentNode.style;
|
362 |
s.left="0px";
|
363 |
s.top="0px";
|
364 |
s.width=ps.width; |
365 |
s.height=ps.height; |
366 |
_29=m.multiply(_29,{xx:_2b.width/parseInt(s.width),yy:_2b.height/parseInt(s.height)}); |
367 |
var f=_2a.filters["DXImageTransform.Microsoft.Matrix"]; |
368 |
if(f){
|
369 |
f.M11=_29.xx; |
370 |
f.M12=_29.xy; |
371 |
f.M21=_29.yx; |
372 |
f.M22=_29.yy; |
373 |
f.Dx=_29.dx; |
374 |
f.Dy=_29.dy; |
375 |
}else{
|
376 |
s.filter="progid:DXImageTransform.Microsoft.Matrix(M11="+_29.xx+", M12="+_29.xy+", M21="+_29.yx+", M22="+_29.yy+", Dx="+_29.dx+", Dy="+_29.dy+")"; |
377 |
} |
378 |
} |
379 |
return this; |
380 |
},_setDimensions:function(_2c,_2d){ |
381 |
var r=this.rawNode,f=r.filters["DXImageTransform.Microsoft.Matrix"]; |
382 |
if(f){
|
383 |
var s=r.style;
|
384 |
s.width=_2c; |
385 |
s.height=_2d; |
386 |
return this._applyTransform(); |
387 |
} |
388 |
return this; |
389 |
}}); |
390 |
g.Image.nodeType="rect";
|
391 |
dojo.declare("dojox.gfx.Text",gs.Text,{constructor:function(_2e){ |
392 |
if(_2e){
|
393 |
_2e.setAttribute("dojoGfxType","text"); |
394 |
} |
395 |
this.fontStyle=null; |
396 |
},_alignment:{start:"left",middle:"center",end:"right"},setShape:function(_2f){ |
397 |
this.shape=g.makeParameters(this.shape,_2f); |
398 |
this.bbox=null; |
399 |
var r=this.rawNode,s=this.shape,x=s.x,y=s.y.toFixed(),_30; |
400 |
switch(s.align){
|
401 |
case "middle": |
402 |
x-=5;
|
403 |
break;
|
404 |
case "end": |
405 |
x-=10;
|
406 |
break;
|
407 |
} |
408 |
_30="m"+x.toFixed()+","+y+"l"+(x+10).toFixed()+","+y+"e"; |
409 |
var p=null,t=null,c=r.childNodes; |
410 |
for(var i=0;i<c.length;++i){ |
411 |
var tag=c[i].tagName;
|
412 |
if(tag=="path"){ |
413 |
p=c[i]; |
414 |
if(t){
|
415 |
break;
|
416 |
} |
417 |
}else{
|
418 |
if(tag=="textpath"){ |
419 |
t=c[i]; |
420 |
if(p){
|
421 |
break;
|
422 |
} |
423 |
} |
424 |
} |
425 |
} |
426 |
if(!p){
|
427 |
p=r.ownerDocument.createElement("v:path");
|
428 |
r.appendChild(p); |
429 |
} |
430 |
if(!t){
|
431 |
t=r.ownerDocument.createElement("v:textpath");
|
432 |
r.appendChild(t); |
433 |
} |
434 |
p.v=_30; |
435 |
p.textPathOk=true;
|
436 |
t.on=true;
|
437 |
var a=_1.text_alignment[s.align];
|
438 |
t.style["v-text-align"]=a?a:"left"; |
439 |
t.style["text-decoration"]=s.decoration;
|
440 |
t.style["v-rotate-letters"]=s.rotated;
|
441 |
t.style["v-text-kern"]=s.kerning;
|
442 |
t.string=s.text; |
443 |
return this.setTransform(this.matrix); |
444 |
},_setFont:function(){ |
445 |
var f=this.fontStyle,c=this.rawNode.childNodes; |
446 |
for(var i=0;i<c.length;++i){ |
447 |
if(c[i].tagName=="textpath"){ |
448 |
c[i].style.font=g.makeFontString(f); |
449 |
break;
|
450 |
} |
451 |
} |
452 |
this.setTransform(this.matrix); |
453 |
},_getRealMatrix:function(){ |
454 |
var _31=g.Shape.prototype._getRealMatrix.call(this); |
455 |
if(_31){
|
456 |
_31=m.multiply(_31,{dy:-g.normalizedLength(this.fontStyle?this.fontStyle.size:"10pt")*0.35}); |
457 |
} |
458 |
return _31;
|
459 |
},getTextWidth:function(){ |
460 |
var _32=this.rawNode,_33=_32.style.display; |
461 |
_32.style.display="inline";
|
462 |
var _34=g.pt2px(parseFloat(_32.currentStyle.width));
|
463 |
_32.style.display=_33; |
464 |
return _34;
|
465 |
}}); |
466 |
g.Text.nodeType="shape";
|
467 |
dojo.declare("dojox.gfx.Path",g.path.Path,{constructor:function(_35){ |
468 |
if(_35&&!_35.getAttribute("dojoGfxType")){ |
469 |
_35.setAttribute("dojoGfxType","path"); |
470 |
} |
471 |
this.vmlPath=""; |
472 |
this.lastControl={};
|
473 |
},_updateWithSegment:function(_36){ |
474 |
var _37=d.clone(this.last); |
475 |
g.Path.superclass._updateWithSegment.apply(this,arguments); |
476 |
if(arguments.length>1){ |
477 |
return;
|
478 |
} |
479 |
var _38=this[this.renderers[_36.action]](_36,_37); |
480 |
if(typeof this.vmlPath=="string"){ |
481 |
this.vmlPath+=_38.join(""); |
482 |
this.rawNode.path.v=this.vmlPath+" r0,0 e"; |
483 |
}else{
|
484 |
Array.prototype.push.apply(this.vmlPath,_38);
|
485 |
} |
486 |
},setShape:function(_39){ |
487 |
this.vmlPath=[];
|
488 |
this.lastControl.type=""; |
489 |
g.Path.superclass.setShape.apply(this,arguments); |
490 |
this.vmlPath=this.vmlPath.join(""); |
491 |
this.rawNode.path.v=this.vmlPath+" r0,0 e"; |
492 |
return this; |
493 |
},_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(_3a,_3b,_3c,_3d){ |
494 |
var n=_3b instanceof Array?_3b:_3b.args; |
495 |
for(var i=_3c;i<_3d;++i){ |
496 |
_3a.push(" ",n[i].toFixed());
|
497 |
} |
498 |
},_adjustRelCrd:function(_3e,_3f,_40){ |
499 |
var n=_3f instanceof Array?_3f:_3f.args,l=n.length,_41=new Array(l),i=0,x=_3e.x,y=_3e.y; |
500 |
if(typeof x!="number"){ |
501 |
_41[0]=x=n[0]; |
502 |
_41[1]=y=n[1]; |
503 |
i=2;
|
504 |
} |
505 |
if(typeof _40=="number"&&_40!=2){ |
506 |
var j=_40;
|
507 |
while(j<=l){
|
508 |
for(;i<j;i+=2){ |
509 |
_41[i]=x+n[i]; |
510 |
_41[i+1]=y+n[i+1]; |
511 |
} |
512 |
x=_41[j-2];
|
513 |
y=_41[j-1];
|
514 |
j+=_40; |
515 |
} |
516 |
}else{
|
517 |
for(;i<l;i+=2){ |
518 |
_41[i]=(x+=n[i]); |
519 |
_41[i+1]=(y+=n[i+1]); |
520 |
} |
521 |
} |
522 |
return _41;
|
523 |
},_adjustRelPos:function(_42,_43){ |
524 |
var n=_43 instanceof Array?_43:_43.args,l=n.length,_44=new Array(l); |
525 |
for(var i=0;i<l;++i){ |
526 |
_44[i]=(_42+=n[i]); |
527 |
} |
528 |
return _44;
|
529 |
},_moveToA:function(_45){ |
530 |
var p=[" m"],n=_45 instanceof Array?_45:_45.args,l=n.length; |
531 |
this._addArgs(p,n,0,2); |
532 |
if(l>2){ |
533 |
p.push(" l");
|
534 |
this._addArgs(p,n,2,l); |
535 |
} |
536 |
this.lastControl.type=""; |
537 |
return p;
|
538 |
},_moveToR:function(_46,_47){ |
539 |
return this._moveToA(this._adjustRelCrd(_47,_46)); |
540 |
},_lineToA:function(_48){ |
541 |
var p=[" l"],n=_48 instanceof Array?_48:_48.args; |
542 |
this._addArgs(p,n,0,n.length); |
543 |
this.lastControl.type=""; |
544 |
return p;
|
545 |
},_lineToR:function(_49,_4a){ |
546 |
return this._lineToA(this._adjustRelCrd(_4a,_49)); |
547 |
},_hLineToA:function(_4b,_4c){ |
548 |
var p=[" l"],y=" "+_4c.y.toFixed(),n=_4b instanceof Array?_4b:_4b.args,l=n.length; |
549 |
for(var i=0;i<l;++i){ |
550 |
p.push(" ",n[i].toFixed(),y);
|
551 |
} |
552 |
this.lastControl.type=""; |
553 |
return p;
|
554 |
},_hLineToR:function(_4d,_4e){ |
555 |
return this._hLineToA(this._adjustRelPos(_4e.x,_4d),_4e); |
556 |
},_vLineToA:function(_4f,_50){ |
557 |
var p=[" l"],x=" "+_50.x.toFixed(),n=_4f instanceof Array?_4f:_4f.args,l=n.length; |
558 |
for(var i=0;i<l;++i){ |
559 |
p.push(x," ",n[i].toFixed());
|
560 |
} |
561 |
this.lastControl.type=""; |
562 |
return p;
|
563 |
},_vLineToR:function(_51,_52){ |
564 |
return this._vLineToA(this._adjustRelPos(_52.y,_51),_52); |
565 |
},_curveToA:function(_53){ |
566 |
var p=[],n=_53 instanceof Array?_53:_53.args,l=n.length,lc=this.lastControl; |
567 |
for(var i=0;i<l;i+=6){ |
568 |
p.push(" c");
|
569 |
this._addArgs(p,n,i,i+6); |
570 |
} |
571 |
lc.x=n[l-4];
|
572 |
lc.y=n[l-3];
|
573 |
lc.type="C";
|
574 |
return p;
|
575 |
},_curveToR:function(_54,_55){ |
576 |
return this._curveToA(this._adjustRelCrd(_55,_54,6)); |
577 |
},_smoothCurveToA:function(_56,_57){ |
578 |
var p=[],n=_56 instanceof Array?_56:_56.args,l=n.length,lc=this.lastControl,i=0; |
579 |
if(lc.type!="C"){ |
580 |
p.push(" c");
|
581 |
this._addArgs(p,[_57.x,_57.y],0,2); |
582 |
this._addArgs(p,n,0,4); |
583 |
lc.x=n[0];
|
584 |
lc.y=n[1];
|
585 |
lc.type="C";
|
586 |
i=4;
|
587 |
} |
588 |
for(;i<l;i+=4){ |
589 |
p.push(" c");
|
590 |
this._addArgs(p,[2*_57.x-lc.x,2*_57.y-lc.y],0,2); |
591 |
this._addArgs(p,n,i,i+4); |
592 |
lc.x=n[i]; |
593 |
lc.y=n[i+1];
|
594 |
} |
595 |
return p;
|
596 |
},_smoothCurveToR:function(_58,_59){ |
597 |
return this._smoothCurveToA(this._adjustRelCrd(_59,_58,4),_59); |
598 |
},_qCurveToA:function(_5a){ |
599 |
var p=[],n=_5a instanceof Array?_5a:_5a.args,l=n.length,lc=this.lastControl; |
600 |
for(var i=0;i<l;i+=4){ |
601 |
p.push(" qb");
|
602 |
this._addArgs(p,n,i,i+4); |
603 |
} |
604 |
lc.x=n[l-4];
|
605 |
lc.y=n[l-3];
|
606 |
lc.type="Q";
|
607 |
return p;
|
608 |
},_qCurveToR:function(_5b,_5c){ |
609 |
return this._qCurveToA(this._adjustRelCrd(_5c,_5b,4)); |
610 |
},_qSmoothCurveToA:function(_5d,_5e){ |
611 |
var p=[],n=_5d instanceof Array?_5d:_5d.args,l=n.length,lc=this.lastControl,i=0; |
612 |
if(lc.type!="Q"){ |
613 |
p.push(" qb");
|
614 |
this._addArgs(p,[lc.x=_5e.x,lc.y=_5e.y],0,2); |
615 |
lc.type="Q";
|
616 |
this._addArgs(p,n,0,2); |
617 |
i=2;
|
618 |
} |
619 |
for(;i<l;i+=2){ |
620 |
p.push(" qb");
|
621 |
this._addArgs(p,[lc.x=2*_5e.x-lc.x,lc.y=2*_5e.y-lc.y],0,2); |
622 |
this._addArgs(p,n,i,i+2); |
623 |
} |
624 |
return p;
|
625 |
},_qSmoothCurveToR:function(_5f,_60){ |
626 |
return this._qSmoothCurveToA(this._adjustRelCrd(_60,_5f,2),_60); |
627 |
},_arcTo:function(_61,_62){ |
628 |
var p=[],n=_61.args,l=n.length,_63=_61.action=="a"; |
629 |
for(var i=0;i<l;i+=7){ |
630 |
var x1=n[i+5],y1=n[i+6]; |
631 |
if(_63){
|
632 |
x1+=_62.x; |
633 |
y1+=_62.y; |
634 |
} |
635 |
var _64=g.arc.arcAsBezier(_62,n[i],n[i+1],n[i+2],n[i+3]?1:0,n[i+4]?1:0,x1,y1); |
636 |
for(var j=0;j<_64.length;++j){ |
637 |
p.push(" c");
|
638 |
var t=_64[j];
|
639 |
this._addArgs(p,t,0,t.length); |
640 |
this._updateBBox(t[0],t[1]); |
641 |
this._updateBBox(t[2],t[3]); |
642 |
this._updateBBox(t[4],t[5]); |
643 |
} |
644 |
_62.x=x1; |
645 |
_62.y=y1; |
646 |
} |
647 |
this.lastControl.type=""; |
648 |
return p;
|
649 |
},_closePath:function(){ |
650 |
this.lastControl.type=""; |
651 |
return ["x"]; |
652 |
}}); |
653 |
g.Path.nodeType="shape";
|
654 |
dojo.declare("dojox.gfx.TextPath",g.Path,{constructor:function(_65){ |
655 |
if(_65){
|
656 |
_65.setAttribute("dojoGfxType","textpath"); |
657 |
} |
658 |
this.fontStyle=null; |
659 |
if(!("text" in this)){ |
660 |
this.text=d.clone(g.defaultTextPath);
|
661 |
} |
662 |
if(!("fontStyle" in this)){ |
663 |
this.fontStyle=d.clone(g.defaultFont);
|
664 |
} |
665 |
},setText:function(_66){ |
666 |
this.text=g.makeParameters(this.text,typeof _66=="string"?{text:_66}:_66); |
667 |
this._setText();
|
668 |
return this; |
669 |
},setFont:function(_67){ |
670 |
this.fontStyle=typeof _67=="string"?g.splitFontString(_67):g.makeParameters(g.defaultFont,_67); |
671 |
this._setFont();
|
672 |
return this; |
673 |
},_setText:function(){ |
674 |
this.bbox=null; |
675 |
var r=this.rawNode,s=this.text,p=null,t=null,c=r.childNodes; |
676 |
for(var i=0;i<c.length;++i){ |
677 |
var tag=c[i].tagName;
|
678 |
if(tag=="path"){ |
679 |
p=c[i]; |
680 |
if(t){
|
681 |
break;
|
682 |
} |
683 |
}else{
|
684 |
if(tag=="textpath"){ |
685 |
t=c[i]; |
686 |
if(p){
|
687 |
break;
|
688 |
} |
689 |
} |
690 |
} |
691 |
} |
692 |
if(!p){
|
693 |
p=this.rawNode.ownerDocument.createElement("v:path"); |
694 |
r.appendChild(p); |
695 |
} |
696 |
if(!t){
|
697 |
t=this.rawNode.ownerDocument.createElement("v:textpath"); |
698 |
r.appendChild(t); |
699 |
} |
700 |
p.textPathOk=true;
|
701 |
t.on=true;
|
702 |
var a=_1.text_alignment[s.align];
|
703 |
t.style["v-text-align"]=a?a:"left"; |
704 |
t.style["text-decoration"]=s.decoration;
|
705 |
t.style["v-rotate-letters"]=s.rotated;
|
706 |
t.style["v-text-kern"]=s.kerning;
|
707 |
t.string=s.text; |
708 |
},_setFont:function(){ |
709 |
var f=this.fontStyle,c=this.rawNode.childNodes; |
710 |
for(var i=0;i<c.length;++i){ |
711 |
if(c[i].tagName=="textpath"){ |
712 |
c[i].style.font=g.makeFontString(f); |
713 |
break;
|
714 |
} |
715 |
} |
716 |
}}); |
717 |
g.TextPath.nodeType="shape";
|
718 |
dojo.declare("dojox.gfx.Surface",gs.Surface,{constructor:function(){ |
719 |
_1.Container._init.call(this);
|
720 |
},setDimensions:function(_68,_69){ |
721 |
this.width=g.normalizedLength(_68);
|
722 |
this.height=g.normalizedLength(_69);
|
723 |
if(!this.rawNode){ |
724 |
return this; |
725 |
} |
726 |
var cs=this.clipNode.style,r=this.rawNode,rs=r.style,bs=this.bgNode.style,ps=this._parent.style,i; |
727 |
ps.width=_68; |
728 |
ps.height=_69; |
729 |
cs.width=_68; |
730 |
cs.height=_69; |
731 |
cs.clip="rect(0px "+_68+"px "+_69+"px 0px)"; |
732 |
rs.width=_68; |
733 |
rs.height=_69; |
734 |
r.coordsize=_68+" "+_69;
|
735 |
bs.width=_68; |
736 |
bs.height=_69; |
737 |
for(i=0;i<this.children.length;++i){ |
738 |
this.children[i]._setDimensions(_68,_69);
|
739 |
} |
740 |
return this; |
741 |
},getDimensions:function(){ |
742 |
var t=this.rawNode?{width:g.normalizedLength(this.rawNode.style.width),height:g.normalizedLength(this.rawNode.style.height)}:null; |
743 |
if(t.width<=0){ |
744 |
t.width=this.width;
|
745 |
} |
746 |
if(t.height<=0){ |
747 |
t.height=this.height;
|
748 |
} |
749 |
return t;
|
750 |
}}); |
751 |
g.createSurface=function(_6a,_6b,_6c){ |
752 |
if(!_6b&&!_6c){
|
753 |
var pos=d.position(_6a);
|
754 |
_6b=_6b||pos.w; |
755 |
_6c=_6c||pos.h; |
756 |
} |
757 |
if(typeof _6b=="number"){ |
758 |
_6b=_6b+"px";
|
759 |
} |
760 |
if(typeof _6c=="number"){ |
761 |
_6c=_6c+"px";
|
762 |
} |
763 |
var s=new g.Surface(),p=d.byId(_6a),c=s.clipNode=p.ownerDocument.createElement("div"),r=s.rawNode=p.ownerDocument.createElement("v:group"),cs=c.style,rs=r.style; |
764 |
if(d.isIE>7){ |
765 |
rs.display="inline-block";
|
766 |
} |
767 |
s._parent=p; |
768 |
s._nodes.push(c); |
769 |
p.style.width=_6b; |
770 |
p.style.height=_6c; |
771 |
cs.position="absolute";
|
772 |
cs.width=_6b; |
773 |
cs.height=_6c; |
774 |
cs.clip="rect(0px "+_6b+" "+_6c+" 0px)"; |
775 |
rs.position="absolute";
|
776 |
rs.width=_6b; |
777 |
rs.height=_6c; |
778 |
r.coordsize=(_6b==="100%"?_6b:parseFloat(_6b))+" "+(_6c==="100%"?_6c:parseFloat(_6c)); |
779 |
r.coordorigin="0 0";
|
780 |
var b=s.bgNode=r.ownerDocument.createElement("v:rect"),bs=b.style; |
781 |
bs.left=bs.top=0;
|
782 |
bs.width=rs.width; |
783 |
bs.height=rs.height; |
784 |
b.filled=b.stroked="f";
|
785 |
r.appendChild(b); |
786 |
c.appendChild(r); |
787 |
p.appendChild(c); |
788 |
s.width=g.normalizedLength(_6b); |
789 |
s.height=g.normalizedLength(_6c); |
790 |
return s;
|
791 |
}; |
792 |
_1.Container={_init:function(){ |
793 |
gs.Container._init.call(this);
|
794 |
},add:function(_6d){ |
795 |
if(this!=_6d.getParent()){ |
796 |
this.rawNode.appendChild(_6d.rawNode);
|
797 |
if(!_6d.getParent()){
|
798 |
_6d.setFill(_6d.getFill()); |
799 |
_6d.setStroke(_6d.getStroke()); |
800 |
} |
801 |
gs.Container.add.apply(this,arguments); |
802 |
} |
803 |
return this; |
804 |
},remove:function(_6e,_6f){ |
805 |
if(this==_6e.getParent()){ |
806 |
if(this.rawNode==_6e.rawNode.parentNode){ |
807 |
this.rawNode.removeChild(_6e.rawNode);
|
808 |
} |
809 |
gs.Container.remove.apply(this,arguments); |
810 |
} |
811 |
return this; |
812 |
},clear:function(){ |
813 |
var r=this.rawNode; |
814 |
while(r.firstChild!=r.lastChild){
|
815 |
if(r.firstChild!=this.bgNode){ |
816 |
r.removeChild(r.firstChild); |
817 |
} |
818 |
if(r.lastChild!=this.bgNode){ |
819 |
r.removeChild(r.lastChild); |
820 |
} |
821 |
} |
822 |
return gs.Container.clear.apply(this,arguments); |
823 |
},_moveChildToFront:gs.Container._moveChildToFront,_moveChildToBack:gs.Container._moveChildToBack}; |
824 |
dojo.mixin(gs.Creator,{createGroup:function(){ |
825 |
var _70=this.createObject(g.Group,null); |
826 |
var r=_70.rawNode.ownerDocument.createElement("v:rect"); |
827 |
r.style.left=r.style.top=0;
|
828 |
r.style.width=_70.rawNode.style.width; |
829 |
r.style.height=_70.rawNode.style.height; |
830 |
r.filled=r.stroked="f";
|
831 |
_70.rawNode.appendChild(r); |
832 |
_70.bgNode=r; |
833 |
return _70;
|
834 |
},createImage:function(_71){ |
835 |
if(!this.rawNode){ |
836 |
return null; |
837 |
} |
838 |
var _72=new g.Image(),doc=this.rawNode.ownerDocument,_73=doc.createElement("v:rect"); |
839 |
_73.stroked="f";
|
840 |
_73.style.width=this.rawNode.style.width;
|
841 |
_73.style.height=this.rawNode.style.height;
|
842 |
var img=doc.createElement("v:imagedata"); |
843 |
_73.appendChild(img); |
844 |
_72.setRawNode(_73); |
845 |
this.rawNode.appendChild(_73);
|
846 |
_72.setShape(_71); |
847 |
this.add(_72);
|
848 |
return _72;
|
849 |
},createRect:function(_74){ |
850 |
if(!this.rawNode){ |
851 |
return null; |
852 |
} |
853 |
var _75=new g.Rect,_76=this.rawNode.ownerDocument.createElement("v:roundrect"); |
854 |
if(d.isIE>7){ |
855 |
_76.style.display="inline-block";
|
856 |
} |
857 |
_75.setRawNode(_76); |
858 |
this.rawNode.appendChild(_76);
|
859 |
_75.setShape(_74); |
860 |
this.add(_75);
|
861 |
return _75;
|
862 |
},createObject:function(_77,_78){ |
863 |
if(!this.rawNode){ |
864 |
return null; |
865 |
} |
866 |
var _79=new _77(),_7a=this.rawNode.ownerDocument.createElement("v:"+_77.nodeType); |
867 |
_79.setRawNode(_7a); |
868 |
this.rawNode.appendChild(_7a);
|
869 |
switch(_77){
|
870 |
case g.Group:
|
871 |
case g.Line:
|
872 |
case g.Polyline:
|
873 |
case g.Image:
|
874 |
case g.Text:
|
875 |
case g.Path:
|
876 |
case g.TextPath:
|
877 |
this._overrideSize(_7a);
|
878 |
} |
879 |
_79.setShape(_78); |
880 |
this.add(_79);
|
881 |
return _79;
|
882 |
},_overrideSize:function(_7b){ |
883 |
var s=this.rawNode.style,w=s.width,h=s.height; |
884 |
_7b.style.width=w; |
885 |
_7b.style.height=h; |
886 |
_7b.coordsize=parseInt(w)+" "+parseInt(h);
|
887 |
}}); |
888 |
d.extend(g.Group,_1.Container); |
889 |
d.extend(g.Group,gs.Creator); |
890 |
d.extend(g.Surface,_1.Container); |
891 |
d.extend(g.Surface,gs.Creator); |
892 |
})(); |
893 |
} |