/*
	Copyright (c) 2004-2008, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


dojo._xdResourceLoaded(function(_1,_2,_3){return {depends:[["provide","dojox.gfx.svg"],["require","dojox.gfx._base"],["require","dojox.gfx.shape"],["require","dojox.gfx.path"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["dojox.gfx.svg"]){_4._hasResource["dojox.gfx.svg"]=true;_4.provide("dojox.gfx.svg");_4.require("dojox.gfx._base");_4.require("dojox.gfx.shape");_4.require("dojox.gfx.path");_6.gfx.svg.xmlns={xlink:"http://www.w3.org/1999/xlink",svg:"http://www.w3.org/2000/svg"};_6.gfx.svg.getRef=function(_7){if(!_7||_7=="none"){return null;}if(_7.match(/^url\(#.+\)$/)){return _4.byId(_7.slice(5,-1));}if(_7.match(/^#dojoUnique\d+$/)){return _4.byId(_7.slice(1));}return null;};_6.gfx.svg.dasharray={solid:"none",shortdash:[4,1],shortdot:[1,1],shortdashdot:[4,1,1,1],shortdashdotdot:[4,1,1,1,1,1],dot:[1,3],dash:[4,3],longdash:[8,3],dashdot:[4,3,1,3],longdashdot:[8,3,1,3],longdashdotdot:[8,3,1,3,1,3]};_4.extend(_6.gfx.Shape,{setFill:function(_8){if(!_8){this.fillStyle=null;this.rawNode.setAttribute("fill","none");this.rawNode.setAttribute("fill-opacity",0);return this;}var f;var _a=function(x){this.setAttribute(x,f[x].toFixed(8));};if(typeof (_8)=="object"&&"type" in _8){switch(_8.type){case "linear":f=_6.gfx.makeParameters(_6.gfx.defaultLinearGradient,_8);var _c=this._setFillObject(f,"linearGradient");_4.forEach(["x1","y1","x2","y2"],_a,_c);break;case "radial":f=_6.gfx.makeParameters(_6.gfx.defaultRadialGradient,_8);var _c=this._setFillObject(f,"radialGradient");_4.forEach(["cx","cy","r"],_a,_c);break;case "pattern":f=_6.gfx.makeParameters(_6.gfx.defaultPattern,_8);var _d=this._setFillObject(f,"pattern");_4.forEach(["x","y","width","height"],_a,_d);break;}this.fillStyle=f;return this;}var f=_6.gfx.normalizeColor(_8);this.fillStyle=f;this.rawNode.setAttribute("fill",f.toCss());this.rawNode.setAttribute("fill-opacity",f.a);this.rawNode.setAttribute("fill-rule","evenodd");return this;},setStroke:function(_e){if(!_e){this.strokeStyle=null;this.rawNode.setAttribute("stroke","none");this.rawNode.setAttribute("stroke-opacity",0);return this;}if(typeof _e=="string"||_4.isArray(_e)||_e instanceof _4.Color){_e={color:_e};}var s=this.strokeStyle=_6.gfx.makeParameters(_6.gfx.defaultStroke,_e);s.color=_6.gfx.normalizeColor(s.color);var rn=this.rawNode;if(s){rn.setAttribute("stroke",s.color.toCss());rn.setAttribute("stroke-opacity",s.color.a);rn.setAttribute("stroke-width",s.width);rn.setAttribute("stroke-linecap",s.cap);if(typeof s.join=="number"){rn.setAttribute("stroke-linejoin","miter");rn.setAttribute("stroke-miterlimit",s.join);}else{rn.setAttribute("stroke-linejoin",s.join);}var da=s.style.toLowerCase();if(da in _6.gfx.svg.dasharray){da=_6.gfx.svg.dasharray[da];}if(da instanceof Array){da=_4.clone(da);for(var i=0;i<da.length;++i){da[i]*=s.width;}if(s.cap!="butt"){for(var i=0;i<da.length;i+=2){da[i]-=s.width;if(da[i]<1){da[i]=1;}}for(var i=1;i<da.length;i+=2){da[i]+=s.width;}}da=da.join(",");}rn.setAttribute("stroke-dasharray",da);rn.setAttribute("dojoGfxStrokeStyle",s.style);}return this;},_getParentSurface:function(){var _13=this.parent;for(;_13&&!(_13 instanceof _6.gfx.Surface);_13=_13.parent){}return _13;},_setFillObject:function(f,_15){var _16=_6.gfx.svg.xmlns.svg;this.fillStyle=f;var _17=this._getParentSurface(),_18=_17.defNode,_19=this.rawNode.getAttribute("fill"),ref=_6.gfx.svg.getRef(_19);if(ref){_19=ref;if(_19.tagName.toLowerCase()!=_15.toLowerCase()){var id=_19.id;_19.parentNode.removeChild(_19);_19=document.createElementNS(_16,_15);_19.setAttribute("id",id);_18.appendChild(_19);}else{while(_19.childNodes.length){_19.removeChild(_19.lastChild);}}}else{_19=document.createElementNS(_16,_15);_19.setAttribute("id",_6.gfx._base._getUniqueId());_18.appendChild(_19);}if(_15=="pattern"){if(_4.isSafari){_19.setAttributeNS(null,"patternUnits","userSpaceOnUse");}else{_19.setAttribute("patternUnits","userSpaceOnUse");}var img=document.createElementNS(_16,"image");img.setAttribute("x",0);img.setAttribute("y",0);img.setAttribute("width",f.width.toFixed(8));img.setAttribute("height",f.height.toFixed(8));img.setAttributeNS(_6.gfx.svg.xmlns.xlink,"href",f.src);_19.appendChild(img);}else{if(_4.isSafari){_19.setAttributeNS(null,"gradientUnits","userSpaceOnUse");}else{_19.setAttribute("gradientUnits","userSpaceOnUse");}for(var i=0;i<f.colors.length;++i){var c=f.colors[i],t=document.createElementNS(_16,"stop"),cc=c.color=_6.gfx.normalizeColor(c.color);t.setAttribute("offset",c.offset.toFixed(8));t.setAttribute("stop-color",cc.toCss());t.setAttribute("stop-opacity",cc.a);_19.appendChild(t);}}this.rawNode.setAttribute("fill","url(#"+_19.getAttribute("id")+")");this.rawNode.removeAttribute("fill-opacity");this.rawNode.setAttribute("fill-rule","evenodd");return _19;},_applyTransform:function(){var _21=this.matrix;if(_21){var tm=this.matrix;this.rawNode.setAttribute("transform","matrix("+tm.xx.toFixed(8)+","+tm.yx.toFixed(8)+","+tm.xy.toFixed(8)+","+tm.yy.toFixed(8)+","+tm.dx.toFixed(8)+","+tm.dy.toFixed(8)+")");}else{this.rawNode.removeAttribute("transform");}return this;},setRawNode:function(_23){var r=this.rawNode=_23;r.setAttribute("fill","none");r.setAttribute("fill-opacity",0);r.setAttribute("stroke","none");r.setAttribute("stroke-opacity",0);r.setAttribute("stroke-width",1);r.setAttribute("stroke-linecap","butt");r.setAttribute("stroke-linejoin","miter");r.setAttribute("stroke-miterlimit",4);},setShape:function(_25){this.shape=_6.gfx.makeParameters(this.shape,_25);for(var i in this.shape){if(i!="type"){this.rawNode.setAttribute(i,this.shape[i]);}}return this;},_moveToFront:function(){this.rawNode.parentNode.appendChild(this.rawNode);return this;},_moveToBack:function(){this.rawNode.parentNode.insertBefore(this.rawNode,this.rawNode.parentNode.firstChild);return this;}});_4.declare("dojox.gfx.Group",_6.gfx.Shape,{constructor:function(){_6.gfx.svg.Container._init.call(this);},setRawNode:function(_27){this.rawNode=_27;}});_6.gfx.Group.nodeType="g";_4.declare("dojox.gfx.Rect",_6.gfx.shape.Rect,{setShape:function(_28){this.shape=_6.gfx.makeParameters(this.shape,_28);this.bbox=null;for(var i in this.shape){if(i!="type"&&i!="r"){this.rawNode.setAttribute(i,this.shape[i]);}}if(this.shape.r){this.rawNode.setAttribute("ry",this.shape.r);this.rawNode.setAttribute("rx",this.shape.r);}return this;}});_6.gfx.Rect.nodeType="rect";_6.gfx.Ellipse=_6.gfx.shape.Ellipse;_6.gfx.Ellipse.nodeType="ellipse";_6.gfx.Circle=_6.gfx.shape.Circle;_6.gfx.Circle.nodeType="circle";_6.gfx.Line=_6.gfx.shape.Line;_6.gfx.Line.nodeType="line";_4.declare("dojox.gfx.Polyline",_6.gfx.shape.Polyline,{setShape:function(_2a,_2b){if(_2a&&_2a instanceof Array){this.shape=_6.gfx.makeParameters(this.shape,{points:_2a});if(_2b&&this.shape.points.length){this.shape.points.push(this.shape.points[0]);}}else{this.shape=_6.gfx.makeParameters(this.shape,_2a);}this.box=null;var _2c=[],p=this.shape.points;for(var i=0;i<p.length;++i){if(typeof p[i]=="number"){_2c.push(p[i].toFixed(8));}else{_2c.push(p[i].x.toFixed(8));_2c.push(p[i].y.toFixed(8));}}this.rawNode.setAttribute("points",_2c.join(" "));return this;}});_6.gfx.Polyline.nodeType="polyline";_4.declare("dojox.gfx.Image",_6.gfx.shape.Image,{setShape:function(_2f){this.shape=_6.gfx.makeParameters(this.shape,_2f);this.bbox=null;var _30=this.rawNode;for(var i in this.shape){if(i!="type"&&i!="src"){_30.setAttribute(i,this.shape[i]);}}_30.setAttributeNS(_6.gfx.svg.xmlns.xlink,"href",this.shape.src);return this;}});_6.gfx.Image.nodeType="image";_4.declare("dojox.gfx.Text",_6.gfx.shape.Text,{setShape:function(_32){this.shape=_6.gfx.makeParameters(this.shape,_32);this.bbox=null;var r=this.rawNode,s=this.shape;r.setAttribute("x",s.x);r.setAttribute("y",s.y);r.setAttribute("text-anchor",s.align);r.setAttribute("text-decoration",s.decoration);r.setAttribute("rotate",s.rotated?90:0);r.setAttribute("kerning",s.kerning?"auto":0);r.setAttribute("text-rendering","optimizeLegibility");r.textContent=s.text;return this;},getTextWidth:function(){var _35=this.rawNode,_36=_35.parentNode,_37=_35.cloneNode(true);_37.style.visibility="hidden";var _38=0,_39=_37.firstChild.nodeValue;_36.appendChild(_37);if(_39!=""){while(!_38){_38=parseInt(_37.getBBox().width);}}_36.removeChild(_37);return _38;}});_6.gfx.Text.nodeType="text";_4.declare("dojox.gfx.Path",_6.gfx.path.Path,{_updateWithSegment:function(_3a){_6.gfx.Path.superclass._updateWithSegment.apply(this,arguments);if(typeof (this.shape.path)=="string"){this.rawNode.setAttribute("d",this.shape.path);}},setShape:function(_3b){_6.gfx.Path.superclass.setShape.apply(this,arguments);this.rawNode.setAttribute("d",this.shape.path);return this;}});_6.gfx.Path.nodeType="path";_4.declare("dojox.gfx.TextPath",_6.gfx.path.TextPath,{_updateWithSegment:function(_3c){_6.gfx.Path.superclass._updateWithSegment.apply(this,arguments);this._setTextPath();},setShape:function(_3d){_6.gfx.Path.superclass.setShape.apply(this,arguments);this._setTextPath();return this;},_setTextPath:function(){if(typeof this.shape.path!="string"){return;}var r=this.rawNode;if(!r.firstChild){var tp=document.createElementNS(_6.gfx.svg.xmlns.svg,"textPath"),tx=document.createTextNode("");tp.appendChild(tx);r.appendChild(tp);}var ref=r.firstChild.getAttributeNS(_6.gfx.svg.xmlns.xlink,"href"),_42=ref&&_6.gfx.svg.getRef(ref);if(!_42){var _43=this._getParentSurface();if(_43){var _44=_43.defNode;_42=document.createElementNS(_6.gfx.svg.xmlns.svg,"path");var id=_6.gfx._base._getUniqueId();_42.setAttribute("id",id);_44.appendChild(_42);r.firstChild.setAttributeNS(_6.gfx.svg.xmlns.xlink,"href","#"+id);}}if(_42){_42.setAttribute("d",this.shape.path);}},_setText:function(){var r=this.rawNode;if(!r.firstChild){var tp=document.createElementNS(_6.gfx.svg.xmlns.svg,"textPath"),tx=document.createTextNode("");tp.appendChild(tx);r.appendChild(tp);}r=r.firstChild;var t=this.text;r.setAttribute("alignment-baseline","middle");switch(t.align){case "middle":r.setAttribute("text-anchor","middle");r.setAttribute("startOffset","50%");break;case "end":r.setAttribute("text-anchor","end");r.setAttribute("startOffset","100%");break;default:r.setAttribute("text-anchor","start");r.setAttribute("startOffset","0%");break;}r.setAttribute("baseline-shift","0.5ex");r.setAttribute("text-decoration",t.decoration);r.setAttribute("rotate",t.rotated?90:0);r.setAttribute("kerning",t.kerning?"auto":0);r.firstChild.data=t.text;}});_6.gfx.TextPath.nodeType="text";_4.declare("dojox.gfx.Surface",_6.gfx.shape.Surface,{constructor:function(){_6.gfx.svg.Container._init.call(this);},destroy:function(){this.defNode=null;this.inherited(arguments);},setDimensions:function(_4a,_4b){if(!this.rawNode){return this;}this.rawNode.setAttribute("width",_4a);this.rawNode.setAttribute("height",_4b);return this;},getDimensions:function(){return this.rawNode?{width:this.rawNode.getAttribute("width"),height:this.rawNode.getAttribute("height")}:null;}});_6.gfx.createSurface=function(_4c,_4d,_4e){var s=new _6.gfx.Surface();s.rawNode=document.createElementNS(_6.gfx.svg.xmlns.svg,"svg");s.rawNode.setAttribute("width",_4d);s.rawNode.setAttribute("height",_4e);var _50=document.createElementNS(_6.gfx.svg.xmlns.svg,"defs");s.rawNode.appendChild(_50);s.defNode=_50;s._parent=_4.byId(_4c);s._parent.appendChild(s.rawNode);return s;};_6.gfx.svg.Font={_setFont:function(){var f=this.fontStyle;this.rawNode.setAttribute("font-style",f.style);this.rawNode.setAttribute("font-variant",f.variant);this.rawNode.setAttribute("font-weight",f.weight);this.rawNode.setAttribute("font-size",f.size);this.rawNode.setAttribute("font-family",f.family);}};_6.gfx.svg.Container={_init:function(){_6.gfx.shape.Container._init.call(this);},add:function(_52){if(this!=_52.getParent()){this.rawNode.appendChild(_52.rawNode);_6.gfx.shape.Container.add.apply(this,arguments);}return this;},remove:function(_53,_54){if(this==_53.getParent()){if(this.rawNode==_53.rawNode.parentNode){this.rawNode.removeChild(_53.rawNode);}_6.gfx.shape.Container.remove.apply(this,arguments);}return this;},clear:function(){var r=this.rawNode;while(r.lastChild){r.removeChild(r.lastChild);}var d=this.defNode;if(d){while(d.lastChild){d.removeChild(d.lastChild);}r.appendChild(d);}return _6.gfx.shape.Container.clear.apply(this,arguments);},_moveChildToFront:_6.gfx.shape.Container._moveChildToFront,_moveChildToBack:_6.gfx.shape.Container._moveChildToBack};_4.mixin(_6.gfx.shape.Creator,{createObject:function(_57,_58){if(!this.rawNode){return null;}var _59=new _57(),_5a=document.createElementNS(_6.gfx.svg.xmlns.svg,_57.nodeType);_59.setRawNode(_5a);this.rawNode.appendChild(_5a);_59.setShape(_58);this.add(_59);return _59;}});_4.extend(_6.gfx.Text,_6.gfx.svg.Font);_4.extend(_6.gfx.TextPath,_6.gfx.svg.Font);_4.extend(_6.gfx.Group,_6.gfx.svg.Container);_4.extend(_6.gfx.Group,_6.gfx.shape.Creator);_4.extend(_6.gfx.Surface,_6.gfx.svg.Container);_4.extend(_6.gfx.Surface,_6.gfx.shape.Creator);}}};});
