//>>built define(["dijit","dojo","dojox","dojo/require!dojo/fx/easing"],function(_1,_2,_3){ _2.provide("dojox.drawing.stencil._Base"); _2.require("dojo.fx.easing"); _3.drawing.stencil._Base=_3.drawing.util.oo.declare(function(_4){ _2.mixin(this,_4); this.style=_4.style||_3.drawing.defaults.copy(); if(_4.stencil){ this.stencil=_4.stencil; this.util=_4.stencil.util; this.mouse=_4.stencil.mouse; this.container=_4.stencil.container; this.style=_4.stencil.style; } var _5=/Line|Vector|Axes|Arrow/; var _6=/Text/; this.shortType=this.util.abbr(this.type); this.isText=_6.test(this.type); this.isLine=_5.test(this.type); this.renderHit=this.style.renderHitLayer; if(!this.renderHit&&this.style.renderHitLines&&this.isLine){ this.renderHit=true; } if(!this.renderHit&&this.style.useSelectedStyle){ this.useSelectedStyle=true; this.selCopy=_2.clone(this.style.selected); for(var nm in this.style.norm){ if(this.style.selected[nm]===undefined){ this.style.selected[nm]=this.style.norm[nm]; } } this.textSelected=_2.clone(this.style.text); this.textSelected.color=this.style.selected.fill; } this.angleSnap=this.style.angleSnap||1; this.marginZero=_4.marginZero||this.style.anchors.marginZero; this.id=_4.id||this.util.uid(this.type); this._cons=[]; if(!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; if(this.isText){ this.align=_4.align||this.align; this.valign=_4.valign||this.valign; if(_4.data&&_4.data.makeFit){ var _7=this.makeFit(_4.data.text,_4.data.width); this.textSize=this.style.text.size=_7.size; this._lineHeight=_7.box.h; }else{ this.textSize=parseInt(this.style.text.size,10); this._lineHeight=this.textSize*1.4; } this.deleteEmptyCreate=_4.deleteEmptyCreate!==undefined?_4.deleteEmptyCreate:this.style.text.deleteEmptyCreate; this.deleteEmptyModify=_4.deleteEmptyModify!==undefined?_4.deleteEmptyModify:this.style.text.deleteEmptyModify; } this.attr(_4.data); if(this.noBaseRender){ return; } if(_4.points){ if(_4.data&&_4.data.closePath===false){ this.closePath=false; } this.setPoints(_4.points); this.connect(this,"render",this,"onRender",true); this.baseRender&&this.enabled&&this.render(); _4.label&&this.setLabel(_4.label); _4.shadow&&this.addShadow(_4.shadow); }else{ if(_4.data){ _4.data.width=_4.data.width?_4.data.width:this.style.text.minWidth; _4.data.height=_4.data.height?_4.data.height:this._lineHeight; this.setData(_4.data); this.connect(this,"render",this,"onRender",true); this.baseRender&&this.enabled&&this.render(_4.data.text); this.baseRender&&_4.label&&this.setLabel(_4.label); this.baseRender&&_4.shadow&&this.addShadow(_4.shadow); }else{ if(this.draws){ this.points=[]; this.data={}; this.connectMouse(); this._postRenderCon=_2.connect(this,"render",this,"_onPostRender"); } } } if(this.showAngle){ this.angleLabel=new _3.drawing.annotations.Angle({stencil:this}); } if(!this.enabled){ this.disable(); this.moveToBack(); this.render(_4.data.text); } },{type:"dojox.drawing.stencil",minimumSize:10,enabled:true,drawingType:"stencil",setData:function(_8){ this.data=_8; this.points=this.dataToPoints(); },setPoints:function(_9){ this.points=_9; if(this.pointsToData){ this.data=this.pointsToData(); } },onDelete:function(_a){ },onBeforeRender:function(_b){ },onModify:function(_c){ },onChangeData:function(_d){ },onChangeText:function(_e){ },onRender:function(_f){ this._postRenderCon=_2.connect(this,"render",this,"_onPostRender"); this.created=true; this.disconnectMouse(); if(this.shape){ this.shape.superClass=this; }else{ this.container.superClass=this; } this._setNodeAtts(this); },onChangeStyle:function(_10){ this._isBeingModified=true; if(!this.enabled){ this.style.current=this.style.disabled; this.style.currentText=this.style.textDisabled; this.style.currentHit=this.style.hitNorm; }else{ this.style.current=this.style.norm; this.style.currentHit=this.style.hitNorm; this.style.currentText=this.style.text; } if(this.selected){ if(this.useSelectedStyle){ this.style.current=this.style.selected; this.style.currentText=this.textSelected; } this.style.currentHit=this.style.hitSelected; }else{ if(this.highlighted){ this.style.currentHit=this.style.hitHighlighted; } } this.render(); },animate:function(_11,_12){ console.warn("ANIMATE.........................."); var d=_11.d||_11.duration||1000; var ms=_11.ms||20; var _13=_11.ease||_2.fx.easing.linear; var _14=_11.steps; var ts=new Date().getTime(); var w=100; var cnt=0; var _15=true; var sp,ep; if(_2.isArray(_11.start)){ sp=_11.start; ep=_11.end; }else{ if(_2.isObject(_11.start)){ sp=_11.start; ep=_11.end; _15=false; }else{ console.warn("No data provided to animate"); } } var v=setInterval(_2.hitch(this,function(){ var t=new Date().getTime()-ts; var p=_13(1-t/d); if(t>d||cnt++>100){ clearInterval(v); return; } if(_15){ var _16=[]; _2.forEach(sp,function(pt,i){ var o={x:(ep[i].x-sp[i].x)*p+sp[i].x,y:(ep[i].y-sp[i].y)*p+sp[i].y}; _16.push(o); }); this.setPoints(_16); this.render(); }else{ var o={}; for(var nm in sp){ o[nm]=(ep[nm]-sp[nm])*p+sp[nm]; } this.attr(o); } }),ms); },attr:function(key,_17){ var n=this.enabled?this.style.norm:this.style.disabled; var t=this.enabled?this.style.text:this.style.textDisabled; var ts=this.textSelected||{},o,nm,_18,_19=_2.toJson(n),_1a=_2.toJson(t); var _1b={x:true,y:true,r:true,height:true,width:true,radius:true,angle:true}; var _1c=false; if(typeof (key)!="object"){ o={}; o[key]=_17; }else{ o=_2.clone(key); } if(o.width){ _18=o.width; delete o.width; } for(nm in o){ if(nm in n){ n[nm]=o[nm]; } if(nm in t){ t[nm]=o[nm]; } if(nm in ts){ ts[nm]=o[nm]; } if(nm in _1b){ _1b[nm]=o[nm]; _1c=true; if(nm=="radius"&&o.angle===undefined){ o.angle=_1b.angle=this.getAngle(); }else{ if(nm=="angle"&&o.radius===undefined){ o.radius=_1b.radius=this.getRadius(); } } } if(nm=="text"){ this.setText(o.text); } if(nm=="label"){ this.setLabel(o.label); } } if(o.borderWidth!==undefined){ n.width=o.borderWidth; } if(this.useSelectedStyle){ for(nm in this.style.norm){ if(this.selCopy[nm]===undefined){ this.style.selected[nm]=this.style.norm[nm]; } } this.textSelected.color=this.style.selected.color; } if(!this.created){ return; } if(o.x!==undefined||o.y!==undefined){ var box=this.getBounds(true); var mx={dx:0,dy:0}; for(nm in o){ if(nm=="x"||nm=="y"||nm=="r"){ mx["d"+nm]=o[nm]-box[nm]; } } this.transformPoints(mx); } var p=this.points; if(o.angle!==undefined){ this.dataToPoints({x:this.data.x1,y:this.data.y1,angle:o.angle,radius:o.radius}); }else{ if(_18!==undefined){ p[1].x=p[2].x=p[0].x+_18; this.pointsToData(p); } } if(o.height!==undefined&&o.angle===undefined){ p[2].y=p[3].y=p[0].y+o.height; this.pointsToData(p); } if(o.r!==undefined){ this.data.r=Math.max(0,o.r); } if(_1c||_1a!=_2.toJson(t)||_19!=_2.toJson(n)){ this.onChangeStyle(this); } o.width=_18; if(o.cosphi!=undefined){ !this.data?this.data={cosphi:o.cosphi}:this.data.cosphi=o.cosphi; this.style.zAxis=o.cosphi!=0?true:false; } },exporter:function(){ var _1d=this.type.substring(this.type.lastIndexOf(".")+1).charAt(0).toLowerCase()+this.type.substring(this.type.lastIndexOf(".")+2); var o=_2.clone(this.style.norm); o.borderWidth=o.width; delete o.width; if(_1d=="path"){ o.points=this.points; }else{ o=_2.mixin(o,this.data); } o.type=_1d; if(this.isText){ o.text=this.getText(); o=_2.mixin(o,this.style.text); delete o.minWidth; delete o.deleteEmptyCreate; delete o.deleteEmptyModify; } var lbl=this.getLabel(); if(lbl){ o.label=lbl; } return o; },disable:function(){ this.enabled=false; this.renderHit=false; this.onChangeStyle(this); },enable:function(){ this.enabled=true; this.renderHit=true; this.onChangeStyle(this); },select:function(){ this.selected=true; this.onChangeStyle(this); },deselect:function(_1e){ if(_1e){ setTimeout(_2.hitch(this,function(){ this.selected=false; this.onChangeStyle(this); }),200); }else{ this.selected=false; this.onChangeStyle(this); } },_toggleSelected:function(){ if(!this.selected){ return; } this.deselect(); setTimeout(_2.hitch(this,"select"),0); },highlight:function(){ this.highlighted=true; this.onChangeStyle(this); },unhighlight:function(){ this.highlighted=false; this.onChangeStyle(this); },moveToFront:function(){ this.container&&this.container.moveToFront(); },moveToBack:function(){ this.container&&this.container.moveToBack(); },onTransformBegin:function(_1f){ this._isBeingModified=true; },onTransformEnd:function(_20){ this._isBeingModified=false; this.onModify(this); },onTransform:function(_21){ if(!this._isBeingModified){ this.onTransformBegin(); } this.setPoints(this.points); this.render(); },transformPoints:function(mx){ if(!mx.dx&&!mx.dy){ return; } var _22=_2.clone(this.points),_23=false; _2.forEach(this.points,function(o){ o.x+=mx.dx; o.y+=mx.dy; if(o.x1){ this._cons.push(this.connect.apply(this,arguments)); }else{ if(_2.isArray(arguments[0][0])){ _2.forEach(arguments[0],function(ar){ this._cons.push(this.connect.apply(this,ar)); },this); }else{ this._cons.push(this.connect.apply(this,arguments[0])); } } },connect:function(o,e,s,m,_2d){ var c; if(typeof (o)!="object"){ if(s){ m=s; s=e; e=o; o=this; }else{ m=e; e=o; o=s=this; } }else{ if(!m){ m=s; s=this; }else{ if(_2d){ c=_2.connect(o,e,function(evt){ _2.hitch(s,m)(evt); _2.disconnect(c); }); this._cons.push(c); return c; }else{ } } } c=_2.connect(o,e,s,m); this._cons.push(c); return c; },disconnect:function(_2e){ if(!_2e){ return; } if(!_2.isArray(_2e)){ _2e=[_2e]; } _2.forEach(_2e,_2.disconnect,_2); },connectMouse:function(){ this._mouseHandle=this.mouse.register(this); },disconnectMouse:function(){ this.mouse.unregister(this._mouseHandle); },render:function(){ },dataToPoints:function(_2f){ },pointsToData:function(_30){ },onDown:function(obj){ this._downOnCanvas=true; _2.disconnect(this._postRenderCon); this._postRenderCon=null; },onMove:function(obj){ },onDrag:function(obj){ },onUp:function(obj){ }}); });