//>>built
define("dojox/drawing/stencil/Text",["dojo","../util/oo","./_Base","../manager/_registry","../util/typeset"],function(c,f,g,h,i){f=f.declare(g,function(){},{type:"dojox.drawing.stencil.Text",anchorType:"none",baseRender:!0,align:"start",valign:"top",_lineHeight:1,typesetter:function(a){this._rawText=a;return i.convertLaTeX(a)},setText:function(a){this.enabled&&(a=this.typesetter(a));this._text=a;this._textArray=[];this.created&&this.render(a)},getText:function(){return this._rawText||this._text},
dataToPoints:function(a){var a=a||this.data,b="auto"==a.width?1:a.width,d=a.height||this._lineHeight;return this.points=[{x:a.x,y:a.y},{x:a.x+b,y:a.y},{x:a.x+b,y:a.y+d},{x:a.x,y:a.y+d}]},pointsToData:function(a){var a=a||this.points,b=a[0],a=a[2];return this.data={x:b.x,y:b.y,width:a.x-b.x,height:a.y-b.y}},render:function(a){this.remove(this.shape,this.hit);!this.annotation&&this.renderHit&&this._renderOutline();if(void 0!=a)this._text=a,this._textArray=this._text.split("\n");var a=this.pointsToData(),
b=this._lineHeight,d=a.x+2*this.style.text.pad,e=a.y+this._lineHeight-0.4*this.textSize;"middle"==this.valign&&(e-=b/2);this.shape=this.container.createGroup();c.forEach(this._textArray,function(a,c){this._setNodeAtts(this.shape.createText({x:d,y:e+b*c,text:unescape(a),align:this.align}).setFont(this.style.currentText).setFill(this.style.currentText.color))},this);this._setNodeAtts(this.shape)},_renderOutline:function(){if(!this.annotation){var a=this.pointsToData();"middle"==this.align?a.x-=a.width/
2-2*this.style.text.pad:"start"==this.align?a.x+=this.style.text.pad:"end"==this.align&&(a.x-=a.width-3*this.style.text.pad);"middle"==this.valign&&(a.y-=this._lineHeight/2-this.style.text.pad);this.hit=this.container.createRect(a).setStroke(this.style.currentHit).setFill(this.style.currentHit.fill);this._setNodeAtts(this.hit);this.hit.moveToBack()}},makeFit:function(a,b){var d=c.create("span",{innerHTML:a,id:"foo"},document.body),e=1;c.style(d,"fontSize",e+"px");for(var f=30;c.marginBox(d).w<b&&
!(e++,c.style(d,"fontSize",e+"px"),0>=f--););e--;f=c.marginBox(d);c.destroy(d);return{size:e,box:f}}});c.setObject("dojox.drawing.stencil.Text",f);h.register({name:"dojox.drawing.stencil.Text"},"stencil");return f});