Skip to content
Browse files

Graphics build files.

  • Loading branch information...
1 parent 091085b commit 0f600fa8611a355b40bdebf65f34aa01d6db12a6 @tripp committed Sep 3, 2011
View
1 build/graphics-canvas/graphics-canvas-debug.js
@@ -1612,6 +1612,7 @@ CanvasShape.ATTRS = {
* <dt>translateY</dt><dd>Translates the shape along the y-axis.</dd>
* <dt>skewX</dt><dd>Skews the shape around the x-axis.</dd>
* <dt>skewY</dt><dd>Skews the shape around the y-axis.</dd>
+ * <dt>matrix</dt><dd>Specifies a 2D transformation matrix comprised of the specified six values.</dd>
* </dl>
* </p>
* <p>Applying transforms through the transform attribute will reset the transform matrix and apply a new transform. The shape class also contains corresponding methods for each transform
View
1 build/graphics-canvas/graphics-canvas.js
@@ -1612,6 +1612,7 @@ CanvasShape.ATTRS = {
* <dt>translateY</dt><dd>Translates the shape along the y-axis.</dd>
* <dt>skewX</dt><dd>Skews the shape around the x-axis.</dd>
* <dt>skewY</dt><dd>Skews the shape around the y-axis.</dd>
+ * <dt>matrix</dt><dd>Specifies a 2D transformation matrix comprised of the specified six values.</dd>
* </dl>
* </p>
* <p>Applying transforms through the transform attribute will reset the transform matrix and apply a new transform. The shape class also contains corresponding methods for each transform
View
29 build/graphics-svg/graphics-svg-debug.js
@@ -1032,39 +1032,27 @@ Y.extend(SVGShape, Y.BaseGraphic, Y.mix({
{
x = this.get("x");
y = this.get("y");
-
+ transformOrigin = this.get("transformOrigin");
+ tx = x + (transformOrigin[0] * this.get("width"));
+ ty = y + (transformOrigin[1] * this.get("height"));
if(isPath)
{
- x += this._left;
- y += this._top;
- matrix.init({dx: x, dy: y});
- x = 0;
- y = 0;
+ matrix.init({dx: x + this._left, dy: y + this._top});
}
+ matrix.translate(tx, ty);
for(; i < len; ++i)
{
key = this._transforms[i].shift();
if(key)
{
- if(key == "rotate" || key == "scale")
- {
- transformOrigin = this.get("transformOrigin");
- tx = x + (transformOrigin[0] * this.get("width"));
- ty = y + (transformOrigin[1] * this.get("height"));
- matrix.translate(tx, ty);
- matrix[key].apply(matrix, this._transforms[i]);
- matrix.translate(0 - tx, 0 - ty);
- }
- else
- {
- matrix[key].apply(matrix, this._transforms[i]);
- }
+ matrix[key].apply(matrix, this._transforms[i]);
}
if(isPath)
{
this._transforms[i].unshift(key);
}
}
+ matrix.translate(-tx, -ty);
transform = "matrix(" + matrix.a + "," +
matrix.b + "," +
matrix.c + "," +
@@ -1276,6 +1264,7 @@ SVGShape.ATTRS = {
* <dt>translateY</dt><dd>Translates the shape along the y-axis.</dd>
* <dt>skewX</dt><dd>Skews the shape around the x-axis.</dd>
* <dt>skewY</dt><dd>Skews the shape around the y-axis.</dd>
+ * <dt>matrix</dt><dd>Specifies a 2D transformation matrix comprised of the specified six values.</dd>
* </dl>
* </p>
* <p>Applying transforms through the transform attribute will reset the transform matrix and apply a new transform. The shape class also contains corresponding methods for each transform
@@ -1294,7 +1283,7 @@ SVGShape.ATTRS = {
*/
transform: {
setter: function(val)
- {
+ {
this.matrix.init();
this._transforms = this.matrix.getTransformArray(val);
this._transform = val;
View
6 build/graphics-svg/graphics-svg-min.js
@@ -1,4 +1,4 @@
YUI.add("graphics-svg",function(b){var i="svgShape",c=b.Lang,g=b.AttributeLite,d,l,f,h,k,e,j,m=b.config.doc;function a(){}a.prototype={_type:"path",curveTo:function(s,q,z,w,v,u){var o,t,r,n,p,A;if(this._pathType!=="C"){this._pathType="C";t=["C"];this._pathArray.push(t);}else{t=this._pathArray[Math.max(0,this._pathArray.length-1)];if(!t){t=[];this._pathArray.push(t);}}o=this._pathArray.length-1;this._pathArray[o]=this._pathArray[o].concat([Math.round(s),Math.round(q),Math.round(z),Math.round(w),v,u]);r=Math.max(v,Math.max(s,z));p=Math.max(u,Math.max(q,w));n=Math.min(v,Math.min(s,z));A=Math.min(u,Math.min(q,w));this._trackSize(r,p);this._trackSize(n,A);},quadraticCurveTo:function(s,r,v,u){var o,t,q,n,p,w;if(this._pathType!=="Q"){this._pathType="Q";t=["Q"];this._pathArray.push(t);}else{t=this._pathArray[Math.max(0,this._pathArray.length-1)];if(!t){t=[];this._pathArray.push(t);}}o=this._pathArray.length-1;this._pathArray[o]=this._pathArray[o].concat([Math.round(s),Math.round(r),Math.round(v),Math.round(u)]);q=Math.max(v,s);p=Math.max(u,r);n=Math.min(v,s);w=Math.min(u,r);this._trackSize(q,p);this._trackSize(n,w);},drawRect:function(n,q,o,p){this.moveTo(n,q);this.lineTo(n+o,q);this.lineTo(n+o,q+p);this.lineTo(n,q+p);this.lineTo(n,q);},drawRoundRect:function(n,s,o,q,p,r){this.moveTo(n,s+r);this.lineTo(n,s+q-r);this.quadraticCurveTo(n,s+q,n+p,s+q);this.lineTo(n+o-p,s+q);this.quadraticCurveTo(n+o,s+q,n+o,s+q-r);this.lineTo(n+o,s+r);this.quadraticCurveTo(n+o,s,n+o-p,s);this.lineTo(n+p,s);this.quadraticCurveTo(n,s,n,s+r);},drawWedge:function(A,v,F,u,q,r){var E,D,t,J,s,B,z,I,H,p,o,G=0,w=q*2,n,C;r=r||q;if(this._pathType!="M"){this._pathType="M";n=["M"];this._pathArray.push(n);}else{n=this._getCurrentArray();}C=this._pathArray.length-1;this._pathArray[C].push(A);this._pathArray[C].push(A);if(Math.abs(u)>360){u=360;}E=Math.ceil(Math.abs(u)/45);D=u/E;t=-(D/180)*Math.PI;J=(F/180)*Math.PI;if(E>0){B=A+Math.cos(F/180*Math.PI)*q;z=v+Math.sin(F/180*Math.PI)*r;this._pathType="L";C++;this._pathArray[C]=["L"];this._pathArray[C].push(Math.round(B));this._pathArray[C].push(Math.round(z));C++;this._pathType="Q";this._pathArray[C]=["Q"];for(;G<E;++G){J+=t;s=J-(t/2);I=A+Math.cos(J)*q;H=v+Math.sin(J)*r;p=A+Math.cos(s)*(q/Math.cos(t/2));o=v+Math.sin(s)*(r/Math.cos(t/2));this._pathArray[C].push(Math.round(p));this._pathArray[C].push(Math.round(o));this._pathArray[C].push(Math.round(I));this._pathArray[C].push(Math.round(H));}}this._trackSize(w,w);return this;},lineTo:function(s,r,p){var o=arguments,q,n,u,t;this._pathArray=this._pathArray||[];if(typeof s==="string"||typeof s==="number"){o=[[s,r]];}n=o.length;this._shapeType="path";if(this._pathType!=="L"){this._pathType="L";t=["L"];this._pathArray.push(t);}else{t=this._getCurrentArray();}u=this._pathArray.length-1;for(q=0;q<n;++q){this._pathArray[u].push(o[q][0]);this._pathArray[u].push(o[q][1]);this._trackSize.apply(this,o[q]);}},_getCurrentArray:function(){var n=this._pathArray[Math.max(0,this._pathArray.length-1)];if(!n){n=[];this._pathArray.push(n);}return n;},moveTo:function(n,q){var p,o;this._pathArray=this._pathArray||[];if(this._pathType!="M"){this._pathType="M";o=["M"];this._pathArray.push(o);}else{o=this._getCurrentArray();}p=this._pathArray.length-1;this._pathArray[p]=this._pathArray[p].concat([n,q]);this._trackSize(n,q);},end:function(){this._closePath();this._graphic.addToRedrawQueue(this);},clear:function(){this._left=0;this._right=0;this._top=0;this._bottom=0;this._pathArray=[];this._path="";},_closePath:function(){var o,s,n,v,p,u,t,y="",r=this.node,q=this._left,w=this._top,x=this.get("fill");if(this._pathArray){o=this._pathArray.concat();while(o&&o.length>0){s=o.shift();v=s.length;n=s[0];y+=" "+n+(s[1]-q);switch(n){case"L":case"M":case"Q":for(t=2;t<v;++t){p=(t%2===0)?w:q;p=s[t]-p;y+=", "+p;}break;case"C":for(t=2;t<v;++t){p=(t%2===0)?w:q;u=s[t];u-=p;y+=" "+u;}break;}}if(x&&x.color){y+="z";}if(y){r.setAttribute("d",y);}this._path=y;this._fillChangeHandler();this._strokeChangeHandler();this._updateTransform();}},_trackSize:function(n,o){if(n>this._right){this._right=n;}if(n<this._left){this._left=n;}if(o<this._top){this._top=o;}if(o>this._bottom){this._bottom=o;}this._width=this._right-this._left;this._height=this._bottom-this._top;}};b.SVGDrawing=a;l=function(n){this._transforms=[];this.matrix=new b.Matrix();l.superclass.constructor.apply(this,arguments);};l.NAME="svgShape";b.extend(l,b.BaseGraphic,b.mix({init:function(){this.initializer.apply(this,arguments);},initializer:function(n){var o=this;o.createNode();o._graphic=n.graphic;o._updateHandler();},addClass:function(n){var o=this.node;o.className.baseVal=c.trim([o.className.baseVal,n].join(" "));},removeClass:function(n){var o=this.node,p=o.className.baseVal;p=p.replace(new RegExp(n+" "),n).replace(new RegExp(n),"");o.className.baseVal=p;},getXY:function(){var q=this._graphic,o=q.getXY(),n=this.get("x"),p=this.get("y");return[o[0]+n,o[1]+p];},setXY:function(o){var p=this._graphic,n=p.getXY();this.set("x",o[0]-n[0]);this.set("y",o[1]-n[1]);},contains:function(n){return n===b.one(this.node);},compareTo:function(n){var o=this.node;return o===n;},test:function(n){return b.Selector.test(this.node,n);},_getDefaultFill:function(){return{type:"solid",opacity:1,cx:0.5,cy:0.5,fx:0.5,fy:0.5,r:0.5};},_getDefaultStroke:function(){return{weight:1,dashstyle:"none",color:"#000",opacity:1};},createNode:function(){var n=m.createElementNS("http://www.w3.org/2000/svg","svg:"+this._type),p=this.get("id"),o=this.get("pointerEvents");this.node=n;this.addClass("yui3-"+i+" yui3-"+this.name);if(p){n.setAttribute("id",p);}if(o){n.setAttribute("pointer-events",o);}},on:function(o,n){if(b.Node.DOM_EVENTS[o]){return b.one("#"+this.get("id")).on(o,n);}return b.on.apply(this,arguments);},_strokeChangeHandler:function(s){var q=this.node,r=this.get("stroke"),p,n,t,o;if(r&&r.weight&&r.weight>0){o=r.linejoin||"round";p=parseFloat(r.opacity);n=r.dashstyle||"none";t=c.isArray(n)?n.toString():n;r.color=r.color||"#000000";r.weight=r.weight||1;r.opacity=c.isNumber(p)?p:1;
-r.linecap=r.linecap||"butt";q.setAttribute("stroke-dasharray",t);q.setAttribute("stroke",r.color);q.setAttribute("stroke-linecap",r.linecap);q.setAttribute("stroke-width",r.weight);q.setAttribute("stroke-opacity",r.opacity);if(o=="round"||o=="bevel"){q.setAttribute("stroke-linejoin",o);}else{o=parseInt(o,10);if(c.isNumber(o)){q.setAttribute("stroke-miterlimit",Math.max(o,1));q.setAttribute("stroke-linejoin","miter");}}}else{q.setAttribute("stroke","none");}},_fillChangeHandler:function(r){var p=this.node,q=this.get("fill"),n,o;if(q){o=q.type;if(o=="linear"||o=="radial"){this._setGradientFill(q);p.setAttribute("fill","url(#grad"+this.get("id")+")");}else{if(!q.color){p.setAttribute("fill","none");}else{n=parseFloat(q.opacity);n=c.isNumber(n)?n:1;p.setAttribute("fill",q.color);p.setAttribute("fill-opacity",n);}}}else{p.setAttribute("fill","none");}},_setGradientFill:function(L){var y,u,K,G,D=c.isNumber,C=this._graphic,v=L.type,J=C.getGradientNode("grad"+this.get("id"),v),z=L.stops,A=this.get("width"),P=this.get("height"),I=L.rotation,x=Math.PI/180,F=parseFloat(parseFloat(Math.tan(I*x)).toFixed(8)),M,O,B,H,Q="0%",N="100%",s="0%",o="0%",q=L.cx,n=L.cy,t=L.fx,p=L.fy,E=L.r;if(v=="linear"){q=A/2;n=P/2;if(Math.abs(F)*A/2>=P/2){if(I<180){s=0;o=P;}else{s=P;o=0;}Q=q-((n-s)/F);N=q-((n-o)/F);}else{if(I>90&&I<270){Q=A;N=0;}else{Q=0;N=A;}s=((F*(q-Q))-n)*-1;o=((F*(q-N))-n)*-1;}J.setAttribute("spreadMethod","pad");J.setAttribute("width",A);J.setAttribute("height",P);J.setAttribute("x1",Math.round(100*Q/A)+"%");J.setAttribute("y1",Math.round(100*s/P)+"%");J.setAttribute("x2",Math.round(100*N/A)+"%");J.setAttribute("y2",Math.round(100*o/P)+"%");}else{J.setAttribute("cx",(q*100)+"%");J.setAttribute("cy",(n*100)+"%");J.setAttribute("fx",(t*100)+"%");J.setAttribute("fy",(p*100)+"%");J.setAttribute("r",(E*100)+"%");}O=z.length;B=0;for(M=0;M<O;++M){H=z[M];u=H.opacity;K=H.color;y=H.offset||M/(O-1);y=Math.round(y*100)+"%";u=D(u)?u:1;u=Math.max(0,Math.min(1,u));B=(M+1)/O;G=C._createGraphicNode("stop");G.setAttribute("offset",y);G.setAttribute("stop-color",K);G.setAttribute("stop-opacity",u);J.appendChild(G);}},set:function(){var n=this;g.prototype.set.apply(n,arguments);if(n.initialized){n._updateHandler();}},translate:function(n,o){this._translateX+=n;this._translateY+=o;this._addTransform("translate",arguments);},translateX:function(n){this._translateX+=n;this._addTransform("translateX",arguments);},translateY:function(n){this._translateY+=n;this._addTransform("translateY",arguments);},skew:function(n,o){this._addTransform("skew",arguments);},skewX:function(n){this._addTransform("skewX",arguments);},skewY:function(n){this._addTransform("skewY",arguments);},_rotation:0,rotate:function(n){this._rotation=n;this._addTransform("rotate",arguments);},scale:function(n,o){this._addTransform("scale",arguments);},_addTransform:function(o,n){n=b.Array(n);this._transform=c.trim(this._transform+" "+o+"("+n.join(", ")+")");n.unshift(o);this._transforms.push(n);if(this.initialized){this._updateTransform();}},_updateTransform:function(){var u=this._type=="path",o=this.node,A,n,q,z,v,s,p,w=this.matrix,r=0,t=this._transforms.length;if(u||(this._transforms&&this._transforms.length>0)){z=this.get("x");v=this.get("y");if(u){z+=this._left;v+=this._top;w.init({dx:z,dy:v});z=0;v=0;}for(;r<t;++r){A=this._transforms[r].shift();if(A){if(A=="rotate"||A=="scale"){q=this.get("transformOrigin");s=z+(q[0]*this.get("width"));p=v+(q[1]*this.get("height"));w.translate(s,p);w[A].apply(w,this._transforms[r]);w.translate(0-s,0-p);}else{w[A].apply(w,this._transforms[r]);}}if(u){this._transforms[r].unshift(A);}}n="matrix("+w.a+","+w.b+","+w.c+","+w.d+","+w.dx+","+w.dy+")";}this._graphic.addToRedrawQueue(this);if(n){o.setAttribute("transform",n);}if(!u){this._transforms=[];}},_draw:function(){var n=this.node;n.setAttribute("width",this.get("width"));n.setAttribute("height",this.get("height"));n.setAttribute("x",this.get("x"));n.setAttribute("y",this.get("y"));n.style.left=this.get("x")+"px";n.style.top=this.get("y")+"px";this._fillChangeHandler();this._strokeChangeHandler();this._updateTransform();},_updateHandler:function(n){this._draw();},_translateX:0,_translateY:0,_transform:"",getBounds:function(){var s=this._type,n,u={},D=this.matrix,M=D.a,L=D.b,K=D.c,I=D.d,A=D.dx,y=D.dy,z=this.get("width"),G=this.get("height"),t=s=="path"?0:this.get("x"),B=s=="path"?0:this.get("y"),J=t+z,x=B+G,v=this.get("stroke"),H=(M*t+K*B+A),r=(L*t+I*B+y),F=(M*J+K*B+A),q=(L*J+I*B+y),E=(M*t+K*x+A),p=(L*t+I*x+y),C=(M*J+K*x+A),o=(L*J+I*x+y);u.left=Math.min(E,Math.min(H,Math.min(F,C)));u.right=Math.max(E,Math.max(H,Math.max(F,C)));u.top=Math.min(q,Math.min(o,Math.min(p,r)));u.bottom=Math.max(q,Math.max(o,Math.max(p,r)));if(v&&v.weight){n=v.weight;u.left-=n;u.right+=n;u.top-=n;u.bottom+=n;}return u;},_getRotatedCornerX:function(o,s,n,r,p,q){return(n+(o-n)*p+(s-r)*q);},_getRotatedCornerY:function(o,s,n,r,p,q){return(r-(o-n)*q+(s-r)*p);},destroy:function(){if(this._graphic&&this._graphic._contentNode){this._graphic._contentNode.removeChild(this.node);}}},b.SVGDrawing.prototype));l.ATTRS={transformOrigin:{valueFn:function(){return[0.5,0.5];}},transform:{setter:function(n){this.matrix.init();this._transforms=this.matrix.getTransformArray(n);this._transform=n;if(this.initialized){this._updateTransform();}return n;},getter:function(){return this._transform;}},id:{valueFn:function(){return b.guid();},setter:function(o){var n=this.node;if(n){n.setAttribute("id",o);}return o;}},x:{value:0},y:{value:0},width:{value:0},height:{value:0},visible:{value:true,setter:function(o){var n=o?"visible":"hidden";this.node.style.visibility=n;return o;}},fill:{valueFn:"_getDefaultFill",setter:function(p){var o,n=this.get("fill")||this._getDefaultFill();o=(p)?b.merge(n,p):null;if(o&&o.color){if(o.color===undefined||o.color=="none"){o.color=null;}}return o;}},stroke:{valueFn:"_getDefaultStroke",setter:function(p){var o=this.get("stroke")||this._getDefaultStroke(),n;if(p&&p.hasOwnProperty("weight")){n=parseInt(p.weight,10);
-if(!isNaN(n)){p.weight=n;}}return(p)?b.merge(o,p):null;}},autoSize:{value:false},pointerEvents:{valueFn:function(){var o="visiblePainted",n=this.node;if(n){n.setAttribute("pointer-events",o);}return o;},setter:function(o){var n=this.node;if(n){n.setAttribute("pointer-events",o);}return o;}},gradientNode:{setter:function(n){if(c.isString(n)){n=this._graphic.getGradientNode("linear",n);}return n;}},autoDraw:{getter:function(){return this._graphic.autoDraw;}},node:{readOnly:true,getter:function(){return this.node;}},graphic:{readOnly:true,getter:function(){return this._graphic;}}};b.SVGShape=l;k=function(n){k.superclass.constructor.apply(this,arguments);};k.NAME="svgPath";b.extend(k,b.SVGShape,{_left:0,_right:0,_top:0,_bottom:0,_type:"path",_path:""});k.ATTRS=b.merge(b.SVGShape.ATTRS,{path:{readOnly:true,getter:function(){return this._path;}},width:{getter:function(){var n=Math.max(this._right-this._left,0);return n;}},height:{getter:function(){return Math.max(this._bottom-this._top,0);}}});b.SVGPath=k;h=function(){h.superclass.constructor.apply(this,arguments);};h.NAME="svgRect";b.extend(h,b.SVGShape,{_type:"rect"});h.ATTRS=b.SVGShape.ATTRS;b.SVGRect=h;e=function(n){e.superclass.constructor.apply(this,arguments);};e.NAME="svgEllipse";b.extend(e,l,{_type:"ellipse",_draw:function(){var n=this.node,v=this.get("width"),q=this.get("height"),u=this.get("x"),s=this.get("y"),t=v*0.5,r=q*0.5,p=u+t,o=s+r;n.setAttribute("rx",t);n.setAttribute("ry",r);n.setAttribute("cx",p);n.setAttribute("cy",o);this._fillChangeHandler();this._strokeChangeHandler();this._updateTransform();}});e.ATTRS=b.merge(l.ATTRS,{xRadius:{setter:function(n){this.set("width",n/2);},getter:function(){var n=this.get("width");if(n){n*=0.5;}return n;}},yRadius:{setter:function(n){this.set("height",n/2);},getter:function(){var n=this.get("height");if(n){n*=0.5;}return n;}}});b.SVGEllipse=e;f=function(n){f.superclass.constructor.apply(this,arguments);};f.NAME="svgCircle";b.extend(f,b.SVGShape,{_type:"circle",_draw:function(){var q=this.node,p=this.get("x"),s=this.get("y"),o=this.get("radius"),n=p+o,r=s+o;q.setAttribute("r",o);q.setAttribute("cx",n);q.setAttribute("cy",r);this._fillChangeHandler();this._strokeChangeHandler();this._updateTransform();}});f.ATTRS=b.merge(b.SVGShape.ATTRS,{width:{setter:function(n){this.set("radius",n/2);return n;},getter:function(){return this.get("radius")*2;}},height:{setter:function(n){this.set("radius",n/2);return n;},getter:function(){return this.get("radius")*2;}},radius:{value:0}});b.SVGCircle=f;j=function(){j.superclass.constructor.apply(this,arguments);};j.NAME="svgPieSlice";b.extend(j,b.SVGShape,b.mix({_type:"path",_draw:function(r){var o=this.get("cx"),s=this.get("cy"),q=this.get("startAngle"),p=this.get("arc"),n=this.get("radius");this.clear();this.drawWedge(o,s,q,p,n);this.end();}},b.SVGDrawing.prototype));j.ATTRS=b.mix({cx:{value:0},cy:{value:0},startAngle:{value:0},arc:{value:0},radius:{value:0}},b.SVGShape.ATTRS);b.SVGPieSlice=j;d=function(n){d.superclass.constructor.apply(this,arguments);};d.NAME="svgGraphic";d.ATTRS={render:{},id:{valueFn:function(){return b.guid();},setter:function(o){var n=this._node;if(n){n.setAttribute("id",o);}return o;}},shapes:{readOnly:true,getter:function(){return this._shapes;}},contentBounds:{readOnly:true,getter:function(){return this._contentBounds;}},node:{readOnly:true,getter:function(){return this._node;}},width:{setter:function(n){if(this._node){this._node.style.width=n+"px";}return n;}},height:{setter:function(n){if(this._node){this._node.style.height=n+"px";}return n;}},autoSize:{value:false},resizeDown:{getter:function(){return this._resizeDown;},setter:function(n){this._resizeDown=n;this._redraw();return n;}},x:{getter:function(){return this._x;},setter:function(n){this._x=n;if(this._node){this._node.style.left=n+"px";}return n;}},y:{getter:function(){return this._y;},setter:function(n){this._y=n;if(this._node){this._node.style.top=n+"px";}return n;}},autoDraw:{value:true},visible:{value:true,setter:function(n){this._toggleVisible(n);return n;}},pointerEvents:{value:"none"}};b.extend(d,b.BaseGraphic,{_x:0,_y:0,getXY:function(){var n=b.one(this._node),o;if(n){o=n.getXY();}return o;},_resizeDown:false,initializer:function(){var n=this.get("render");this._shapes={};this._contentBounds={left:0,top:0,right:0,bottom:0};this._gradients={};this._node=m.createElement("div");this._node.style.position="absolute";this._node.style.left=this.get("x")+"px";this._node.style.top=this.get("y")+"px";this._contentNode=this._createGraphics();this._contentNode.setAttribute("id",this.get("id"));this._node.appendChild(this._contentNode);if(n){this.render(n);}},render:function(q){var n=b.one(q),o=this.get("width")||parseInt(n.getComputedStyle("width"),10),p=this.get("height")||parseInt(n.getComputedStyle("height"),10);n=n||m.body;n.appendChild(this._node);this.parentNode=n;this.set("width",o);this.set("height",p);this.parentNode=n;return this;},destroy:function(){this.removeAllShapes();this._removeChildren(this._node);if(this._node&&this._node.parentNode){this._node.parentNode.removeChild(this._node);}},addShape:function(n){n.graphic=this;var p=this._getShapeClass(n.type),o=new p(n);this._appendShape(o);return o;},_appendShape:function(o){var p=o.node,n=this._frag||this._contentNode;if(this.get("autoDraw")){n.appendChild(p);}else{this._getDocFrag().appendChild(p);}},removeShape:function(n){if(!(n instanceof l)){if(c.isString(n)){n=this._shapes[n];}}if(n&&n instanceof l){n.destroy();delete this._shapes[n.get("id")];}if(this.get("autoDraw")){this._redraw();}return n;},removeAllShapes:function(){var n=this._shapes,o;for(o in n){if(n.hasOwnProperty(o)){n[o].destroy();}}this._shapes={};},_removeChildren:function(n){if(n.hasChildNodes()){var o;while(n.firstChild){o=n.firstChild;this._removeChildren(o);n.removeChild(o);}}},clear:function(){this.removeAllShapes();},_toggleVisible:function(q){var p,o=this._shapes,n=q?"visible":"hidden";if(o){for(p in o){if(o.hasOwnProperty(p)){o[p].set("visible",q);
-}}}this._contentNode.style.visibility=n;this._node.style.visibility=n;},_getShapeClass:function(o){var n=this._shapeClass[o];if(n){return n;}return o;},_shapeClass:{circle:b.SVGCircle,rect:b.SVGRect,path:b.SVGPath,ellipse:b.SVGEllipse,pieslice:b.SVGPieSlice},getShapeById:function(o){var n=this._shapes[o];return n;},batch:function(o){var n=this.get("autoDraw");this.set("autoDraw",false);o();this._redraw();this.set("autoDraw",n);},_getDocFrag:function(){if(!this._frag){this._frag=m.createDocumentFragment();}return this._frag;},_redraw:function(){var n=this.get("resizeDown")?this._getUpdatedContentBounds():this._contentBounds;this._contentNode.style.left=n.left+"px";this._contentNode.style.top=n.top+"px";this._contentNode.setAttribute("width",n.width);this._contentNode.setAttribute("height",n.height);this._contentNode.style.width=n.width+"px";this._contentNode.style.height=n.height+"px";this._contentNode.setAttribute("viewBox",""+n.left+" "+n.top+" "+n.width+" "+n.height+"");if(this.get("autoSize")){this.set("width",n.right);this.set("height",n.bottom);}if(this._frag){this._contentNode.appendChild(this._frag);this._frag=null;}},addToRedrawQueue:function(n){var p,o;this._shapes[n.get("id")]=n;if(!this.get("resizeDown")){p=n.getBounds();o=this._contentBounds;o.left=o.left<p.left?o.left:p.left;o.top=o.top<p.top?o.top:p.top;o.right=o.right>p.right?o.right:p.right;o.bottom=o.bottom>p.bottom?o.bottom:p.bottom;o.width=o.right-o.left;o.height=o.bottom-o.top;this._contentBounds=o;}if(this.get("autoDraw")){this._redraw();}},_getUpdatedContentBounds:function(){var r,p,o,n=this._shapes,q={left:0,top:0,right:0,bottom:0};for(p in n){if(n.hasOwnProperty(p)){o=n[p];r=o.getBounds();q.left=Math.min(q.left,r.left);q.top=Math.min(q.top,r.top);q.right=Math.max(q.right,r.right);q.bottom=Math.max(q.bottom,r.bottom);}}q.width=q.right-q.left;q.height=q.bottom-q.top;this._contentBounds=q;return q;},_createGraphics:function(){var n=this._createGraphicNode("svg"),o=this.get("pointerEvents");n.style.position="absolute";n.style.top="px";n.style.left="0px";n.style.overflow="auto";n.setAttribute("overflow","auto");n.setAttribute("pointer-events",o);return n;},_createGraphicNode:function(p,n){var q=m.createElementNS("http://www.w3.org/2000/svg","svg:"+p),o=n||"none";if(p!=="defs"&&p!=="stop"&&p!=="linearGradient"&&p!="radialGradient"){q.setAttribute("pointer-events",o);}return q;},getGradientNode:function(p,q){var n=this._gradients,r,o=q+"Gradient";if(n.hasOwnProperty(p)&&n[p].tagName.indexOf(q)>-1){r=this._gradients[p];}else{r=this._createGraphicNode(o);if(!this._defs){this._defs=this._createGraphicNode("defs");this._contentNode.appendChild(this._defs);}this._defs.appendChild(r);p=p||"gradient"+Math.round(100000*Math.random());r.setAttribute("id",p);if(n.hasOwnProperty(p)){this._defs.removeChild(n[p]);}n[p]=r;}return r;}});b.SVGGraphic=d;},"@VERSION@",{requires:["graphics"],skinnable:false});
+r.linecap=r.linecap||"butt";q.setAttribute("stroke-dasharray",t);q.setAttribute("stroke",r.color);q.setAttribute("stroke-linecap",r.linecap);q.setAttribute("stroke-width",r.weight);q.setAttribute("stroke-opacity",r.opacity);if(o=="round"||o=="bevel"){q.setAttribute("stroke-linejoin",o);}else{o=parseInt(o,10);if(c.isNumber(o)){q.setAttribute("stroke-miterlimit",Math.max(o,1));q.setAttribute("stroke-linejoin","miter");}}}else{q.setAttribute("stroke","none");}},_fillChangeHandler:function(r){var p=this.node,q=this.get("fill"),n,o;if(q){o=q.type;if(o=="linear"||o=="radial"){this._setGradientFill(q);p.setAttribute("fill","url(#grad"+this.get("id")+")");}else{if(!q.color){p.setAttribute("fill","none");}else{n=parseFloat(q.opacity);n=c.isNumber(n)?n:1;p.setAttribute("fill",q.color);p.setAttribute("fill-opacity",n);}}}else{p.setAttribute("fill","none");}},_setGradientFill:function(L){var y,u,K,G,D=c.isNumber,C=this._graphic,v=L.type,J=C.getGradientNode("grad"+this.get("id"),v),z=L.stops,A=this.get("width"),P=this.get("height"),I=L.rotation,x=Math.PI/180,F=parseFloat(parseFloat(Math.tan(I*x)).toFixed(8)),M,O,B,H,Q="0%",N="100%",s="0%",o="0%",q=L.cx,n=L.cy,t=L.fx,p=L.fy,E=L.r;if(v=="linear"){q=A/2;n=P/2;if(Math.abs(F)*A/2>=P/2){if(I<180){s=0;o=P;}else{s=P;o=0;}Q=q-((n-s)/F);N=q-((n-o)/F);}else{if(I>90&&I<270){Q=A;N=0;}else{Q=0;N=A;}s=((F*(q-Q))-n)*-1;o=((F*(q-N))-n)*-1;}J.setAttribute("spreadMethod","pad");J.setAttribute("width",A);J.setAttribute("height",P);J.setAttribute("x1",Math.round(100*Q/A)+"%");J.setAttribute("y1",Math.round(100*s/P)+"%");J.setAttribute("x2",Math.round(100*N/A)+"%");J.setAttribute("y2",Math.round(100*o/P)+"%");}else{J.setAttribute("cx",(q*100)+"%");J.setAttribute("cy",(n*100)+"%");J.setAttribute("fx",(t*100)+"%");J.setAttribute("fy",(p*100)+"%");J.setAttribute("r",(E*100)+"%");}O=z.length;B=0;for(M=0;M<O;++M){H=z[M];u=H.opacity;K=H.color;y=H.offset||M/(O-1);y=Math.round(y*100)+"%";u=D(u)?u:1;u=Math.max(0,Math.min(1,u));B=(M+1)/O;G=C._createGraphicNode("stop");G.setAttribute("offset",y);G.setAttribute("stop-color",K);G.setAttribute("stop-opacity",u);J.appendChild(G);}},set:function(){var n=this;g.prototype.set.apply(n,arguments);if(n.initialized){n._updateHandler();}},translate:function(n,o){this._translateX+=n;this._translateY+=o;this._addTransform("translate",arguments);},translateX:function(n){this._translateX+=n;this._addTransform("translateX",arguments);},translateY:function(n){this._translateY+=n;this._addTransform("translateY",arguments);},skew:function(n,o){this._addTransform("skew",arguments);},skewX:function(n){this._addTransform("skewX",arguments);},skewY:function(n){this._addTransform("skewY",arguments);},_rotation:0,rotate:function(n){this._rotation=n;this._addTransform("rotate",arguments);},scale:function(n,o){this._addTransform("scale",arguments);},_addTransform:function(o,n){n=b.Array(n);this._transform=c.trim(this._transform+" "+o+"("+n.join(", ")+")");n.unshift(o);this._transforms.push(n);if(this.initialized){this._updateTransform();}},_updateTransform:function(){var u=this._type=="path",o=this.node,A,n,q,z,v,s,p,w=this.matrix,r=0,t=this._transforms.length;if(u||(this._transforms&&this._transforms.length>0)){z=this.get("x");v=this.get("y");q=this.get("transformOrigin");s=z+(q[0]*this.get("width"));p=v+(q[1]*this.get("height"));if(u){w.init({dx:z+this._left,dy:v+this._top});}w.translate(s,p);for(;r<t;++r){A=this._transforms[r].shift();if(A){w[A].apply(w,this._transforms[r]);}if(u){this._transforms[r].unshift(A);}}w.translate(-s,-p);n="matrix("+w.a+","+w.b+","+w.c+","+w.d+","+w.dx+","+w.dy+")";}this._graphic.addToRedrawQueue(this);if(n){o.setAttribute("transform",n);}if(!u){this._transforms=[];}},_draw:function(){var n=this.node;n.setAttribute("width",this.get("width"));n.setAttribute("height",this.get("height"));n.setAttribute("x",this.get("x"));n.setAttribute("y",this.get("y"));n.style.left=this.get("x")+"px";n.style.top=this.get("y")+"px";this._fillChangeHandler();this._strokeChangeHandler();this._updateTransform();},_updateHandler:function(n){this._draw();},_translateX:0,_translateY:0,_transform:"",getBounds:function(){var s=this._type,n,u={},D=this.matrix,M=D.a,L=D.b,K=D.c,I=D.d,A=D.dx,y=D.dy,z=this.get("width"),G=this.get("height"),t=s=="path"?0:this.get("x"),B=s=="path"?0:this.get("y"),J=t+z,x=B+G,v=this.get("stroke"),H=(M*t+K*B+A),r=(L*t+I*B+y),F=(M*J+K*B+A),q=(L*J+I*B+y),E=(M*t+K*x+A),p=(L*t+I*x+y),C=(M*J+K*x+A),o=(L*J+I*x+y);u.left=Math.min(E,Math.min(H,Math.min(F,C)));u.right=Math.max(E,Math.max(H,Math.max(F,C)));u.top=Math.min(q,Math.min(o,Math.min(p,r)));u.bottom=Math.max(q,Math.max(o,Math.max(p,r)));if(v&&v.weight){n=v.weight;u.left-=n;u.right+=n;u.top-=n;u.bottom+=n;}return u;},_getRotatedCornerX:function(o,s,n,r,p,q){return(n+(o-n)*p+(s-r)*q);},_getRotatedCornerY:function(o,s,n,r,p,q){return(r-(o-n)*q+(s-r)*p);},destroy:function(){if(this._graphic&&this._graphic._contentNode){this._graphic._contentNode.removeChild(this.node);}}},b.SVGDrawing.prototype));l.ATTRS={transformOrigin:{valueFn:function(){return[0.5,0.5];}},transform:{setter:function(n){this.matrix.init();this._transforms=this.matrix.getTransformArray(n);this._transform=n;if(this.initialized){this._updateTransform();}return n;},getter:function(){return this._transform;}},id:{valueFn:function(){return b.guid();},setter:function(o){var n=this.node;if(n){n.setAttribute("id",o);}return o;}},x:{value:0},y:{value:0},width:{value:0},height:{value:0},visible:{value:true,setter:function(o){var n=o?"visible":"hidden";this.node.style.visibility=n;return o;}},fill:{valueFn:"_getDefaultFill",setter:function(p){var o,n=this.get("fill")||this._getDefaultFill();o=(p)?b.merge(n,p):null;if(o&&o.color){if(o.color===undefined||o.color=="none"){o.color=null;}}return o;}},stroke:{valueFn:"_getDefaultStroke",setter:function(p){var o=this.get("stroke")||this._getDefaultStroke(),n;if(p&&p.hasOwnProperty("weight")){n=parseInt(p.weight,10);if(!isNaN(n)){p.weight=n;}}return(p)?b.merge(o,p):null;}},autoSize:{value:false},pointerEvents:{valueFn:function(){var o="visiblePainted",n=this.node;
+if(n){n.setAttribute("pointer-events",o);}return o;},setter:function(o){var n=this.node;if(n){n.setAttribute("pointer-events",o);}return o;}},gradientNode:{setter:function(n){if(c.isString(n)){n=this._graphic.getGradientNode("linear",n);}return n;}},autoDraw:{getter:function(){return this._graphic.autoDraw;}},node:{readOnly:true,getter:function(){return this.node;}},graphic:{readOnly:true,getter:function(){return this._graphic;}}};b.SVGShape=l;k=function(n){k.superclass.constructor.apply(this,arguments);};k.NAME="svgPath";b.extend(k,b.SVGShape,{_left:0,_right:0,_top:0,_bottom:0,_type:"path",_path:""});k.ATTRS=b.merge(b.SVGShape.ATTRS,{path:{readOnly:true,getter:function(){return this._path;}},width:{getter:function(){var n=Math.max(this._right-this._left,0);return n;}},height:{getter:function(){return Math.max(this._bottom-this._top,0);}}});b.SVGPath=k;h=function(){h.superclass.constructor.apply(this,arguments);};h.NAME="svgRect";b.extend(h,b.SVGShape,{_type:"rect"});h.ATTRS=b.SVGShape.ATTRS;b.SVGRect=h;e=function(n){e.superclass.constructor.apply(this,arguments);};e.NAME="svgEllipse";b.extend(e,l,{_type:"ellipse",_draw:function(){var n=this.node,v=this.get("width"),q=this.get("height"),u=this.get("x"),s=this.get("y"),t=v*0.5,r=q*0.5,p=u+t,o=s+r;n.setAttribute("rx",t);n.setAttribute("ry",r);n.setAttribute("cx",p);n.setAttribute("cy",o);this._fillChangeHandler();this._strokeChangeHandler();this._updateTransform();}});e.ATTRS=b.merge(l.ATTRS,{xRadius:{setter:function(n){this.set("width",n/2);},getter:function(){var n=this.get("width");if(n){n*=0.5;}return n;}},yRadius:{setter:function(n){this.set("height",n/2);},getter:function(){var n=this.get("height");if(n){n*=0.5;}return n;}}});b.SVGEllipse=e;f=function(n){f.superclass.constructor.apply(this,arguments);};f.NAME="svgCircle";b.extend(f,b.SVGShape,{_type:"circle",_draw:function(){var q=this.node,p=this.get("x"),s=this.get("y"),o=this.get("radius"),n=p+o,r=s+o;q.setAttribute("r",o);q.setAttribute("cx",n);q.setAttribute("cy",r);this._fillChangeHandler();this._strokeChangeHandler();this._updateTransform();}});f.ATTRS=b.merge(b.SVGShape.ATTRS,{width:{setter:function(n){this.set("radius",n/2);return n;},getter:function(){return this.get("radius")*2;}},height:{setter:function(n){this.set("radius",n/2);return n;},getter:function(){return this.get("radius")*2;}},radius:{value:0}});b.SVGCircle=f;j=function(){j.superclass.constructor.apply(this,arguments);};j.NAME="svgPieSlice";b.extend(j,b.SVGShape,b.mix({_type:"path",_draw:function(r){var o=this.get("cx"),s=this.get("cy"),q=this.get("startAngle"),p=this.get("arc"),n=this.get("radius");this.clear();this.drawWedge(o,s,q,p,n);this.end();}},b.SVGDrawing.prototype));j.ATTRS=b.mix({cx:{value:0},cy:{value:0},startAngle:{value:0},arc:{value:0},radius:{value:0}},b.SVGShape.ATTRS);b.SVGPieSlice=j;d=function(n){d.superclass.constructor.apply(this,arguments);};d.NAME="svgGraphic";d.ATTRS={render:{},id:{valueFn:function(){return b.guid();},setter:function(o){var n=this._node;if(n){n.setAttribute("id",o);}return o;}},shapes:{readOnly:true,getter:function(){return this._shapes;}},contentBounds:{readOnly:true,getter:function(){return this._contentBounds;}},node:{readOnly:true,getter:function(){return this._node;}},width:{setter:function(n){if(this._node){this._node.style.width=n+"px";}return n;}},height:{setter:function(n){if(this._node){this._node.style.height=n+"px";}return n;}},autoSize:{value:false},resizeDown:{getter:function(){return this._resizeDown;},setter:function(n){this._resizeDown=n;this._redraw();return n;}},x:{getter:function(){return this._x;},setter:function(n){this._x=n;if(this._node){this._node.style.left=n+"px";}return n;}},y:{getter:function(){return this._y;},setter:function(n){this._y=n;if(this._node){this._node.style.top=n+"px";}return n;}},autoDraw:{value:true},visible:{value:true,setter:function(n){this._toggleVisible(n);return n;}},pointerEvents:{value:"none"}};b.extend(d,b.BaseGraphic,{_x:0,_y:0,getXY:function(){var n=b.one(this._node),o;if(n){o=n.getXY();}return o;},_resizeDown:false,initializer:function(){var n=this.get("render");this._shapes={};this._contentBounds={left:0,top:0,right:0,bottom:0};this._gradients={};this._node=m.createElement("div");this._node.style.position="absolute";this._node.style.left=this.get("x")+"px";this._node.style.top=this.get("y")+"px";this._contentNode=this._createGraphics();this._contentNode.setAttribute("id",this.get("id"));this._node.appendChild(this._contentNode);if(n){this.render(n);}},render:function(q){var n=b.one(q),o=this.get("width")||parseInt(n.getComputedStyle("width"),10),p=this.get("height")||parseInt(n.getComputedStyle("height"),10);n=n||m.body;n.appendChild(this._node);this.parentNode=n;this.set("width",o);this.set("height",p);this.parentNode=n;return this;},destroy:function(){this.removeAllShapes();this._removeChildren(this._node);if(this._node&&this._node.parentNode){this._node.parentNode.removeChild(this._node);}},addShape:function(n){n.graphic=this;var p=this._getShapeClass(n.type),o=new p(n);this._appendShape(o);return o;},_appendShape:function(o){var p=o.node,n=this._frag||this._contentNode;if(this.get("autoDraw")){n.appendChild(p);}else{this._getDocFrag().appendChild(p);}},removeShape:function(n){if(!(n instanceof l)){if(c.isString(n)){n=this._shapes[n];}}if(n&&n instanceof l){n.destroy();delete this._shapes[n.get("id")];}if(this.get("autoDraw")){this._redraw();}return n;},removeAllShapes:function(){var n=this._shapes,o;for(o in n){if(n.hasOwnProperty(o)){n[o].destroy();}}this._shapes={};},_removeChildren:function(n){if(n.hasChildNodes()){var o;while(n.firstChild){o=n.firstChild;this._removeChildren(o);n.removeChild(o);}}},clear:function(){this.removeAllShapes();},_toggleVisible:function(q){var p,o=this._shapes,n=q?"visible":"hidden";if(o){for(p in o){if(o.hasOwnProperty(p)){o[p].set("visible",q);}}}this._contentNode.style.visibility=n;this._node.style.visibility=n;},_getShapeClass:function(o){var n=this._shapeClass[o];if(n){return n;
+}return o;},_shapeClass:{circle:b.SVGCircle,rect:b.SVGRect,path:b.SVGPath,ellipse:b.SVGEllipse,pieslice:b.SVGPieSlice},getShapeById:function(o){var n=this._shapes[o];return n;},batch:function(o){var n=this.get("autoDraw");this.set("autoDraw",false);o();this._redraw();this.set("autoDraw",n);},_getDocFrag:function(){if(!this._frag){this._frag=m.createDocumentFragment();}return this._frag;},_redraw:function(){var n=this.get("resizeDown")?this._getUpdatedContentBounds():this._contentBounds;this._contentNode.style.left=n.left+"px";this._contentNode.style.top=n.top+"px";this._contentNode.setAttribute("width",n.width);this._contentNode.setAttribute("height",n.height);this._contentNode.style.width=n.width+"px";this._contentNode.style.height=n.height+"px";this._contentNode.setAttribute("viewBox",""+n.left+" "+n.top+" "+n.width+" "+n.height+"");if(this.get("autoSize")){this.set("width",n.right);this.set("height",n.bottom);}if(this._frag){this._contentNode.appendChild(this._frag);this._frag=null;}},addToRedrawQueue:function(n){var p,o;this._shapes[n.get("id")]=n;if(!this.get("resizeDown")){p=n.getBounds();o=this._contentBounds;o.left=o.left<p.left?o.left:p.left;o.top=o.top<p.top?o.top:p.top;o.right=o.right>p.right?o.right:p.right;o.bottom=o.bottom>p.bottom?o.bottom:p.bottom;o.width=o.right-o.left;o.height=o.bottom-o.top;this._contentBounds=o;}if(this.get("autoDraw")){this._redraw();}},_getUpdatedContentBounds:function(){var r,p,o,n=this._shapes,q={left:0,top:0,right:0,bottom:0};for(p in n){if(n.hasOwnProperty(p)){o=n[p];r=o.getBounds();q.left=Math.min(q.left,r.left);q.top=Math.min(q.top,r.top);q.right=Math.max(q.right,r.right);q.bottom=Math.max(q.bottom,r.bottom);}}q.width=q.right-q.left;q.height=q.bottom-q.top;this._contentBounds=q;return q;},_createGraphics:function(){var n=this._createGraphicNode("svg"),o=this.get("pointerEvents");n.style.position="absolute";n.style.top="px";n.style.left="0px";n.style.overflow="auto";n.setAttribute("overflow","auto");n.setAttribute("pointer-events",o);return n;},_createGraphicNode:function(p,n){var q=m.createElementNS("http://www.w3.org/2000/svg","svg:"+p),o=n||"none";if(p!=="defs"&&p!=="stop"&&p!=="linearGradient"&&p!="radialGradient"){q.setAttribute("pointer-events",o);}return q;},getGradientNode:function(p,q){var n=this._gradients,r,o=q+"Gradient";if(n.hasOwnProperty(p)&&n[p].tagName.indexOf(q)>-1){r=this._gradients[p];}else{r=this._createGraphicNode(o);if(!this._defs){this._defs=this._createGraphicNode("defs");this._contentNode.appendChild(this._defs);}this._defs.appendChild(r);p=p||"gradient"+Math.round(100000*Math.random());r.setAttribute("id",p);if(n.hasOwnProperty(p)){this._defs.removeChild(n[p]);}n[p]=r;}return r;}});b.SVGGraphic=d;},"@VERSION@",{requires:["graphics"],skinnable:false});
View
29 build/graphics-svg/graphics-svg.js
@@ -1032,39 +1032,27 @@ Y.extend(SVGShape, Y.BaseGraphic, Y.mix({
{
x = this.get("x");
y = this.get("y");
-
+ transformOrigin = this.get("transformOrigin");
+ tx = x + (transformOrigin[0] * this.get("width"));
+ ty = y + (transformOrigin[1] * this.get("height"));
if(isPath)
{
- x += this._left;
- y += this._top;
- matrix.init({dx: x, dy: y});
- x = 0;
- y = 0;
+ matrix.init({dx: x + this._left, dy: y + this._top});
}
+ matrix.translate(tx, ty);
for(; i < len; ++i)
{
key = this._transforms[i].shift();
if(key)
{
- if(key == "rotate" || key == "scale")
- {
- transformOrigin = this.get("transformOrigin");
- tx = x + (transformOrigin[0] * this.get("width"));
- ty = y + (transformOrigin[1] * this.get("height"));
- matrix.translate(tx, ty);
- matrix[key].apply(matrix, this._transforms[i]);
- matrix.translate(0 - tx, 0 - ty);
- }
- else
- {
- matrix[key].apply(matrix, this._transforms[i]);
- }
+ matrix[key].apply(matrix, this._transforms[i]);
}
if(isPath)
{
this._transforms[i].unshift(key);
}
}
+ matrix.translate(-tx, -ty);
transform = "matrix(" + matrix.a + "," +
matrix.b + "," +
matrix.c + "," +
@@ -1276,6 +1264,7 @@ SVGShape.ATTRS = {
* <dt>translateY</dt><dd>Translates the shape along the y-axis.</dd>
* <dt>skewX</dt><dd>Skews the shape around the x-axis.</dd>
* <dt>skewY</dt><dd>Skews the shape around the y-axis.</dd>
+ * <dt>matrix</dt><dd>Specifies a 2D transformation matrix comprised of the specified six values.</dd>
* </dl>
* </p>
* <p>Applying transforms through the transform attribute will reset the transform matrix and apply a new transform. The shape class also contains corresponding methods for each transform
@@ -1294,7 +1283,7 @@ SVGShape.ATTRS = {
*/
transform: {
setter: function(val)
- {
+ {
this.matrix.init();
this._transforms = this.matrix.getTransformArray(val);
this._transform = val;
View
92 build/graphics-vml/graphics-vml-debug.js
@@ -998,19 +998,8 @@ Y.extend(VMLShape, Y.BaseGraphic, Y.mix({
y = this.get("y"),
w = this.get("width"),
h = this.get("height"),
- cx,
- cy,
- dx,
- dy,
- originX,
- originY,
- translatedCenterX,
- translatedCenterY,
- oldBounds,
- newBounds,
tx,
ty,
- keys = [],
matrix = this.matrix,
rotationMatrix = this.rotationMatrix,
i = 0,
@@ -1019,70 +1008,48 @@ Y.extend(VMLShape, Y.BaseGraphic, Y.mix({
if(this._transforms && this._transforms.length > 0)
{
transformOrigin = this.get("transformOrigin");
+
+ //vml skew matrix transformOrigin ranges from -0.5 to 0.5.
+ //subtract 0.5 from values
+ tx = transformOrigin[0] - 0.5;
+ ty = transformOrigin[1] - 0.5;
+
+ //ensure the values are within the appropriate range to avoid errors
+ tx = Math.max(-0.5, Math.min(0.5, tx));
+ ty = Math.max(-0.5, Math.min(0.5, ty));
+
for(; i < len; ++i)
{
key = this._transforms[i].shift();
if(key)
{
- if(key == "rotate")
- {
- tx = transformOrigin[0];
- ty = transformOrigin[1];
- oldBounds = this.getBounds(matrix);
- matrix[key].apply(matrix, this._transforms[i]);
- rotationMatrix[key].apply(rotationMatrix, this._transforms[i]);
- newBounds = this.getBounds(matrix);
- cx = w * 0.5;
- cy = h * 0.5;
- originX = w * (tx);
- originY = h * (ty);
- translatedCenterX = cx - originX;
- translatedCenterY = cy - originY;
- translatedCenterX = (matrix.a * translatedCenterX + matrix.b * translatedCenterY);
- translatedCenterY = (matrix.d * translatedCenterX + matrix.d * translatedCenterY);
- translatedCenterX += originX;
- translatedCenterY += originY;
- matrix.dx = rotationMatrix.dx + translatedCenterX - (newBounds.right - newBounds.left)/2;
- matrix.dy = rotationMatrix.dy + translatedCenterY - (newBounds.bottom - newBounds.top)/2;
- }
- else if(key == "scale")
- {
- transformOrigin = this.get("transformOrigin");
- tx = x + (transformOrigin[0] * this.get("width"));
- ty = y + (transformOrigin[1] * this.get("height"));
- matrix.translate(tx, ty);
- matrix[key].apply(matrix, this._transforms[i]);
- matrix.translate(0 - tx, 0 - ty);
- }
- else
- {
- matrix[key].apply(matrix, this._transforms[i]);
- rotationMatrix[key].apply(rotationMatrix, this._transforms[i]);
- }
- keys.push(key);
+ matrix[key].apply(matrix, this._transforms[i]);
}
}
- transform = matrix.toFilterText();
+ transform = matrix.a + "," +
+ matrix.c + "," +
+ matrix.b + "," +
+ matrix.d + "," +
+ 0 + "," +
+ 0;
}
- dx = matrix.dx;
- dy = matrix.dy;
this._graphic.addToRedrawQueue(this);
- //only apply the filter if necessary as it degrades image quality
- if(Y.Array.indexOf(keys, "skew") > -1 || Y.Array.indexOf(keys, "scale") > -1)
- {
- node.style.filter = transform;
- }
- else if(Y.Array.indexOf(keys,"rotate") > -1)
+ if(transform)
{
- node.style.rotation = this._rotation;
- dx = rotationMatrix.dx;
- dy = rotationMatrix.dy;
+ if(!this._skew)
+ {
+ this._skew = DOCUMENT.createElement( '<skew class="vmlskew" xmlns="urn:schemas-microsft.com:vml" on="false" style="behavior:url(#default#VML);display:inline-block;" />');
+ this.node.appendChild(this._skew);
+ }
+ this._skew.matrix = transform;
+ this._skew.on = true;
+ //use offset for translate
+ this._skew.offset = matrix.dx + "px, " + matrix.dy + "px";
+ this._skew.origin = tx + ", " + ty;
}
this._transforms = [];
- x += dx;
- y += dy;
node.style.left = x + "px";
- node.style.top = y + "px";
+ node.style.top = y + "px";
},
/**
@@ -1445,6 +1412,7 @@ VMLShape.ATTRS = {
* <dt>translateY</dt><dd>Translates the shape along the y-axis.</dd>
* <dt>skewX</dt><dd>Skews the shape around the x-axis.</dd>
* <dt>skewY</dt><dd>Skews the shape around the y-axis.</dd>
+ * <dt>matrix</dt><dd>Specifies a 2D transformation matrix comprised of the specified six values.</dd>
* </dl>
* </p>
* <p>Applying transforms through the transform attribute will reset the transform matrix and apply a new transform. The shape class also contains corresponding methods for each transform
View
6 build/graphics-vml/graphics-vml-min.js
@@ -1,4 +1,4 @@
YUI.add("graphics-vml",function(b){var d=b.Lang,j=d.isNumber,f=d.isArray,h=b.DOM,c=b.Selector,m=b.config.doc,e=b.AttributeLite,p,l,o,k,n,i,a;function g(){}g.prototype={_currentX:0,_currentY:0,curveTo:function(t,s,A,z,w,v){var u,q,r,B;w=Math.round(w);v=Math.round(v);this._path+=" c "+Math.round(t)+", "+Math.round(s)+", "+Math.round(A)+", "+Math.round(z)+", "+w+", "+v;this._currentX=w;this._currentY=v;u=Math.max(w,Math.max(t,A));r=Math.max(v,Math.max(s,z));q=Math.min(w,Math.min(t,A));B=Math.min(v,Math.min(s,z));this._trackSize(u,r);this._trackSize(q,B);},quadraticCurveTo:function(v,u,z,w){var r=this._currentX,q=this._currentY,t=r+0.67*(v-r),s=q+0.67*(u-q),B=t+(z-r)*0.34,A=s+(w-q)*0.34;this.curveTo(t,s,B,A,z,w);},drawRect:function(q,t,r,s){this.moveTo(q,t);this.lineTo(q+r,t);this.lineTo(q+r,t+s);this.lineTo(q,t+s);this.lineTo(q,t);this._currentX=q;this._currentY=t;return this;},drawRoundRect:function(q,v,r,t,s,u){this.moveTo(q,v+u);this.lineTo(q,v+t-u);this.quadraticCurveTo(q,v+t,q+s,v+t);this.lineTo(q+r-s,v+t);this.quadraticCurveTo(q+r,v+t,q+r,v+t-u);this.lineTo(q+r,v+u);this.quadraticCurveTo(q+r,v,q+r-s,v);this.lineTo(q+s,v);this.quadraticCurveTo(q,v,q,v+u);return this;},drawWedge:function(s,w,u,t,r,q){var v=r*2;q=q||r;if(Math.abs(t)>360){t=360;}u*=-65535;t*=65536;this._path+=" m "+s+" "+w+" ae "+s+" "+w+" "+r+" "+q+" "+u+" "+t;this._trackSize(v,v);this._currentX=s;this._currentY=w;return this;},lineTo:function(v,u,s){var r=arguments,t,q;if(typeof v==="string"||typeof v==="number"){r=[[v,u]];}q=r.length;if(!this._path){this._path="";}this._path+=" l ";for(t=0;t<q;++t){this._path+=" "+Math.round(r[t][0])+", "+Math.round(r[t][1]);this._trackSize.apply(this,r[t]);this._currentX=r[t][0];this._currentY=r[t][1];}return this;},moveTo:function(q,r){if(!this._path){this._path="";}this._path+=" m "+Math.round(q)+", "+Math.round(r);this._trackSize(q,r);this._currentX=q;this._currentY=r;},_closePath:function(){var x=this.get("fill"),v=this.get("stroke"),s=this.node,q=this.get("width"),r=this.get("height"),u=this._path,t="";s.style.visible="hidden";this._fillChangeHandler();this._strokeChangeHandler();if(u){if(x&&x.color){t+=" x";}if(v){t+=" e";}}if(u){s.path=u+t;}if(q&&r){s.coordSize=q+", "+r;s.style.position="absolute";s.style.width=q+"px";s.style.height=r+"px";}this._path=u;s.style.visible="visible";this._updateTransform();},end:function(){this._closePath();},clear:function(){this._path="";},_trackSize:function(q,r){if(q>this._right){this._right=q;}if(q<this._left){this._left=q;}if(r<this._top){this._top=r;}if(r>this._bottom){this._bottom=r;}this._width=this._right-this._left;this._height=this._bottom-this._top;},_left:0,_right:0,_top:0,_bottom:0,_width:0,_height:0};b.VMLDrawing=g;p=function(){this._transforms=[];this.matrix=new b.Matrix();this.rotationMatrix=new b.Matrix();p.superclass.constructor.apply(this,arguments);};p.NAME="vmlShape";b.extend(p,b.BaseGraphic,b.mix({_type:"shape",init:function(){this.initializer.apply(this,arguments);},initializer:function(q){var r=this,s=q.graphic;r._graphic=s;r.createNode();this._updateHandler();},createNode:function(){var F,B=this.get("x"),z=this.get("y"),C=this.get("width"),H=this.get("height"),E,t,K,J,v,u,D,r,A,I,q,G,s;E=this.get("id");t=this._type;v="vml"+t+" yui3-vmlShape yui3-"+this.constructor.NAME;u=this._getStrokeProps();G=this._getFillProps();K="<"+t+' xmlns="urn:schemas-microsft.com:vml" id="'+E+'" class="'+v+'" style="behavior:url(#default#VML);display:inline-block;position:absolute;left:'+B+"px;top:"+z+"px;width:"+C+"px;height:"+H+'px;"';if(u&&u.weight&&u.weight>0){D=u.endcap;r=parseFloat(u.opacity);A=u.joinstyle;I=u.miterlimit;q=u.dashstyle;K+=' stroked="t" strokecolor="'+u.color+'" strokeWeight="'+u.weight+'px"';J='<stroke class="vmlstroke" xmlns="urn:schemas-microsft.com:vml" on="t" style="behavior:url(#default#VML);display:inline-block;"';J+=' opacity="'+r+'"';if(D){J+=' endcap="'+D+'"';}if(A){J+=' joinstyle="'+A+'"';}if(I){J+=' miterlimit="'+I+'"';}if(q){J+=' dashstyle="'+q+'"';}J+="></stroke>";this._strokeNode=m.createElement(J);K+=' stroked="t"';}else{K+=' stroked="f"';}if(G){if(G.node){s=G.node;this._fillNode=m.createElement(s);}if(G.color){K+=' fillcolor="'+G.color+'"';}K+=' filled="'+G.filled+'"';}K+=">";K+="</"+t+">";F=m.createElement(K);if(this._strokeNode){F.appendChild(this._strokeNode);}if(this._fillNode){F.appendChild(this._fillNode);}this.node=F;this._strokeFlag=false;this._fillFlag=false;},addClass:function(q){var r=this.node;h.addClass(r,q);},removeClass:function(q){var r=this.node;h.removeClass(r,q);},getXY:function(){var t=this._graphic,r=t.getXY(),q=this.get("x"),s=this.get("y");return[r[0]+q,r[1]+s];},setXY:function(r){var s=this._graphic,q=s.getXY();this.set("x",r[0]-q[0]);this.set("y",r[1]-q[1]);},contains:function(q){return q===b.one(this.node);},compareTo:function(q){var r=this.node;return r===q;},test:function(q){return c.test(this.node,q);},_getStrokeProps:function(){var x,z=this.get("stroke"),v,r,t="",q,s=0,u,y,w;if(z&&z.weight&&z.weight>0){x={};y=z.linecap||"flat";w=z.linejoin||"round";if(y!="round"&&y!="square"){y="flat";}v=parseFloat(z.opacity);r=z.dashstyle||"none";z.color=z.color||"#000000";z.weight=z.weight||1;z.opacity=j(v)?v:1;x.stroked=true;x.color=z.color;x.weight=z.weight;x.endcap=y;x.opacity=z.opacity;if(f(r)){t=[];u=r.length;for(s=0;s<u;++s){q=r[s];t[s]=q/z.weight;}}if(w=="round"||w=="bevel"){x.joinstyle=w;}else{w=parseInt(w,10);if(j(w)){x.miterlimit=Math.max(w,1);x.joinstyle="miter";}}x.dashstyle=t;}return x;},_strokeChangeHandler:function(w){if(!this._strokeFlag){return;}var s=this.node,A=this.get("stroke"),x,r,u="",q,t=0,v,z,y;if(A&&A.weight&&A.weight>0){z=A.linecap||"flat";y=A.linejoin||"round";if(z!="round"&&z!="square"){z="flat";}x=parseFloat(A.opacity);r=A.dashstyle||"none";A.color=A.color||"#000000";A.weight=A.weight||1;A.opacity=j(x)?x:1;s.stroked=true;s.strokeColor=A.color;s.strokeWeight=A.weight+"px";if(!this._strokeNode){this._strokeNode=this._createGraphicNode("stroke");s.appendChild(this._strokeNode);
-}this._strokeNode.endcap=z;this._strokeNode.opacity=A.opacity;if(f(r)){u=[];v=r.length;for(t=0;t<v;++t){q=r[t];u[t]=q/A.weight;}}if(y=="round"||y=="bevel"){this._strokeNode.joinstyle=y;}else{y=parseInt(y,10);if(j(y)){this._strokeNode.miterlimit=Math.max(y,1);this._strokeNode.joinstyle="miter";}}this._strokeNode.dashstyle=u;this._strokeNode.on=true;}else{if(this._strokeNode){this._strokeNode.on=false;}s.stroked=false;}this._strokeFlag=false;},_getFillProps:function(){var w=this.get("fill"),q,t,v,r,s,u=false;if(w){t={};if(w.type=="radial"||w.type=="linear"){q=parseFloat(w.opacity);q=j(q)?q:1;u=true;v=this._getGradientFill(w);s='<fill xmlns="urn:schemas-microsft.com:vml" class="vmlfill" style="behavior:url(#default#VML);display:inline-block;" opacity="'+q+'"';for(r in v){if(v.hasOwnProperty(r)){s+=" "+r+'="'+v[r]+'"';}}s+=" />";t.node=s;}else{if(w.color){q=parseFloat(w.opacity);u=true;t.color=w.color;if(j(q)){q=Math.max(Math.min(q,1),0);t.opacity=q;if(q<1){t.node='<fill xmlns="urn:schemas-microsft.com:vml" class="vmlfill" style="behavior:url(#default#VML);display:inline-block;" type="solid" opacity="'+q+'"/>';}}}}t.filled=u;}return t;},_fillChangeHandler:function(x){if(!this._fillFlag){return;}var t=this.node,w=this.get("fill"),q,s,u=false,r,v;if(w){if(w.type=="radial"||w.type=="linear"){u=true;v=this._getGradientFill(w);if(this._fillNode){for(r in v){if(v.hasOwnProperty(r)){this._fillNode.setAttribute(r,v[r]);}}}else{s='<fill xmlns="urn:schemas-microsft.com:vml" class="vmlfill" style="behavior:url(#default#VML);display:inline-block;"';for(r in v){if(v.hasOwnProperty(r)){s+=" "+r+'="'+v[r]+'"';}}s+=" />";this._fillNode=m.createElement(s);t.appendChild(this._fillNode);}}else{if(w.color){t.fillcolor=w.color;q=parseFloat(w.opacity);u=true;if(j(q)&&q<1){w.opacity=q;if(this._fillNode){if(this._fillNode.getAttribute("type")!="solid"){this._fillNode.type="solid";}this._fillNode.opacity=q;}else{s='<fill xmlns="urn:schemas-microsft.com:vml" class="vmlfill" style="behavior:url(#default#VML);display:inline-block;" type="solid" opacity="'+q+'"/>';this._fillNode=m.createElement(s);t.appendChild(this._fillNode);}}else{if(this._fillNode){this._fillNode.opacity=1;this._fillNode.type="solid";}}}}}t.filled=u;this._fillFlag=false;},_updateFillNode:function(q){if(!this._fillNode){this._fillNode=this._createGraphicNode("fill");q.appendChild(this._fillNode);}},_getGradientFill:function(K){var O={},C,A,z=K.type,D=this.get("width"),N=this.get("height"),E=j,I,B=K.stops,M=B.length,x,J,L=0,F,q="",u=K.cx,s=K.cy,v=K.fx,t=K.fy,G=K.r,y,H=K.rotation||0;if(z==="linear"){if(H<=270){H=Math.abs(H-270);}else{if(H<360){H=270+(360-H);}else{H=270;}}O.type="gradient";O.angle=H;}else{if(z==="radial"){C=D*(G*2);A=N*(G*2);v=G*2*(v-0.5);t=G*2*(t-0.5);v+=u;t+=s;O.focussize=(C/D)/10+"% "+(A/N)/10+"%";O.alignshape=false;O.type="gradientradial";O.focus="100%";O.focusposition=Math.round(v*100)+"% "+Math.round(t*100)+"%";}}for(;L<M;++L){I=B[L];J=I.color;x=I.opacity;x=E(x)?x:1;y=I.offset||L/(M-1);y*=(G*2);if(y<=1){y=Math.round(100*y)+"%";F=L>0?L+1:"";O["opacity"+F]=x+"";q+=", "+y+" "+J;}}y=B[1].offset||0;y*=100;if(parseInt(y,10)<100){q+=", 100% "+J;}O.colors=q.substr(2);return O;},_addTransform:function(r,q){q=b.Array(q);this._transform=d.trim(this._transform+" "+r+"("+q.join(", ")+")");q.unshift(r);this._transforms.push(q);if(this.initialized){this._updateTransform();}},_updateTransform:function(){var J=this.node,Q,E,F,z=this.get("x"),v=this.get("y"),B=this.get("width"),N=this.get("height"),t,r,D,A,I,H,q,R,s,u,P,O,G=[],K=this.matrix,C=this.rotationMatrix,L=0,M=this._transforms.length;if(this._transforms&&this._transforms.length>0){F=this.get("transformOrigin");for(;L<M;++L){Q=this._transforms[L].shift();if(Q){if(Q=="rotate"){P=F[0];O=F[1];s=this.getBounds(K);K[Q].apply(K,this._transforms[L]);C[Q].apply(C,this._transforms[L]);u=this.getBounds(K);t=B*0.5;r=N*0.5;I=B*(P);H=N*(O);q=t-I;R=r-H;q=(K.a*q+K.b*R);R=(K.d*q+K.d*R);q+=I;R+=H;K.dx=C.dx+q-(u.right-u.left)/2;K.dy=C.dy+R-(u.bottom-u.top)/2;}else{if(Q=="scale"){F=this.get("transformOrigin");P=z+(F[0]*this.get("width"));O=v+(F[1]*this.get("height"));K.translate(P,O);K[Q].apply(K,this._transforms[L]);K.translate(0-P,0-O);}else{K[Q].apply(K,this._transforms[L]);C[Q].apply(C,this._transforms[L]);}}G.push(Q);}}E=K.toFilterText();}D=K.dx;A=K.dy;this._graphic.addToRedrawQueue(this);if(b.Array.indexOf(G,"skew")>-1||b.Array.indexOf(G,"scale")>-1){J.style.filter=E;}else{if(b.Array.indexOf(G,"rotate")>-1){J.style.rotation=this._rotation;D=C.dx;A=C.dy;}}this._transforms=[];z+=D;v+=A;J.style.left=z+"px";J.style.top=v+"px";},_translateX:0,_translateY:0,_transform:"",translate:function(q,r){this._translateX+=q;this._translateY+=r;this._addTransform("translate",arguments);},translateX:function(q){this._translateX+=q;this._addTransform("translateX",arguments);},translateY:function(q){this._translateY+=q;this._addTransform("translateY",arguments);},skew:function(q,r){this._addTransform("skew",arguments);},skewX:function(q){this._addTransform("skewX",arguments);},skewY:function(q){this._addTransform("skewY",arguments);},_rotation:0,rotate:function(q){this._rotation+=q;this._addTransform("rotate",arguments);},scale:function(q,r){this._addTransform("scale",arguments);},on:function(r,q){if(b.Node.DOM_EVENTS[r]){return b.one("#"+this.get("id")).on(r,q);}return b.on.apply(this,arguments);},_draw:function(){},_updateHandler:function(s){var r=this,q=r.node;r._fillChangeHandler();r._strokeChangeHandler();q.style.width=this.get("width")+"px";q.style.height=this.get("height")+"px";this._draw();r._updateTransform();},_createGraphicNode:function(q){q=q||this._type;return m.createElement("<"+q+' xmlns="urn:schemas-microsft.com:vml" style="behavior:url(#default#VML);display:inline-block;" class="vml'+q+'"/>');},_getDefaultFill:function(){return{type:"solid",cx:0.5,cy:0.5,fx:0.5,fy:0.5,r:0.5};},_getDefaultStroke:function(){return{weight:1,dashstyle:"none",color:"#000",opacity:1};},set:function(){var q=this;e.prototype.set.apply(q,arguments);
-if(q.initialized){q._updateHandler();}},getBounds:function(x){var q,y={},G=x||this.matrix,P=G.a,O=G.b,N=G.c,L=G.d,D=G.dx,B=G.dy,C=this.get("width"),J=this.get("height"),v=this.get("x"),E=this.get("y"),M=v+C,A=E+J,z=this.get("stroke"),K=(P*v+N*E+D),u=(O*v+L*E+B),I=(P*M+N*E+D),t=(O*M+L*E+B),H=(P*v+N*A+D),s=(O*v+L*A+B),F=(P*M+N*A+D),r=(O*M+L*A+B);y.left=Math.min(H,Math.min(K,Math.min(I,F)));y.right=Math.max(H,Math.max(K,Math.max(I,F)));y.top=Math.min(t,Math.min(r,Math.min(s,u)));y.bottom=Math.max(t,Math.max(r,Math.max(s,u)));if(z&&z.weight){q=z.weight;y.left-=q;y.right+=q;y.top-=q;y.bottom+=q;}y.width=y.right-y.left;y.height=y.bottom-y.top;return y;},destroy:function(){var q=this._graphic&&this._graphic._node?this._graphic._node:null,r=this.node;if(this.node){if(this._fillNode){r.removeChild(this._fillNode);}if(this._strokeNode){r.removeChild(this._strokeNode);}if(q){q.removeChild(r);}}}},b.VMLDrawing.prototype));p.ATTRS={transformOrigin:{valueFn:function(){return[0.5,0.5];}},transform:{setter:function(t){var s=0,q,r;this._rotation=0;this.matrix.init();this._transforms=this.matrix.getTransformArray(t);q=this._transforms.length;for(;s<q;++s){r=this._transforms[s];if(r[0]=="rotate"){this._rotation+=r[1];}}this._transform=t;if(this.initialized){this._updateTransform();}return t;},getter:function(){return this._transform;}},x:{value:0},y:{value:0},id:{valueFn:function(){return b.guid();},setter:function(r){var q=this.node;if(q){q.setAttribute("id",r);}return r;}},width:{value:0},height:{value:0},visible:{value:true,setter:function(s){var r=this.node,q=s?"visible":"hidden";if(r){r.style.visibility=q;}return s;}},fill:{valueFn:"_getDefaultFill",setter:function(t){var r,s,q=this.get("fill")||this._getDefaultFill();if(t){if(t.hasOwnProperty("color")){t.type="solid";}for(r in t){if(t.hasOwnProperty(r)){q[r]=t[r];}}}s=q;if(s&&s.color){if(s.color===undefined||s.color=="none"){s.color=null;}}this._fillFlag=true;return s;}},stroke:{valueFn:"_getDefaultStroke",setter:function(u){var s,t,q,r=this.get("stroke")||this._getDefaultStroke();if(u){if(u.hasOwnProperty("weight")){q=parseInt(u.weight,10);if(!isNaN(q)){u.weight=q;}}for(s in u){if(u.hasOwnProperty(s)){r[s]=u[s];}}}t=r;this._strokeFlag=true;return t;}},autoSize:{value:false},pointerEvents:{value:"visiblePainted"},node:{readOnly:true,getter:function(){return this.node;}},graphic:{readOnly:true,getter:function(){return this._graphic;}}};b.VMLShape=p;o=function(){o.superclass.constructor.apply(this,arguments);};o.NAME="vmlPath";b.extend(o,b.VMLShape,{_updateHandler:function(){var q=this;q._fillChangeHandler();q._strokeChangeHandler();q._updateTransform();}});o.ATTRS=b.merge(b.VMLShape.ATTRS,{width:{getter:function(){return this._width;},setter:function(q){this._width=q;return q;}},height:{getter:function(){return this._height;},setter:function(q){this._height=q;return q;}},path:{readOnly:true,getter:function(){return this._path;}}});b.VMLPath=o;k=function(){k.superclass.constructor.apply(this,arguments);};k.NAME="vmlRect";b.extend(k,b.VMLShape,{_type:"rect"});k.ATTRS=b.VMLShape.ATTRS;b.VMLRect=k;n=function(){n.superclass.constructor.apply(this,arguments);};n.NAME="vmlEllipse";b.extend(n,b.VMLShape,{_type:"oval"});n.ATTRS=b.merge(b.VMLShape.ATTRS,{xRadius:{lazyAdd:false,getter:function(){var q=this.get("width");q=Math.round((q/2)*100)/100;return q;},setter:function(r){var q=r*2;this.set("width",q);return r;}},yRadius:{lazyAdd:false,getter:function(){var q=this.get("height");q=Math.round((q/2)*100)/100;return q;},setter:function(r){var q=r*2;this.set("height",q);return r;}}});b.VMLEllipse=n;l=function(q){l.superclass.constructor.apply(this,arguments);};l.NAME="vmlCircle";b.extend(l,p,{_type:"oval"});l.ATTRS=b.merge(p.ATTRS,{radius:{lazyAdd:false,value:0},width:{setter:function(q){this.set("radius",q/2);return q;},getter:function(){var q=this.get("radius"),r=q&&q>0?q*2:0;return r;}},height:{setter:function(q){this.set("radius",q/2);return q;},getter:function(){var q=this.get("radius"),r=q&&q>0?q*2:0;return r;}}});b.VMLCircle=l;a=function(){a.superclass.constructor.apply(this,arguments);};a.NAME="vmlPieSlice";b.extend(a,b.VMLShape,b.mix({_type:"shape",_draw:function(u){var r=this.get("cx"),v=this.get("cy"),t=this.get("startAngle"),s=this.get("arc"),q=this.get("radius");this.clear();this.drawWedge(r,v,t,s,q);this.end();}},b.VMLDrawing.prototype));a.ATTRS=b.mix({cx:{value:0},cy:{value:0},startAngle:{value:0},arc:{value:0},radius:{value:0}},b.VMLShape.ATTRS);b.VMLPieSlice=a;i=function(){i.superclass.constructor.apply(this,arguments);};i.NAME="vmlGraphic";i.ATTRS={render:{},id:{valueFn:function(){return b.guid();},setter:function(r){var q=this._node;if(q){q.setAttribute("id",r);}return r;}},shapes:{readOnly:true,getter:function(){return this._shapes;}},contentBounds:{readOnly:true,getter:function(){return this._contentBounds;}},node:{readOnly:true,getter:function(){return this._node;}},width:{setter:function(q){if(this._node){this._node.style.width=q+"px";}return q;}},height:{setter:function(q){if(this._node){this._node.style.height=q+"px";}return q;}},autoSize:{value:false},resizeDown:{getter:function(){return this._resizeDown;},setter:function(q){this._resizeDown=q;this._redraw();return q;}},x:{getter:function(){return this._x;},setter:function(q){this._x=q;if(this._node){this._node.style.left=q+"px";}return q;}},y:{getter:function(){return this._y;},setter:function(q){this._y=q;if(this._node){this._node.style.top=q+"px";}return q;}},autoDraw:{value:true},visible:{value:true,setter:function(q){this._toggleVisible(q);return q;}}};b.extend(i,b.BaseGraphic,{_x:0,_y:0,getXY:function(){var q=b.one(this._node),r;if(q){r=q.getXY();}return r;},_resizeDown:false,initializer:function(q){var r=this.get("render");this._shapes={};this._contentBounds={left:0,top:0,right:0,bottom:0};this._node=this._createGraphic();this._node.setAttribute("id",this.get("id"));if(r){this.render(r);}},render:function(t){var q=b.one(t),r=this.get("width")||parseInt(q.getComputedStyle("width"),10),s=this.get("height")||parseInt(q.getComputedStyle("height"),10);
-q=q||m.body;q.appendChild(this._node);this.setSize(r,s);this.parentNode=q;this.set("width",r);this.set("height",s);return this;},destroy:function(){this.clear();this._node.parentNode.removeChild(this._node);},addShape:function(q){q.graphic=this;var s=this._getShapeClass(q.type),r=new s(q);this._appendShape(r);return r;},_appendShape:function(r){var s=r.node,q=this._frag||this._node;if(this.get("autoDraw")){q.appendChild(s);}else{this._getDocFrag().appendChild(s);}},removeShape:function(q){if(!q instanceof p){if(d.isString(q)){q=this._shapes[q];}}if(q&&q instanceof p){q.destroy();delete this._shapes[q.get("id")];}if(this.get("autoDraw")){this._redraw();}},removeAllShapes:function(){var q=this._shapes,r;for(r in q){if(q.hasOwnProperty(r)){q[r].destroy();}}this._shapes={};},_removeChildren:function(q){if(q.hasChildNodes()){var r;while(q.firstChild){r=q.firstChild;this._removeChildren(r);q.removeChild(r);}}},clear:function(){this._removeAllShapes();this._removeChildren(this._node);},_toggleVisible:function(t){var s,r=this._shapes,q=t?"visible":"hidden";if(r){for(s in r){if(r.hasOwnProperty(s)){r[s].set("visible",t);}}}this._node.style.visibility=q;},setSize:function(q,r){q=Math.round(q);r=Math.round(r);this._node.style.width=q+"px";this._node.style.height=r+"px";this._node.coordSize=q+" "+r;},setPosition:function(q,r){q=Math.round(q);r=Math.round(r);this._node.style.left=q+"px";this._node.style.top=r+"px";},_createGraphic:function(){var q=m.createElement('<group xmlns="urn:schemas-microsft.com:vml" style="behavior:url(#default#VML);display:block;zoom:1;" />');q.style.display="block";q.style.position="absolute";return q;},_createGraphicNode:function(q){return m.createElement("<"+q+' xmlns="urn:schemas-microsft.com:vml" style="behavior:url(#default#VML);display:inline-block;zoom:1;" />');},getShapeById:function(q){return this._shapes[q];},_getShapeClass:function(r){var q=this._shapeClass[r];if(q){return q;}return r;},_shapeClass:{circle:b.VMLCircle,rect:b.VMLRect,path:b.VMLPath,ellipse:b.VMLEllipse,pieslice:b.VMLPieSlice},batch:function(r){var q=this.get("autoDraw");this.set("autoDraw",false);r.apply();this._redraw();this.set("autoDraw",q);},_getDocFrag:function(){if(!this._frag){this._frag=m.createDocumentFragment();}return this._frag;},addToRedrawQueue:function(q){var s,r;this._shapes[q.get("id")]=q;if(!this.get("resizeDown")){s=q.getBounds();r=this._contentBounds;r.left=r.left<s.left?r.left:s.left;r.top=r.top<s.top?r.top:s.top;r.right=r.right>s.right?r.right:s.right;r.bottom=r.bottom>s.bottom?r.bottom:s.bottom;r.width=r.right-r.left;r.height=r.bottom-r.top;this._contentBounds=r;}if(this.get("autoDraw")){this._redraw();}},_redraw:function(){var q=this.get("resizeDown")?this._getUpdatedContentBounds():this._contentBounds;if(this.get("autoSize")){this.setSize(q.right,q.bottom);}if(this._frag){this._node.appendChild(this._frag);this._frag=null;}},_getUpdatedContentBounds:function(){var u,s,r,q=this._shapes,t={left:0,top:0,right:0,bottom:0};for(s in q){if(q.hasOwnProperty(s)){r=q[s];u=r.getBounds();t.left=Math.min(t.left,u.left);t.top=Math.min(t.top,u.top);t.right=Math.max(t.right,u.right);t.bottom=Math.max(t.bottom,u.bottom);}}t.width=t.right-t.left;t.height=t.bottom-t.top;this._contentBounds=t;return t;}});b.VMLGraphic=i;},"@VERSION@",{requires:["graphics"],skinnable:false});
+}this._strokeNode.endcap=z;this._strokeNode.opacity=A.opacity;if(f(r)){u=[];v=r.length;for(t=0;t<v;++t){q=r[t];u[t]=q/A.weight;}}if(y=="round"||y=="bevel"){this._strokeNode.joinstyle=y;}else{y=parseInt(y,10);if(j(y)){this._strokeNode.miterlimit=Math.max(y,1);this._strokeNode.joinstyle="miter";}}this._strokeNode.dashstyle=u;this._strokeNode.on=true;}else{if(this._strokeNode){this._strokeNode.on=false;}s.stroked=false;}this._strokeFlag=false;},_getFillProps:function(){var w=this.get("fill"),q,t,v,r,s,u=false;if(w){t={};if(w.type=="radial"||w.type=="linear"){q=parseFloat(w.opacity);q=j(q)?q:1;u=true;v=this._getGradientFill(w);s='<fill xmlns="urn:schemas-microsft.com:vml" class="vmlfill" style="behavior:url(#default#VML);display:inline-block;" opacity="'+q+'"';for(r in v){if(v.hasOwnProperty(r)){s+=" "+r+'="'+v[r]+'"';}}s+=" />";t.node=s;}else{if(w.color){q=parseFloat(w.opacity);u=true;t.color=w.color;if(j(q)){q=Math.max(Math.min(q,1),0);t.opacity=q;if(q<1){t.node='<fill xmlns="urn:schemas-microsft.com:vml" class="vmlfill" style="behavior:url(#default#VML);display:inline-block;" type="solid" opacity="'+q+'"/>';}}}}t.filled=u;}return t;},_fillChangeHandler:function(x){if(!this._fillFlag){return;}var t=this.node,w=this.get("fill"),q,s,u=false,r,v;if(w){if(w.type=="radial"||w.type=="linear"){u=true;v=this._getGradientFill(w);if(this._fillNode){for(r in v){if(v.hasOwnProperty(r)){this._fillNode.setAttribute(r,v[r]);}}}else{s='<fill xmlns="urn:schemas-microsft.com:vml" class="vmlfill" style="behavior:url(#default#VML);display:inline-block;"';for(r in v){if(v.hasOwnProperty(r)){s+=" "+r+'="'+v[r]+'"';}}s+=" />";this._fillNode=m.createElement(s);t.appendChild(this._fillNode);}}else{if(w.color){t.fillcolor=w.color;q=parseFloat(w.opacity);u=true;if(j(q)&&q<1){w.opacity=q;if(this._fillNode){if(this._fillNode.getAttribute("type")!="solid"){this._fillNode.type="solid";}this._fillNode.opacity=q;}else{s='<fill xmlns="urn:schemas-microsft.com:vml" class="vmlfill" style="behavior:url(#default#VML);display:inline-block;" type="solid" opacity="'+q+'"/>';this._fillNode=m.createElement(s);t.appendChild(this._fillNode);}}else{if(this._fillNode){this._fillNode.opacity=1;this._fillNode.type="solid";}}}}}t.filled=u;this._fillFlag=false;},_updateFillNode:function(q){if(!this._fillNode){this._fillNode=this._createGraphicNode("fill");q.appendChild(this._fillNode);}},_getGradientFill:function(K){var O={},C,A,z=K.type,D=this.get("width"),N=this.get("height"),E=j,I,B=K.stops,M=B.length,x,J,L=0,F,q="",u=K.cx,s=K.cy,v=K.fx,t=K.fy,G=K.r,y,H=K.rotation||0;if(z==="linear"){if(H<=270){H=Math.abs(H-270);}else{if(H<360){H=270+(360-H);}else{H=270;}}O.type="gradient";O.angle=H;}else{if(z==="radial"){C=D*(G*2);A=N*(G*2);v=G*2*(v-0.5);t=G*2*(t-0.5);v+=u;t+=s;O.focussize=(C/D)/10+"% "+(A/N)/10+"%";O.alignshape=false;O.type="gradientradial";O.focus="100%";O.focusposition=Math.round(v*100)+"% "+Math.round(t*100)+"%";}}for(;L<M;++L){I=B[L];J=I.color;x=I.opacity;x=E(x)?x:1;y=I.offset||L/(M-1);y*=(G*2);if(y<=1){y=Math.round(100*y)+"%";F=L>0?L+1:"";O["opacity"+F]=x+"";q+=", "+y+" "+J;}}y=B[1].offset||0;y*=100;if(parseInt(y,10)<100){q+=", 100% "+J;}O.colors=q.substr(2);return O;},_addTransform:function(r,q){q=b.Array(q);this._transform=d.trim(this._transform+" "+r+"("+q.join(", ")+")");q.unshift(r);this._transforms.push(q);if(this.initialized){this._updateTransform();}},_updateTransform:function(){var r=this.node,G,q,t,E=this.get("x"),C=this.get("y"),F=this.get("width"),A=this.get("height"),z,s,D=this.matrix,v=this.rotationMatrix,u=0,B=this._transforms.length;if(this._transforms&&this._transforms.length>0){t=this.get("transformOrigin");z=t[0]-0.5;s=t[1]-0.5;z=Math.max(-0.5,Math.min(0.5,z));s=Math.max(-0.5,Math.min(0.5,s));for(;u<B;++u){G=this._transforms[u].shift();if(G){D[G].apply(D,this._transforms[u]);}}q=D.a+","+D.c+","+D.b+","+D.d+","+0+","+0;}this._graphic.addToRedrawQueue(this);if(q){if(!this._skew){this._skew=m.createElement('<skew class="vmlskew" xmlns="urn:schemas-microsft.com:vml" on="false" style="behavior:url(#default#VML);display:inline-block;" />');this.node.appendChild(this._skew);}this._skew.matrix=q;this._skew.on=true;this._skew.offset=D.dx+"px, "+D.dy+"px";this._skew.origin=z+", "+s;}this._transforms=[];r.style.left=E+"px";r.style.top=C+"px";},_translateX:0,_translateY:0,_transform:"",translate:function(q,r){this._translateX+=q;this._translateY+=r;this._addTransform("translate",arguments);},translateX:function(q){this._translateX+=q;this._addTransform("translateX",arguments);},translateY:function(q){this._translateY+=q;this._addTransform("translateY",arguments);},skew:function(q,r){this._addTransform("skew",arguments);},skewX:function(q){this._addTransform("skewX",arguments);},skewY:function(q){this._addTransform("skewY",arguments);},_rotation:0,rotate:function(q){this._rotation+=q;this._addTransform("rotate",arguments);},scale:function(q,r){this._addTransform("scale",arguments);},on:function(r,q){if(b.Node.DOM_EVENTS[r]){return b.one("#"+this.get("id")).on(r,q);}return b.on.apply(this,arguments);},_draw:function(){},_updateHandler:function(s){var r=this,q=r.node;r._fillChangeHandler();r._strokeChangeHandler();q.style.width=this.get("width")+"px";q.style.height=this.get("height")+"px";this._draw();r._updateTransform();},_createGraphicNode:function(q){q=q||this._type;return m.createElement("<"+q+' xmlns="urn:schemas-microsft.com:vml" style="behavior:url(#default#VML);display:inline-block;" class="vml'+q+'"/>');},_getDefaultFill:function(){return{type:"solid",cx:0.5,cy:0.5,fx:0.5,fy:0.5,r:0.5};},_getDefaultStroke:function(){return{weight:1,dashstyle:"none",color:"#000",opacity:1};},set:function(){var q=this;e.prototype.set.apply(q,arguments);if(q.initialized){q._updateHandler();}},getBounds:function(x){var q,y={},G=x||this.matrix,P=G.a,O=G.b,N=G.c,L=G.d,D=G.dx,B=G.dy,C=this.get("width"),J=this.get("height"),v=this.get("x"),E=this.get("y"),M=v+C,A=E+J,z=this.get("stroke"),K=(P*v+N*E+D),u=(O*v+L*E+B),I=(P*M+N*E+D),t=(O*M+L*E+B),H=(P*v+N*A+D),s=(O*v+L*A+B),F=(P*M+N*A+D),r=(O*M+L*A+B);
+y.left=Math.min(H,Math.min(K,Math.min(I,F)));y.right=Math.max(H,Math.max(K,Math.max(I,F)));y.top=Math.min(t,Math.min(r,Math.min(s,u)));y.bottom=Math.max(t,Math.max(r,Math.max(s,u)));if(z&&z.weight){q=z.weight;y.left-=q;y.right+=q;y.top-=q;y.bottom+=q;}y.width=y.right-y.left;y.height=y.bottom-y.top;return y;},destroy:function(){var q=this._graphic&&this._graphic._node?this._graphic._node:null,r=this.node;if(this.node){if(this._fillNode){r.removeChild(this._fillNode);}if(this._strokeNode){r.removeChild(this._strokeNode);}if(q){q.removeChild(r);}}}},b.VMLDrawing.prototype));p.ATTRS={transformOrigin:{valueFn:function(){return[0.5,0.5];}},transform:{setter:function(t){var s=0,q,r;this._rotation=0;this.matrix.init();this._transforms=this.matrix.getTransformArray(t);q=this._transforms.length;for(;s<q;++s){r=this._transforms[s];if(r[0]=="rotate"){this._rotation+=r[1];}}this._transform=t;if(this.initialized){this._updateTransform();}return t;},getter:function(){return this._transform;}},x:{value:0},y:{value:0},id:{valueFn:function(){return b.guid();},setter:function(r){var q=this.node;if(q){q.setAttribute("id",r);}return r;}},width:{value:0},height:{value:0},visible:{value:true,setter:function(s){var r=this.node,q=s?"visible":"hidden";if(r){r.style.visibility=q;}return s;}},fill:{valueFn:"_getDefaultFill",setter:function(t){var r,s,q=this.get("fill")||this._getDefaultFill();if(t){if(t.hasOwnProperty("color")){t.type="solid";}for(r in t){if(t.hasOwnProperty(r)){q[r]=t[r];}}}s=q;if(s&&s.color){if(s.color===undefined||s.color=="none"){s.color=null;}}this._fillFlag=true;return s;}},stroke:{valueFn:"_getDefaultStroke",setter:function(u){var s,t,q,r=this.get("stroke")||this._getDefaultStroke();if(u){if(u.hasOwnProperty("weight")){q=parseInt(u.weight,10);if(!isNaN(q)){u.weight=q;}}for(s in u){if(u.hasOwnProperty(s)){r[s]=u[s];}}}t=r;this._strokeFlag=true;return t;}},autoSize:{value:false},pointerEvents:{value:"visiblePainted"},node:{readOnly:true,getter:function(){return this.node;}},graphic:{readOnly:true,getter:function(){return this._graphic;}}};b.VMLShape=p;o=function(){o.superclass.constructor.apply(this,arguments);};o.NAME="vmlPath";b.extend(o,b.VMLShape,{_updateHandler:function(){var q=this;q._fillChangeHandler();q._strokeChangeHandler();q._updateTransform();}});o.ATTRS=b.merge(b.VMLShape.ATTRS,{width:{getter:function(){return this._width;},setter:function(q){this._width=q;return q;}},height:{getter:function(){return this._height;},setter:function(q){this._height=q;return q;}},path:{readOnly:true,getter:function(){return this._path;}}});b.VMLPath=o;k=function(){k.superclass.constructor.apply(this,arguments);};k.NAME="vmlRect";b.extend(k,b.VMLShape,{_type:"rect"});k.ATTRS=b.VMLShape.ATTRS;b.VMLRect=k;n=function(){n.superclass.constructor.apply(this,arguments);};n.NAME="vmlEllipse";b.extend(n,b.VMLShape,{_type:"oval"});n.ATTRS=b.merge(b.VMLShape.ATTRS,{xRadius:{lazyAdd:false,getter:function(){var q=this.get("width");q=Math.round((q/2)*100)/100;return q;},setter:function(r){var q=r*2;this.set("width",q);return r;}},yRadius:{lazyAdd:false,getter:function(){var q=this.get("height");q=Math.round((q/2)*100)/100;return q;},setter:function(r){var q=r*2;this.set("height",q);return r;}}});b.VMLEllipse=n;l=function(q){l.superclass.constructor.apply(this,arguments);};l.NAME="vmlCircle";b.extend(l,p,{_type:"oval"});l.ATTRS=b.merge(p.ATTRS,{radius:{lazyAdd:false,value:0},width:{setter:function(q){this.set("radius",q/2);return q;},getter:function(){var q=this.get("radius"),r=q&&q>0?q*2:0;return r;}},height:{setter:function(q){this.set("radius",q/2);return q;},getter:function(){var q=this.get("radius"),r=q&&q>0?q*2:0;return r;}}});b.VMLCircle=l;a=function(){a.superclass.constructor.apply(this,arguments);};a.NAME="vmlPieSlice";b.extend(a,b.VMLShape,b.mix({_type:"shape",_draw:function(u){var r=this.get("cx"),v=this.get("cy"),t=this.get("startAngle"),s=this.get("arc"),q=this.get("radius");this.clear();this.drawWedge(r,v,t,s,q);this.end();}},b.VMLDrawing.prototype));a.ATTRS=b.mix({cx:{value:0},cy:{value:0},startAngle:{value:0},arc:{value:0},radius:{value:0}},b.VMLShape.ATTRS);b.VMLPieSlice=a;i=function(){i.superclass.constructor.apply(this,arguments);};i.NAME="vmlGraphic";i.ATTRS={render:{},id:{valueFn:function(){return b.guid();},setter:function(r){var q=this._node;if(q){q.setAttribute("id",r);}return r;}},shapes:{readOnly:true,getter:function(){return this._shapes;}},contentBounds:{readOnly:true,getter:function(){return this._contentBounds;}},node:{readOnly:true,getter:function(){return this._node;}},width:{setter:function(q){if(this._node){this._node.style.width=q+"px";}return q;}},height:{setter:function(q){if(this._node){this._node.style.height=q+"px";}return q;}},autoSize:{value:false},resizeDown:{getter:function(){return this._resizeDown;},setter:function(q){this._resizeDown=q;this._redraw();return q;}},x:{getter:function(){return this._x;},setter:function(q){this._x=q;if(this._node){this._node.style.left=q+"px";}return q;}},y:{getter:function(){return this._y;},setter:function(q){this._y=q;if(this._node){this._node.style.top=q+"px";}return q;}},autoDraw:{value:true},visible:{value:true,setter:function(q){this._toggleVisible(q);return q;}}};b.extend(i,b.BaseGraphic,{_x:0,_y:0,getXY:function(){var q=b.one(this._node),r;if(q){r=q.getXY();}return r;},_resizeDown:false,initializer:function(q){var r=this.get("render");this._shapes={};this._contentBounds={left:0,top:0,right:0,bottom:0};this._node=this._createGraphic();this._node.setAttribute("id",this.get("id"));if(r){this.render(r);}},render:function(t){var q=b.one(t),r=this.get("width")||parseInt(q.getComputedStyle("width"),10),s=this.get("height")||parseInt(q.getComputedStyle("height"),10);q=q||m.body;q.appendChild(this._node);this.setSize(r,s);this.parentNode=q;this.set("width",r);this.set("height",s);return this;},destroy:function(){this.clear();this._node.parentNode.removeChild(this._node);},addShape:function(q){q.graphic=this;var s=this._getShapeClass(q.type),r=new s(q);
+this._appendShape(r);return r;},_appendShape:function(r){var s=r.node,q=this._frag||this._node;if(this.get("autoDraw")){q.appendChild(s);}else{this._getDocFrag().appendChild(s);}},removeShape:function(q){if(!q instanceof p){if(d.isString(q)){q=this._shapes[q];}}if(q&&q instanceof p){q.destroy();delete this._shapes[q.get("id")];}if(this.get("autoDraw")){this._redraw();}},removeAllShapes:function(){var q=this._shapes,r;for(r in q){if(q.hasOwnProperty(r)){q[r].destroy();}}this._shapes={};},_removeChildren:function(q){if(q.hasChildNodes()){var r;while(q.firstChild){r=q.firstChild;this._removeChildren(r);q.removeChild(r);}}},clear:function(){this._removeAllShapes();this._removeChildren(this._node);},_toggleVisible:function(t){var s,r=this._shapes,q=t?"visible":"hidden";if(r){for(s in r){if(r.hasOwnProperty(s)){r[s].set("visible",t);}}}this._node.style.visibility=q;},setSize:function(q,r){q=Math.round(q);r=Math.round(r);this._node.style.width=q+"px";this._node.style.height=r+"px";this._node.coordSize=q+" "+r;},setPosition:function(q,r){q=Math.round(q);r=Math.round(r);this._node.style.left=q+"px";this._node.style.top=r+"px";},_createGraphic:function(){var q=m.createElement('<group xmlns="urn:schemas-microsft.com:vml" style="behavior:url(#default#VML);display:block;zoom:1;" />');q.style.display="block";q.style.position="absolute";return q;},_createGraphicNode:function(q){return m.createElement("<"+q+' xmlns="urn:schemas-microsft.com:vml" style="behavior:url(#default#VML);display:inline-block;zoom:1;" />');},getShapeById:function(q){return this._shapes[q];},_getShapeClass:function(r){var q=this._shapeClass[r];if(q){return q;}return r;},_shapeClass:{circle:b.VMLCircle,rect:b.VMLRect,path:b.VMLPath,ellipse:b.VMLEllipse,pieslice:b.VMLPieSlice},batch:function(r){var q=this.get("autoDraw");this.set("autoDraw",false);r.apply();this._redraw();this.set("autoDraw",q);},_getDocFrag:function(){if(!this._frag){this._frag=m.createDocumentFragment();}return this._frag;},addToRedrawQueue:function(q){var s,r;this._shapes[q.get("id")]=q;if(!this.get("resizeDown")){s=q.getBounds();r=this._contentBounds;r.left=r.left<s.left?r.left:s.left;r.top=r.top<s.top?r.top:s.top;r.right=r.right>s.right?r.right:s.right;r.bottom=r.bottom>s.bottom?r.bottom:s.bottom;r.width=r.right-r.left;r.height=r.bottom-r.top;this._contentBounds=r;}if(this.get("autoDraw")){this._redraw();}},_redraw:function(){var q=this.get("resizeDown")?this._getUpdatedContentBounds():this._contentBounds;if(this.get("autoSize")){this.setSize(q.right,q.bottom);}if(this._frag){this._node.appendChild(this._frag);this._frag=null;}},_getUpdatedContentBounds:function(){var u,s,r,q=this._shapes,t={left:0,top:0,right:0,bottom:0};for(s in q){if(q.hasOwnProperty(s)){r=q[s];u=r.getBounds();t.left=Math.min(t.left,u.left);t.top=Math.min(t.top,u.top);t.right=Math.max(t.right,u.right);t.bottom=Math.max(t.bottom,u.bottom);}}t.width=t.right-t.left;t.height=t.bottom-t.top;this._contentBounds=t;return t;}});b.VMLGraphic=i;},"@VERSION@",{requires:["graphics"],skinnable:false});
View
92 build/graphics-vml/graphics-vml.js
@@ -997,19 +997,8 @@ Y.extend(VMLShape, Y.BaseGraphic, Y.mix({
y = this.get("y"),
w = this.get("width"),
h = this.get("height"),
- cx,
- cy,
- dx,
- dy,
- originX,
- originY,
- translatedCenterX,
- translatedCenterY,
- oldBounds,
- newBounds,
tx,
ty,
- keys = [],
matrix = this.matrix,
rotationMatrix = this.rotationMatrix,
i = 0,
@@ -1018,70 +1007,48 @@ Y.extend(VMLShape, Y.BaseGraphic, Y.mix({
if(this._transforms && this._transforms.length > 0)
{
transformOrigin = this.get("transformOrigin");
+
+ //vml skew matrix transformOrigin ranges from -0.5 to 0.5.
+ //subtract 0.5 from values
+ tx = transformOrigin[0] - 0.5;
+ ty = transformOrigin[1] - 0.5;
+
+ //ensure the values are within the appropriate range to avoid errors
+ tx = Math.max(-0.5, Math.min(0.5, tx));
+ ty = Math.max(-0.5, Math.min(0.5, ty));
+
for(; i < len; ++i)
{
key = this._transforms[i].shift();
if(key)
{
- if(key == "rotate")
- {
- tx = transformOrigin[0];
- ty = transformOrigin[1];
- oldBounds = this.getBounds(matrix);
- matrix[key].apply(matrix, this._transforms[i]);
- rotationMatrix[key].apply(rotationMatrix, this._transforms[i]);
- newBounds = this.getBounds(matrix);
- cx = w * 0.5;
- cy = h * 0.5;
- originX = w * (tx);
- originY = h * (ty);
- translatedCenterX = cx - originX;
- translatedCenterY = cy - originY;
- translatedCenterX = (matrix.a * translatedCenterX + matrix.b * translatedCenterY);
- translatedCenterY = (matrix.d * translatedCenterX + matrix.d * translatedCenterY);
- translatedCenterX += originX;
- translatedCenterY += originY;
- matrix.dx = rotationMatrix.dx + translatedCenterX - (newBounds.right - newBounds.left)/2;
- matrix.dy = rotationMatrix.dy + translatedCenterY - (newBounds.bottom - newBounds.top)/2;
- }
- else if(key == "scale")
- {
- transformOrigin = this.get("transformOrigin");
- tx = x + (transformOrigin[0] * this.get("width"));
- ty = y + (transformOrigin[1] * this.get("height"));
- matrix.translate(tx, ty);
- matrix[key].apply(matrix, this._transforms[i]);
- matrix.translate(0 - tx, 0 - ty);
- }
- else
- {
- matrix[key].apply(matrix, this._transforms[i]);
- rotationMatrix[key].apply(rotationMatrix, this._transforms[i]);
- }
- keys.push(key);
+ matrix[key].apply(matrix, this._transforms[i]);
}
}
- transform = matrix.toFilterText();
+ transform = matrix.a + "," +
+ matrix.c + "," +
+ matrix.b + "," +
+ matrix.d + "," +
+ 0 + "," +
+ 0;
}
- dx = matrix.dx;
- dy = matrix.dy;
this._graphic.addToRedrawQueue(this);
- //only apply the filter if necessary as it degrades image quality
- if(Y.Array.indexOf(keys, "skew") > -1 || Y.Array.indexOf(keys, "scale") > -1)
- {
- node.style.filter = transform;
- }
- else if(Y.Array.indexOf(keys,"rotate") > -1)
+ if(transform)
{
- node.style.rotation = this._rotation;
- dx = rotationMatrix.dx;
- dy = rotationMatrix.dy;
+ if(!this._skew)
+ {
+ this._skew = DOCUMENT.createElement( '<skew class="vmlskew" xmlns="urn:schemas-microsft.com:vml" on="false" style="behavior:url(#default#VML);display:inline-block;" />');
+ this.node.appendChild(this._skew);
+ }
+ this._skew.matrix = transform;
+ this._skew.on = true;
+ //use offset for translate
+ this._skew.offset = matrix.dx + "px, " + matrix.dy + "px";
+ this._skew.origin = tx + ", " + ty;
}
this._transforms = [];
- x += dx;
- y += dy;
node.style.left = x + "px";
- node.style.top = y + "px";
+ node.style.top = y + "px";
},
/**
@@ -1444,6 +1411,7 @@ VMLShape.ATTRS = {
* <dt>translateY</dt><dd>Translates the shape along the y-axis.</dd>
* <dt>skewX</dt><dd>Skews the shape around the x-axis.</dd>
* <dt>skewY</dt><dd>Skews the shape around the y-axis.</dd>
+ * <dt>matrix</dt><dd>Specifies a 2D transformation matrix comprised of the specified six values.</dd>
* </dl>
* </p>
* <p>Applying transforms through the transform attribute will reset the transform matrix and apply a new transform. The shape class also contains corresponding methods for each transform
View
5 build/graphics/graphics-debug.js
@@ -118,11 +118,12 @@ var SETTER = "setter",
* @return Array
*/
getTransformArray: function(val) {
- var re = /\s*([a-z]*)\(([\w,\s]*)\)/gi,
+ var re = /\s*([a-z]*)\(([\w,\.,\-,\s]*)\)/gi,
transforms = [],
args,
m;
-
+
+ val = val.replace(/matrix/g, "multiply");
while ((m = re.exec(val))) {
if (typeof this[m[1]] === 'function') {
args = m[2].split(',');
View
2 build/graphics/graphics-min.js
@@ -1 +1 @@
-YUI.add("graphics",function(c){var g="setter",h=c.Plugin.Host,j="value",b="valueFn",k="readOnly",d=c.Lang,f="string",i="writeOnce",l,e,a;a=function(m){this.init(m);};a.prototype={_rounder:100000,multiply:function(u,s,r,q,y,x){var t=this,p=t.a*u+t.c*s,o=t.b*u+t.d*s,n=t.a*r+t.c*q,m=t.b*r+t.d*q,w=t.a*y+t.c*x+t.dx,v=t.b*y+t.d*x+t.dy;t.a=p;t.b=o;t.c=n;t.d=m;t.dx=w;t.dy=v;return this;},applyCSSText:function(q){var p=/\s*([a-z]*)\(([\w,\s]*)\)/gi,o,n;while((n=p.exec(q))){if(typeof this[n[1]]==="function"){o=n[2].split(",");console.log(o);this[n[1]].apply(this,o);}}},getTransformArray:function(r){var q=/\s*([a-z]*)\(([\w,\s]*)\)/gi,p=[],o,n;while((n=q.exec(r))){if(typeof this[n[1]]==="function"){o=n[2].split(",");o.unshift(n[1]);p.push(o);}}return p;},_defaults:{a:1,b:0,c:0,d:1,dx:0,dy:0},_round:function(m){m=Math.round(m*this._rounder)/this._rounder;return m;},init:function(m){var n=this._defaults,o;m=m||{};for(o in n){if(n.hasOwnProperty(o)){this[o]=(o in m)?m[o]:n[o];}}this._config=m;},scale:function(m,n){this.multiply(m,0,0,n,0,0);return this;},skew:function(m,n){m=m||0;n=n||0;if(m!==undefined){m=this._round(Math.tan(this.angle2rad(m)));}if(n!==undefined){n=this._round(Math.tan(this.angle2rad(n)));}this.multiply(1,n,m,1,0,0);return this;},skewX:function(m){this.skew(m);return this;},skewY:function(m){this.skew(null,m);return this;},toCSSText:function(){var o=this,n=o.dx,m=o.dy,p="matrix(";if(c.UA.gecko){if(!isNaN(n)){n+="px";}if(!isNaN(m)){m+="px";}}p+=o.a+","+o.b+","+o.c+","+o.d+","+n+","+m;p+=")";return p;},toFilterText:function(){var m=this,n="progid:DXImageTransform.Microsoft.Matrix(";n+="M11="+m.a+","+"M21="+m.b+","+"M12="+m.c+","+"M22="+m.d+","+'sizingMethod="auto expand")';n+="";return n;},rad2deg:function(m){var n=m*(180/Math.PI);return n;},deg2rad:function(n){var m=n*(Math.PI/180);return m;},angle2rad:function(m){if(typeof m==="string"&&m.indexOf("rad")>-1){m=parseFloat(m);}else{m=this.deg2rad(parseFloat(m));}return m;},rotate:function(q,n,s){var p=[],m=this.angle2rad(q),o=this._round(Math.sin(m)),r=this._round(Math.cos(m));this.multiply(r,o,0-o,r,0,0);return this;},translate:function(m,n){this.multiply(1,0,0,1,parseFloat(m),parseFloat(n));return this;}};c.Matrix=a;e=function(){var m=this;m._ATTR_E_FACADE={};c.EventTarget.call(this,{emitFacade:true});m._state={};m.prototype=c.mix(e.prototype,m.prototype);};e.prototype={addAttrs:function(n){var r=this,p=this.constructor.ATTRS,m,o,q,s=r._state;for(o in p){if(p.hasOwnProperty(o)){m=p[o];if(m.hasOwnProperty(j)){s[o]=m.value;}else{if(m.hasOwnProperty(b)){q=m.valueFn;if(d.isString(q)){s[o]=r[q].apply(r);}else{s[o]=q.apply(r);}}}}}r._state=s;for(o in p){if(p.hasOwnProperty(o)){m=p[o];if(m.hasOwnProperty(k)&&m.readOnly){continue;}if(m.hasOwnProperty(i)&&m.writeOnce){m.readOnly=true;}if(n&&n.hasOwnProperty(o)){if(m.hasOwnProperty(g)){r._state[o]=m.setter.apply(r,[n[o]]);}else{r._state[o]=n[o];}}}}},get:function(n){var p=this,m,o=p.constructor.ATTRS;if(o&&o[n]){m=o[n].getter;if(m){if(typeof m==f){return p[m].apply(p);}return o[n].getter.apply(p);}return p._state[n];}return null;},set:function(m,o){var n;if(d.isObject(m)){for(n in m){if(m.hasOwnProperty(n)){this._set(n,m[n]);}}}else{this._set.apply(this,arguments);}},_set:function(m,q){var p=this,r,n,o=p.constructor.ATTRS;if(o&&o.hasOwnProperty(m)){r=o[m].setter;if(r){n=[q];if(typeof r==f){q=p[r].apply(p,n);}else{q=o[m].setter.apply(p,n);}}p._state[m]=q;}}};c.mix(e,c.EventTarget,false,null,1);c.AttributeLite=e;l=function(m){var o=this,n=c.Plugin&&c.Plugin.Host;if(o._initPlugins&&n){n.call(o);}o.name=o.constructor.NAME;o._eventPrefix=o.constructor.EVENT_PREFIX||o.constructor.NAME;e.call(o);o.addAttrs(m);o.init.apply(this,arguments);if(o._initPlugins){o._initPlugins(m);}o.initialized=true;};l.NAME="baseGraphic";l.prototype={init:function(){this.publish("init",{fireOnce:true});this.initializer.apply(this,arguments);this.fire("init",{cfg:arguments[0]});}};c.mix(l,c.AttributeLite,false,null,1);c.mix(l,h,false,null,1);l.prototype.constructor=l;l.plug=h.plug;l.unplug=h.unplug;c.BaseGraphic=l;},"@VERSION@",{requires:["event-custom","node","pluginhost"]});
+YUI.add("graphics",function(c){var g="setter",h=c.Plugin.Host,j="value",b="valueFn",k="readOnly",d=c.Lang,f="string",i="writeOnce",l,e,a;a=function(m){this.init(m);};a.prototype={_rounder:100000,multiply:function(u,s,r,q,y,x){var t=this,p=t.a*u+t.c*s,o=t.b*u+t.d*s,n=t.a*r+t.c*q,m=t.b*r+t.d*q,w=t.a*y+t.c*x+t.dx,v=t.b*y+t.d*x+t.dy;t.a=p;t.b=o;t.c=n;t.d=m;t.dx=w;t.dy=v;return this;},applyCSSText:function(q){var p=/\s*([a-z]*)\(([\w,\s]*)\)/gi,o,n;while((n=p.exec(q))){if(typeof this[n[1]]==="function"){o=n[2].split(",");console.log(o);this[n[1]].apply(this,o);}}},getTransformArray:function(r){var q=/\s*([a-z]*)\(([\w,\.,\-,\s]*)\)/gi,p=[],o,n;r=r.replace(/matrix/g,"multiply");while((n=q.exec(r))){if(typeof this[n[1]]==="function"){o=n[2].split(",");o.unshift(n[1]);p.push(o);}}return p;},_defaults:{a:1,b:0,c:0,d:1,dx:0,dy:0},_round:function(m){m=Math.round(m*this._rounder)/this._rounder;return m;},init:function(m){var n=this._defaults,o;m=m||{};for(o in n){if(n.hasOwnProperty(o)){this[o]=(o in m)?m[o]:n[o];}}this._config=m;},scale:function(m,n){this.multiply(m,0,0,n,0,0);return this;},skew:function(m,n){m=m||0;n=n||0;if(m!==undefined){m=this._round(Math.tan(this.angle2rad(m)));}if(n!==undefined){n=this._round(Math.tan(this.angle2rad(n)));}this.multiply(1,n,m,1,0,0);return this;},skewX:function(m){this.skew(m);return this;},skewY:function(m){this.skew(null,m);return this;},toCSSText:function(){var o=this,n=o.dx,m=o.dy,p="matrix(";if(c.UA.gecko){if(!isNaN(n)){n+="px";}if(!isNaN(m)){m+="px";}}p+=o.a+","+o.b+","+o.c+","+o.d+","+n+","+m;p+=")";return p;},toFilterText:function(){var m=this,n="progid:DXImageTransform.Microsoft.Matrix(";n+="M11="+m.a+","+"M21="+m.b+","+"M12="+m.c+","+"M22="+m.d+","+'sizingMethod="auto expand")';n+="";return n;},rad2deg:function(m){var n=m*(180/Math.PI);return n;},deg2rad:function(n){var m=n*(Math.PI/180);return m;},angle2rad:function(m){if(typeof m==="string"&&m.indexOf("rad")>-1){m=parseFloat(m);}else{m=this.deg2rad(parseFloat(m));}return m;},rotate:function(q,n,s){var p=[],m=this.angle2rad(q),o=this._round(Math.sin(m)),r=this._round(Math.cos(m));this.multiply(r,o,0-o,r,0,0);return this;},translate:function(m,n){this.multiply(1,0,0,1,parseFloat(m),parseFloat(n));return this;}};c.Matrix=a;e=function(){var m=this;m._ATTR_E_FACADE={};c.EventTarget.call(this,{emitFacade:true});m._state={};m.prototype=c.mix(e.prototype,m.prototype);};e.prototype={addAttrs:function(n){var r=this,p=this.constructor.ATTRS,m,o,q,s=r._state;for(o in p){if(p.hasOwnProperty(o)){m=p[o];if(m.hasOwnProperty(j)){s[o]=m.value;}else{if(m.hasOwnProperty(b)){q=m.valueFn;if(d.isString(q)){s[o]=r[q].apply(r);}else{s[o]=q.apply(r);}}}}}r._state=s;for(o in p){if(p.hasOwnProperty(o)){m=p[o];if(m.hasOwnProperty(k)&&m.readOnly){continue;}if(m.hasOwnProperty(i)&&m.writeOnce){m.readOnly=true;}if(n&&n.hasOwnProperty(o)){if(m.hasOwnProperty(g)){r._state[o]=m.setter.apply(r,[n[o]]);}else{r._state[o]=n[o];}}}}},get:function(n){var p=this,m,o=p.constructor.ATTRS;if(o&&o[n]){m=o[n].getter;if(m){if(typeof m==f){return p[m].apply(p);}return o[n].getter.apply(p);}return p._state[n];}return null;},set:function(m,o){var n;if(d.isObject(m)){for(n in m){if(m.hasOwnProperty(n)){this._set(n,m[n]);}}}else{this._set.apply(this,arguments);}},_set:function(m,q){var p=this,r,n,o=p.constructor.ATTRS;if(o&&o.hasOwnProperty(m)){r=o[m].setter;if(r){n=[q];if(typeof r==f){q=p[r].apply(p,n);}else{q=o[m].setter.apply(p,n);}}p._state[m]=q;}}};c.mix(e,c.EventTarget,false,null,1);c.AttributeLite=e;l=function(m){var o=this,n=c.Plugin&&c.Plugin.Host;if(o._initPlugins&&n){n.call(o);}o.name=o.constructor.NAME;o._eventPrefix=o.constructor.EVENT_PREFIX||o.constructor.NAME;e.call(o);o.addAttrs(m);o.init.apply(this,arguments);if(o._initPlugins){o._initPlugins(m);}o.initialized=true;};l.NAME="baseGraphic";l.prototype={init:function(){this.publish("init",{fireOnce:true});this.initializer.apply(this,arguments);this.fire("init",{cfg:arguments[0]});}};c.mix(l,c.AttributeLite,false,null,1);c.mix(l,h,false,null,1);l.prototype.constructor=l;l.plug=h.plug;l.unplug=h.unplug;c.BaseGraphic=l;},"@VERSION@",{requires:["event-custom","node","pluginhost"]});
View
5 build/graphics/graphics.js
@@ -118,11 +118,12 @@ var SETTER = "setter",
* @return Array
*/
getTransformArray: function(val) {
- var re = /\s*([a-z]*)\(([\w,\s]*)\)/gi,
+ var re = /\s*([a-z]*)\(([\w,\.,\-,\s]*)\)/gi,
transforms = [],
args,
m;
-
+
+ val = val.replace(/matrix/g, "multiply");
while ((m = re.exec(val))) {
if (typeof this[m[1]] === 'function') {
args = m[2].split(',');

0 comments on commit 0f600fa

Please sign in to comment.
Something went wrong with that request. Please try again.