//>>built
define("dojox/drawing/stencil/_Base","dojo dojo/fx/easing ../util/oo ../annotations/BoxShadow ../annotations/Angle ../annotations/Label ../defaults".split(" "),function(c,w,r,x,y,z,A){r=r.declare(function(a){c.mixin(this,a);this.style=a.style||A.copy();a.stencil&&(this.stencil=a.stencil,this.util=a.stencil.util,this.mouse=a.stencil.mouse,this.container=a.stencil.container,this.style=a.stencil.style);this.shortType=this.util.abbr(this.type);this.isText=/Text/.test(this.type);this.isLine=/Line|Vector|Axes|Arrow/.test(this.type);
this.renderHit=this.style.renderHitLayer;!this.renderHit&&this.style.renderHitLines&&this.isLine&&(this.renderHit=!0);if(!this.renderHit&&this.style.useSelectedStyle){this.useSelectedStyle=!0;this.selCopy=c.clone(this.style.selected);for(var b in this.style.norm)void 0===this.style.selected[b]&&(this.style.selected[b]=this.style.norm[b]);this.textSelected=c.clone(this.style.text);this.textSelected.color=this.style.selected.fill}this.angleSnap=this.style.angleSnap||1;this.marginZero=a.marginZero||
this.style.anchors.marginZero;this.id=a.id||this.util.uid(this.type);this._cons=[];this.annotation||this.subShape||this.util.attr(this.container,"id",this.id);this.connect(this,"onBeforeRender","preventNegativePos");this._offX=this.mouse.origin.x;this._offY=this.mouse.origin.y;this.isText&&(this.align=a.align||this.align,this.valign=a.valign||this.valign,a.data&&a.data.makeFit?(b=this.makeFit(a.data.text,a.data.width),this.textSize=this.style.text.size=b.size,this._lineHeight=b.box.h):(this.textSize=
parseInt(this.style.text.size,10),this._lineHeight=1.4*this.textSize),this.deleteEmptyCreate=void 0!==a.deleteEmptyCreate?a.deleteEmptyCreate:this.style.text.deleteEmptyCreate,this.deleteEmptyModify=void 0!==a.deleteEmptyModify?a.deleteEmptyModify:this.style.text.deleteEmptyModify);this.attr(a.data);this.noBaseRender||(a.points?(a.data&&!1===a.data.closePath&&(this.closePath=!1),this.setPoints(a.points),this.connect(this,"render",this,"onRender",!0),this.baseRender&&this.enabled&&this.render(),a.label&&
this.setLabel(a.label),a.shadow&&this.addShadow(a.shadow)):a.data?(a.data.width=a.data.width?a.data.width:this.style.text.minWidth,a.data.height=a.data.height?a.data.height:this._lineHeight,this.setData(a.data),this.connect(this,"render",this,"onRender",!0),this.baseRender&&this.enabled&&this.render(a.data.text),this.baseRender&&a.label&&this.setLabel(a.label),this.baseRender&&a.shadow&&this.addShadow(a.shadow)):this.draws&&(this.points=[],this.data={},this.connectMouse(),this._postRenderCon=c.connect(this,
"render",this,"_onPostRender")),this.showAngle&&(this.angleLabel=new y({stencil:this})),this.enabled||(this.disable(),this.moveToBack(),this.render(a.data.text)))},{type:"dojox.drawing.stencil",minimumSize:10,enabled:!0,drawingType:"stencil",setData:function(a){this.data=a;this.points=this.dataToPoints()},setPoints:function(a){this.points=a;this.pointsToData&&(this.data=this.pointsToData())},onDelete:function(a){},onBeforeRender:function(a){},onModify:function(a){},onChangeData:function(a){},onChangeText:function(a){},
onRender:function(a){this._postRenderCon=c.connect(this,"render",this,"_onPostRender");this.created=!0;this.disconnectMouse();this.shape?this.shape.superClass=this:this.container.superClass=this;this._setNodeAtts(this)},onChangeStyle:function(a){this._isBeingModified=!0;this.enabled?(this.style.current=this.style.norm,this.style.currentHit=this.style.hitNorm,this.style.currentText=this.style.text):(this.style.current=this.style.disabled,this.style.currentText=this.style.textDisabled,this.style.currentHit=
this.style.hitNorm);this.selected?(this.useSelectedStyle&&(this.style.current=this.style.selected,this.style.currentText=this.textSelected),this.style.currentHit=this.style.hitSelected):this.highlighted&&(this.style.currentHit=this.style.hitHighlighted);this.render()},animate:function(a,b){var d=a.d||a.duration||1E3,g=a.ms||20,m=a.ease||w.linear,k=(new Date).getTime(),p=0,l=!0;if(c.isArray(a.start)){var h=a.start;var f=a.end}else c.isObject(a.start)&&(h=a.start,f=a.end,l=!1);var q=setInterval(c.hitch(this,
function(){var e=(new Date).getTime()-k,u=m(1-e/d);if(e>d||100<p++)clearInterval(q);else if(l){var v=[];c.forEach(h,function(B,n){v.push({x:(f[n].x-h[n].x)*u+h[n].x,y:(f[n].y-h[n].y)*u+h[n].y})});this.setPoints(v);this.render()}else{e={};for(var t in h)e[t]=(f[t]-h[t])*u+h[t];this.attr(e)}}),g)},attr:function(a,b){var d=this.enabled?this.style.norm:this.style.disabled,g=this.enabled?this.style.text:this.style.textDisabled,m=this.textSelected||{},k=c.toJson(d),p=c.toJson(g),l={x:!0,y:!0,r:!0,height:!0,
width:!0,radius:!0,angle:!0},h=!1;if("object"!=typeof a){var f={};f[a]=b}else f=c.clone(a);if(f.width){var q=f.width;delete f.width}for(e in f)e in d&&(d[e]=f[e]),e in g&&(g[e]=f[e]),e in m&&(m[e]=f[e]),e in l&&(l[e]=f[e],h=!0,"radius"==e&&void 0===f.angle?f.angle=l.angle=this.getAngle():"angle"==e&&void 0===f.radius&&(f.radius=l.radius=this.getRadius())),"text"==e&&this.setText(f.text),"label"==e&&this.setLabel(f.label);void 0!==f.borderWidth&&(d.width=f.borderWidth);if(this.useSelectedStyle){for(e in this.style.norm)void 0===
this.selCopy[e]&&(this.style.selected[e]=this.style.norm[e]);this.textSelected.color=this.style.selected.color}if(this.created){if(void 0!==f.x||void 0!==f.y){m=this.getBounds(!0);l={dx:0,dy:0};for(e in f)if("x"==e||"y"==e||"r"==e)l["d"+e]=f[e]-m[e];this.transformPoints(l)}var e=this.points;void 0!==f.angle?this.dataToPoints({x:this.data.x1,y:this.data.y1,angle:f.angle,radius:f.radius}):void 0!==q&&(e[1].x=e[2].x=e[0].x+q,this.pointsToData(e));void 0!==f.height&&void 0===f.angle&&(e[2].y=e[3].y=e[0].y+
f.height,this.pointsToData(e));void 0!==f.r&&(this.data.r=Math.max(0,f.r));if(h||p!=c.toJson(g)||k!=c.toJson(d))this.onChangeStyle(this);f.width=q;void 0!=f.cosphi&&(this.data?this.data.cosphi=f.cosphi:this.data={cosphi:f.cosphi},this.style.zAxis=0!=f.cosphi?!0:!1)}},exporter:function(){var a=this.type.substring(this.type.lastIndexOf(".")+1).charAt(0).toLowerCase()+this.type.substring(this.type.lastIndexOf(".")+2),b=c.clone(this.style.norm);b.borderWidth=b.width;delete b.width;"path"==a?b.points=
this.points:b=c.mixin(b,this.data);b.type=a;this.isText&&(b.text=this.getText(),b=c.mixin(b,this.style.text),delete b.minWidth,delete b.deleteEmptyCreate,delete b.deleteEmptyModify);if(a=this.getLabel())b.label=a;return b},disable:function(){this.renderHit=this.enabled=!1;this.onChangeStyle(this)},enable:function(){this.renderHit=this.enabled=!0;this.onChangeStyle(this)},select:function(){this.selected=!0;this.onChangeStyle(this)},deselect:function(a){a?setTimeout(c.hitch(this,function(){this.selected=
!1;this.onChangeStyle(this)}),200):(this.selected=!1,this.onChangeStyle(this))},_toggleSelected:function(){this.selected&&(this.deselect(),setTimeout(c.hitch(this,"select"),0))},highlight:function(){this.highlighted=!0;this.onChangeStyle(this)},unhighlight:function(){this.highlighted=!1;this.onChangeStyle(this)},moveToFront:function(){this.container&&this.container.moveToFront()},moveToBack:function(){this.container&&this.container.moveToBack()},onTransformBegin:function(a){this._isBeingModified=
!0},onTransformEnd:function(a){this._isBeingModified=!1;this.onModify(this)},onTransform:function(a){if(!this._isBeingModified)this.onTransformBegin();this.setPoints(this.points);this.render()},transformPoints:function(a){if(a.dx||a.dy){var b=c.clone(this.points),d=!1;c.forEach(this.points,function(g){g.x+=a.dx;g.y+=a.dy;if(g.x<this.marginZero||g.y<this.marginZero)d=!0});d?this.points=b:(this.onTransform(),this.onTransformEnd())}},applyTransform:function(a){this.transformPoints(a)},setTransform:function(a){this.attr({x:a.dx,
y:a.dy})},getTransform:function(){return this.selected?this.container.getParent().getTransform():{dx:0,dy:0}},addShadow:function(a){a=!0===a?{}:a;a.stencil=this;this.shadow=new x(a)},removeShadow:function(){this.shadow.destroy()},setLabel:function(a){this._label?void 0!=a&&this._label.setLabel(a):this._label=new z.Label({text:a,util:this.util,mouse:this.mouse,stencil:this,annotation:!0,container:this.container,labelPosition:this.labelPosition})},getLabel:function(){return this._label?this._label.getText():
null},getAngle:function(){var a=this.pointsToData();a=this.util.angle({start:{x:a.x1,y:a.y1},x:a.x2,y:a.y2},this.angleSnap);0>a?a=360+a:a;return a},getRadius:function(){var a=this.getBounds(!0);return this.util.length({start:{x:a.x1,y:a.y1},x:a.x2,y:a.y2})},getBounds:function(a){var b=this.points;if(2==b.length){if(a){a=b[0].x;var d=b[0].y;var g=b[1].x;b=b[1].y}else a=b[0].x<b[1].x?b[0].x:b[1].x,d=b[0].y<b[1].y?b[0].y:b[1].y,g=b[0].x<b[1].x?b[1].x:b[0].x,b=b[0].y<b[1].y?b[1].y:b[0].y;return{x1:a,
y1:d,x2:g,y2:b,x:a,y:d,w:g-a,h:b-d}}return{x1:b[0].x,y1:b[0].y,x2:b[2].x,y2:b[2].y,x:b[0].x,y:b[0].y,w:b[2].x-b[0].x,h:b[2].y-b[0].y}},preventNegativePos:function(){if(!this._isBeingModified&&this.points&&this.points.length){if("dojox.drawing.tools.custom.Axes"==this.type){var a=this.marginZero,b=this.marginZero;c.forEach(this.points,function(d){a=Math.min(d.y,a)});c.forEach(this.points,function(d){b=Math.min(d.x,b)});a<this.marginZero&&c.forEach(this.points,function(d,g){d.y+=this.marginZero-a},
this);b<this.marginZero&&c.forEach(this.points,function(d){d.x+=this.marginZero-b},this)}else c.forEach(this.points,function(d){d.x=0>d.x?this.marginZero:d.x;d.y=0>d.y?this.marginZero:d.y});this.setPoints(this.points)}},_onPostRender:function(a){this._isBeingModified&&(this.onModify(this),this._isBeingModified=!1);this.editMode||this.selected||!this._prevData||c.toJson(this._prevData)==c.toJson(this.data)?this._prevData||this.isText&&!this.getText()||(this._prevData=c.clone(this.data)):(this.onChangeData(this),
this._prevData=c.clone(this.data))},_setNodeAtts:function(a){this.util.attr(a,"drawingType",!this.enabled||this.annotation&&"label"!=this.drawingType?"":this.drawingType)},destroy:function(){if(!this.destroyed){if(this.data||this.points&&this.points.length)this.onDelete(this);this.disconnectMouse();this.disconnect(this._cons);c.disconnect(this._postRenderCon);this.remove(this.shape,this.hit);this.destroyed=!0}},remove:function(){var a=arguments;if(!a.length){if(!this.shape)return;a=[this.shape]}for(var b=
0;b<a.length;b++)a[b]&&a[b].removeShape()},connectMult:function(){1<arguments.length?this._cons.push(this.connect.apply(this,arguments)):c.isArray(arguments[0][0])?c.forEach(arguments[0],function(a){this._cons.push(this.connect.apply(this,a))},this):this._cons.push(this.connect.apply(this,arguments[0]))},connect:function(a,b,d,g,m){if("object"!=typeof a)d?(g=d,d=b,b=a,a=this):(g=b,b=a,a=d=this);else if(!g)g=d,d=this;else if(m){var k=c.connect(a,b,function(p){c.hitch(d,g)(p);c.disconnect(k)});this._cons.push(k);
return k}k=c.connect(a,b,d,g);this._cons.push(k);return k},disconnect:function(a){a&&(c.isArray(a)||(a=[a]),c.forEach(a,c.disconnect,c))},connectMouse:function(){this._mouseHandle=this.mouse.register(this)},disconnectMouse:function(){this.mouse.unregister(this._mouseHandle)},render:function(){},dataToPoints:function(a){},pointsToData:function(a){},onDown:function(a){this._downOnCanvas=!0;c.disconnect(this._postRenderCon);this._postRenderCon=null},onMove:function(a){},onDrag:function(a){},onUp:function(a){}});
c.setObject("dojox.drawing.stencil._Base",r);return r});