/*
	Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


window[esri._dojoScopeName||"dojo"]._xdResourceLoaded(function(_1,_2,_3){return {depends:[["provide","dojox.drawing.stencil.Text"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["dojox.drawing.stencil.Text"]){_4._hasResource["dojox.drawing.stencil.Text"]=true;_4.provide("dojox.drawing.stencil.Text");_6.drawing.stencil.Text=_6.drawing.util.oo.declare(_6.drawing.stencil._Base,function(_7){},{type:"dojox.drawing.stencil.Text",anchorType:"none",baseRender:true,align:"start",valign:"top",_lineHeight:1,typesetter:function(_8){if(_6.drawing.util.typeset){this._rawText=_8;return _6.drawing.util.typeset.convertLaTeX(_8);}return _8;},setText:function(_9){if(this.enabled){_9=this.typesetter(_9);}this._text=_9;this._textArray=[];this.created&&this.render(_9);},getText:function(){return this._rawText||this._text;},dataToPoints:function(o){o=o||this.data;var w=o.width=="auto"?1:o.width;var h=o.height||this._lineHeight;this.points=[{x:o.x,y:o.y},{x:o.x+w,y:o.y},{x:o.x+w,y:o.y+h},{x:o.x,y:o.y+h}];return this.points;},pointsToData:function(p){p=p||this.points;var s=p[0];var e=p[2];this.data={x:s.x,y:s.y,width:e.x-s.x,height:e.y-s.y};return this.data;},render:function(_a){this.remove(this.shape,this.hit);!this.annotation&&this.renderHit&&this._renderOutline();if(_a!=undefined){this._text=_a;this._textArray=this._text.split("\n");}var d=this.pointsToData();var h=this._lineHeight;var x=d.x+this.style.text.pad*2;var y=d.y+this._lineHeight-(this.textSize*0.4);if(this.valign=="middle"){y-=h/2;}this.shape=this.container.createGroup();_4.forEach(this._textArray,function(_b,i){var tb=this.shape.createText({x:x,y:y+(h*i),text:unescape(_b),align:this.align}).setFont(this.style.currentText).setFill(this.style.currentText.color);this._setNodeAtts(tb);},this);this._setNodeAtts(this.shape);},_renderOutline:function(){if(this.annotation){return;}var d=this.pointsToData();if(this.align=="middle"){d.x-=d.width/2-this.style.text.pad*2;}else{if(this.align=="start"){d.x+=this.style.text.pad;}else{if(this.align=="end"){d.x-=d.width-this.style.text.pad*3;}}}if(this.valign=="middle"){d.y-=(this._lineHeight)/2-this.style.text.pad;}this.hit=this.container.createRect(d).setStroke(this.style.currentHit).setFill(this.style.currentHit.fill);this._setNodeAtts(this.hit);this.hit.moveToBack();},makeFit:function(_c,w){var _d=_4.create("span",{innerHTML:_c,id:"foo"},document.body);var sz=1;_4.style(_d,"fontSize",sz+"px");var _e=30;while(_4.marginBox(_d).w<w){sz++;_4.style(_d,"fontSize",sz+"px");if(_e--<=0){break;}}sz--;var _f=_4.marginBox(_d);_4.destroy(_d);return {size:sz,box:_f};}});_6.drawing.register({name:"dojox.drawing.stencil.Text"},"stencil");}}};});