//>>built
define("dojox/drawing/annotations/Label",["exports","dojo/_base/lang","../util/oo","../stencil/Text"],function(f,d,g,h){f.Label=g.declare(h,function(a){this.master=a.stencil;this.labelPosition=a.labelPosition||"BR";d.isFunction(this.labelPosition)&&(this.setLabel=this.setLabelCustom);this.setLabel(a.text||"");this.connect(this.master,"onTransform",this,"setLabel");this.connect(this.master,"destroy",this,"destroy");this.style.labelSameColor&&this.connect(this.master,"attr",this,"beforeAttr")},{_align:"start",
drawingType:"label",setLabelCustom:function(a){var b=d.hitch(this.master,this.labelPosition)();this.setData({x:b.x,y:b.y,width:b.w||this.style.text.minWidth,height:b.h||this._lineHeight});a&&!a.split&&(a=this.getText());this.render(this.typesetter(a))},setLabel:function(a){var b=this.master.getBounds();var c=/B/.test(this.labelPosition)?b.y2-this._lineHeight:b.y1;if(/R/.test(this.labelPosition))var e=b.x2;else c=b.y1,this._align="end";!this.labelWidth||a&&a.split&&a!=this.getText()?(this.setData({x:e,
y:c,height:this._lineHeight,width:this.style.text.minWidth}),this.labelWidth=this.style.text.minWidth,this.render(this.typesetter(a))):(this.setData({x:e,y:c,height:this.data.height,width:this.data.width}),this.render())},beforeAttr:function(a,b){if(void 0!==b){var c=a;a={};a[c]=b}delete a.x;delete a.y;delete a.width;delete a.height;this.attr(a);!this.created&&this.render()}})});