/* YUI 3.7.3 (build 5687) Copyright 2012 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add("graphics-svg",function(e,t){function g(){}var n="svg",r="shape",i=/[a-z][^a-z]*/ig,s=/[-]?[0-9]*[0-9|\.][0-9]*/g,o=e.Lang,u=e.AttributeLite,a,f,l,c,h,p,d,v=e.config.doc,m=e.ClassNameManager.getClassName;g.prototype={_pathSymbolToMethod:{M:"moveTo",m:"relativeMoveTo",L:"lineTo",l:"relativeLineTo",C:"curveTo",c:"relativeCurveTo",Q:"quadraticCurveTo",q:"relativeQuadraticCurveTo",z:"closePath",Z:"closePath"},_currentX:0,_currentY:0,_type:"path",curveTo:function(){this._curveTo.apply(this,[e.Array(arguments),!1])},relativeCurveTo:function(){this._curveTo.apply(this,[e.Array(arguments),!0])},_curveTo:function(e,t){var n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b=t?"c":"C",w=t?parseFloat(this._currentX):0,E=t?parseFloat(this._currentY):0;this._pathArray=this._pathArray||[],this._pathType!==b?(this._pathType=b,y=[b],this._pathArray.push(y)):(y=this._pathArray[Math.max(0,this._pathArray.length-1)],y||(y=[],this._pathArray.push(y))),g=this._pathArray.length-1,this._pathArray[g]=this._pathArray[g].concat(e),m=e.length-5;for(v=0;v360&&(r=360),o=Math.ceil(Math.abs(r)/45),u=r/o,a=-(u/180)*Math.PI,f=n/180*Math.PI;if(o>0){c=e+Math.cos(n/180*Math.PI)*i,h=t+Math.sin(n/180*Math.PI)*s,this._pathType="L",w++,this._pathArray[w]=["L"],this._pathArray[w].push(Math.round(c)),this._pathArray[w].push(Math.round(h)),w++,this._pathType="Q",this._pathArray[w]=["Q"];for(g=0;g0){n=t.shift(),i=n.length,r=n[0],r==="A"?a+=r+n[1]+","+n[2]:r=="z"||r=="Z"?a+=" z ":r=="C"||r=="c"?a+=r+(n[1]-l)+","+(n[2]-c):a+=" "+r+parseFloat(n[1]-l);switch(r){case"L":case"l":case"M":case"Q":case"q":for(u=2;uthis._right&&(this._right=e),ethis._bottom&&(this._bottom=t),this._width=this._right-this._left,this._height=this._bottom-this._top}},e.SVGDrawing=g,f=function(t){this._transforms=[],this.matrix=new e.Matrix,this._normalizedMatrix=new e.Matrix,f.superclass.constructor.apply(this,arguments)},f.NAME="shape",e.extend(f,e.GraphicBase,e.mix({_x:0,_y:0,init:function(){this.initializer.apply(this,arguments)},initializer:function(e){var t=this,n=e.graphic,r=this.get("data");t.createNode(),n&&t._setGraphic(n),r&&t._parsePathData(r),t._updateHandler()},_setGraphic:function(t){var n;t instanceof e.SVGGraphic?this._graphic=t:(t=e.one(t),n=new e.SVGGraphic({render:t}),n._appendShape(this),this._graphic=n)},addClass:function(e){var t=this.node;t.className.baseVal=o.trim([t.className.baseVal,e].join(" "))},removeClass:function(e){var t=this.node,n=t.className.baseVal;n=n.replace(new RegExp(e+" "),e).replace(new RegExp(e),""),t.className.baseVal=n},getXY:function(){var e=this._graphic,t=e.getXY(),n=this._x,r=this._y;return[t[0]+n,t[1]+r]},setXY:function(e){var t=this._graphic,n=t.getXY();this._x=e[0]-n[0],this._y=e[1]-n[1],this.set("transform",this.get("transform"))},contains:function(t){return t===e.one(this.node)},compareTo:function(e){var t=this.node;return t===e},test:function(t){return e.Selector.test(this.node,t)},_getDefaultFill:function(){return{type:"solid",opacity:1,cx:.5,cy:.5,fx:.5,fy:.5,r:.5}},_getDefaultStroke:function(){return{weight:1,dashstyle:"none",color:"#000",opacity:1}},createNode:function(){var t=this,i=v.createElementNS("http://www.w3.org/2000/svg","svg:"+this._type),s=t.get("id"),o=t.name,u=t._camelCaseConcat,a=t.get("pointerEvents");t.node=i,t.addClass(m(r)+" "+m(u(n,r))+" "+m(o)+" "+m(u(n,o))),s&&i.setAttribute("id",s),a&&i.setAttribute("pointer-events",a),t.get("visible")||e.one(i).setStyle("visibility","hidden")},on:function(t,n){return e.Node.DOM_EVENTS[t]?e.one("#"+this.get("id")).on(t,n):e.on.apply(this,arguments)},_strokeChangeHandler:function(e){var t=this.node,n=this.get("stroke"),r,i,s,u;n&&n.weight&&n.weight>0?(u=n.linejoin||"round",r=parseFloat(n.opacity),i=n.dashstyle||"none",s=o.isArray(i)?i.toString():i,n.color=n.color||"#000000",n.weight=n.weight||1,n.opacity=o.isNumber(r)?r:1,n.linecap=n.linecap||"butt",t.setAttribute("stroke-dasharray",s),t.setAttribute("stroke",n.color),t.setAttribute("stroke-linecap",n.linecap),t.setAttribute("stroke-width",n.weight),t.setAttribute("stroke-opacity",n.opacity),u=="round"||u=="bevel"?t.setAttribute("stroke-linejoin",u):(u=parseInt(u,10),o.isNumber(u)&&(t.setAttribute("stroke-miterlimit",Math.max(u,1)),t.setAttribute("stroke-linejoin","miter")))):t.setAttribute("stroke","none")},_fillChangeHandler:function(e){var t=this.node,n=this.get("fill"),r,i;n?(i=n.type,i=="linear"||i=="radial"?(this._setGradientFill(n),t.setAttribute("fill","url(#grad"+this.get("id")+")")):n.color?(r=parseFloat(n.opacity),r=o.isNumber(r)?r:1,t.setAttribute("fill",n.color),t.setAttribute("fill-opacity",r)):t.setAttribute("fill","none")):t.setAttribute("fill","none")},_setGradientFill:function(e){var t,n,r,i,s,u=o.isNumber,a=this._graphic,f=e.type,l=a.getGradientNode("grad"+this.get("id"),f),c=e.stops,h=this.get("width"),p=this.get("height"),d=e.rotation||0,v=Math.PI/180,m=parseFloat(parseFloat(Math.tan(d*v)).toFixed(8)),g,y,b,w,E="0%",S="100%",x="0%",T="0%",N=e.cx,C=e.cy,k=e.fx,L=e.fy,A=e.r,O=[];f=="linear"?(N=h/2,C=p/2,Math.abs(m)*h/2>=p/2?(d<180?(x=0,T=p):(x=p,T=0),E=N-(C-x)/m,S=N-(C-T)/m):(d>90&&d<270?(E=h,S=0):(E=0,S=h),x=(m*(N-E)-C)*-1,T=(m*(N-S)-C)*-1),E=Math.round(100*E/h),S=Math.round(100*S/h),x=Math.round(100*x/p),T=Math.round(100*T/p),E=u(E)?E:0,S=u(S)?S:100,x=u(x)?x:0,T=u(T)?T:0,l.setAttribute("spreadMethod","pad"),l.setAttribute("width",h),l.setAttribute("height",p),l.setAttribute("x1",E+"%"),l.setAttribute("x2",S+"%"),l.setAttribute("y1",x+"%"),l.setAttribute("y2",T+"%")):(l.setAttribute("cx",N*100+"%"),l.setAttribute("cy",C*100+"%"),l.setAttribute("fx",k*100+"%"),l.setAttribute("fy",L*100+"%"),l.setAttribute("r",A*100+"%")),y=c.length,b=0;for(g=0;g0?(i=this._stops.shift(),s=!1):(i=a._createGraphicNode("stop"),s=!0),w=c[g],n=w.opacity,r=w.color,t=w.offset||g/(y-1),t=Math.round(t*100)+"%",n=u(n)?n:1,n=Math.max(0,Math.min(1,n)),b=(g+1)/y,i.setAttribute("offset",t),i.setAttribute("stop-color",r),i.setAttribute("stop-opacity",n),s&&l.appendChild(i),O.push(i);while(this._stops&&this._stops.length>0)l.removeChild(this._stops.shift());this._stops=O},_stops:null,set:function(){var e=this;u.prototype.set.apply(e,arguments),e.initialized&&e._updateHandler()},translate:function(e,t){this._addTransform("translate",arguments)},translateX:function(e){this._addTransform("translateX",arguments)},translateY:function(e){this._addTransform("translateY",arguments)},skew:function(e,t){this._addTransform("skew",arguments)},skewX:function(e){this._addTransform("skewX",arguments)},skewY:function(e){this._addTransform("skewY",arguments)},rotate:function(e){this._addTransform("rotate",arguments)},scale:function(e,t){this._addTransform("scale",arguments)},_addTransform:function(t,n){n=e.Array(n),this._transform=o.trim(this._transform+" "+t+"("+n.join(", ")+")"),n.unshift(t),this._transforms.push(n),this.initialized&&this._updateTransform()},_updateTransform:function(){var t=this._type=="path",n=this.node,r,i,s,o,u,a,f,l=this.matrix,c=this._normalizedMatrix,h,p=this._transforms.length;if(t||this._transforms&&this._transforms.length>0){o=this._x,u=this._y,s=this.get("transformOrigin"),a=o+s[0]*this.get("width"),f=u+s[1]*this.get("height"),t&&(this instanceof e.SVGPath||(a=this._left+s[0]*this.get("width"),f=this._top+s[1]*this.get("height")),c.init({dx:o+this._left,dy:u+this._top})),c.translate(a,f);for(h=0;h0)if(o.isString&&i[t])a=!0;else if(o.isObject(t))for(s in i)if(i.hasOwnProperty(s)&&t[s]){a=!0;break}a&&r._redraw()},_x:0,_y:0,getXY:function(){var t=e.one(this._node),n;return t&&(n=t.getXY()),n},initializer:function(){var e=this.get("render"),t=this.get("visible")?"visible":"hidden";this._shapes={},this._contentBounds={left:0,top:0,right:0,bottom:0},this._gradients={},this._node=v.createElement("div"),this._node.style.position="absolute",this._node.style.left=this.get("x")+"px",this._node.style.top=this.get("y")+"px",this._node.style.visibility=t,this._contentNode=this._createGraphics(),this._contentNode.style.visibility=t,this._contentNode.setAttribute("id",this.get("id")),this._node.appendChild(this._contentNode),e&&this.render(e)},render:function(t){var n=e.one(t),r=this.get("width")||parseInt(n.getComputedStyle("width"),10),i=this.get("height")||parseInt(n.getComputedStyle("height"),10);return n=n||e.one(v.body),n.append(this._node),this.parentNode=n,this.set("width",r),this.set("height",i),this},destroy:function(){this.removeAllShapes(),this._contentNode&&(this._removeChildren(this._contentNode),this._contentNode.parentNode&&this._contentNode.parentNode.removeChild(this._contentNode),this._contentNode=null),this._node&&(this._removeChildren(this._node),e.one(this._node).remove(!0),this._node=null)},addShape:function(e){e.graphic=this,this.get("visible")||(e.visible=!1);var t=this._getShapeClass(e.type),n=new t(e);return this._appendShape(n),n},_appendShape:function(e){var t=e.node,n=this._frag||this._contentNode;this.get("autoDraw")?n.appendChild(t):this._getDocFrag().appendChild(t)},removeShape:function(e){return e instanceof f||o.isString(e)&&(e=this._shapes[e]),e&&e instanceof f&&(e._destroy(),delete this._shapes[e.get("id")]),this.get("autoDraw")&&this._redraw(),e},removeAllShapes:function(){var e=this._shapes,t;for(t in e)e.hasOwnProperty(t)&&e[t]._destroy();this._shapes={}},_removeChildren:function(e){if(e.hasChildNodes()){var t;while(e.firstChild)t=e.firstChild,this._removeChildren(t),e.removeChild(t)}},clear:function(){this.removeAllShapes()},_toggleVisible:function(e){var t,n=this._shapes,r=e?"visible":"hidden";if(n)for(t in n)n.hasOwnProperty(t)&&n[t].set("visible",e);this._contentNode&&(this._contentNode.style.visibility=r),this._node&&(this._node.style.visibility=r)},_getShapeClass:function(e){var t=this._shapeClass[e];return t?t:e},_shapeClass:{circle:e.SVGCircle,rect:e.SVGRect,path:e.SVGPath,ellipse:e.SVGEllipse,pieslice:e.SVGPieSlice},getShapeById:function(e){var t=this._shapes[e];return t},batch:function(e){var t=this.get("autoDraw");this.set("autoDraw",!1),e(),this.set("autoDraw",t)},_getDocFrag:function(){return this._frag||(this._frag=v.createDocumentFragment()),this._frag},_redraw:function(){var t=this.get("autoSize"),n=this.get("preserveAspectRatio"),r=this.get("resizeDown")?this._getUpdatedContentBounds():this._contentBounds,i=r.left,s=r.right,o=r.top,u=r.bottom,a=s-i,f=u-o,l,c,h,p,d;t?t=="sizeContentToGraphic"?(d=e.one(this._node),l=parseFloat(d.getComputedStyle("width")),c=parseFloat(d.getComputedStyle("height")),h=p=0,this._contentNode.setAttribute("preserveAspectRatio",n)):(l=a,c=f,h=i,p=o,this._state.width=a,this._state.height=f,this._node&&(this._node.style.width=a+"px",this._node.style.height=f+"px")):(l=a,c=f,h=i,p=o),this._contentNode&&(this._contentNode.style.left=h+"px",this._contentNode.style.top=p+"px",this._contentNode.setAttribute("width",l),this._contentNode.setAttribute("height",c),this._contentNode.style.width=l+"px",this._contentNode.style.height=c+"px",this._contentNode.setAttribute("viewBox",""+i+" "+o+" "+a+" "+f+"")),this._frag&&(this._contentNode&&this._contentNode.appendChild(this._frag),this._frag=null)},addToRedrawQueue:function(e){var t,n;this._shapes[e.get("id")]=e,this.get("resizeDown")||(t=e.getBounds(),n=this._contentBounds,n.left=n.leftt.right?n.right:t.right,n.bottom=n.bottom>t.bottom?n.bottom:t.bottom,n.width=n.right-n.left,n.height=n.bottom-n.top,this._contentBounds=n),this.get("autoDraw")&&this._redraw()},_getUpdatedContentBounds:function(){var e,t,n,r=this._shapes,i={};for(t in r)r.hasOwnProperty(t)&&(n=r[t],e=n.getBounds(),i.left=o.isNumber(i.left)?Math.min(i.left,e.left):e.left,i.top=o.isNumber(i.top)?Math.min(i.top,e.top):e.top,i.right=o.isNumber(i.right)?Math.max(i.right,e.right):e.right,i.bottom=o.isNumber(i.bottom)?Math.max(i.bottom,e.bottom):e.bottom);return i.left=o.isNumber(i.left)?i.left:0,i.top=o.isNumber(i.top)?i.top:0,i.right=o.isNumber(i.right)?i.right:0,i.bottom=o.isNumber(i.bottom)?i.bottom:0,this._contentBounds=i,i},_createGraphics:function(){var e=this._createGraphicNode("svg"),t=this.get("pointerEvents");return e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.overflow="auto",e.setAttribute("overflow","auto"),e.setAttribute("pointer-events",t),e},_createGraphicNode:function(e,t){var n=v.createElementNS("http://www.w3.org/2000/svg","svg:"+e),r=t||"none";return e!=="defs"&&e!=="stop"&&e!=="linearGradient"&&e!="radialGradient"&&n.setAttribute("pointer-events",r),n},getGradientNode:function(e,t){var n=this._gradients,r,i=t+"Gradient";return n.hasOwnProperty(e)&&n[e].tagName.indexOf(t)>-1?r=this._gradients[e]:(r=this._createGraphicNode(i),this._defs||(this._defs=this._createGraphicNode("defs"),this._contentNode.appendChild(this._defs)),this._defs.appendChild(r),e=e||"gradient"+Math.round(1e5*Math.random()),r.setAttribute("id",e),n.hasOwnProperty(e)&&this._defs.removeChild(n[e]),n[e]=r),r},_toFront:function(t){var n=this._contentNode;t instanceof e.SVGShape&&(t=t.get("node")),n&&t&&n.appendChild(t)},_toBack:function(t){var n=this._contentNode,r;t instanceof e.SVGShape&&(t=t.get("node")),n&&t&&(r=n.firstChild,r?n.insertBefore(t,r):n.appendChild(t))}}),e.SVGGraphic=a},"3.7.3",{requires:["graphics"]});