//>>built
define("dojox/dgauges/CircularScale",["dojo/_base/declare","dojox/gfx","./ScaleBase","./_circularUtils"],function(t,r,u,l){return t("dojox.dgauges.CircularScale",u,{originX:50,originY:50,radius:50,startAngle:0,endAngle:180,orientation:"clockwise",constructor:function(){this.labelPosition="inside";this.addInvalidatingProperties("originX originY radius startAngle endAngle orientation".split(" "))},_getOrientationNum:function(){return"cclockwise"==this.orientation?-1:1},positionForValue:function(a){var b=
l.computeTotalAngle(this.startAngle,this.endAngle,this.orientation);a=this.scaler.positionForValue(a);return l.modAngle(this.startAngle+this._getOrientationNum()*b*a,360)},_positionForTickItem:function(a){var b=l.computeTotalAngle(this.startAngle,this.endAngle,this.orientation);return l.modAngle(this.startAngle+this._getOrientationNum()*b*a.position,360)},valueForPosition:function(a){if(this.positionInRange(a)){var b=l.modAngle(this._getOrientationNum()*(a-this.startAngle),360),d=l.computeTotalAngle(this.startAngle,
this.endAngle,this.orientation);b/=d}else b=l.modAngle(this.startAngle-a,360),d=360-b,a=l.modAngle(this.endAngle-a,360),b=Math.min(b,d)<Math.min(a,360-a)?0:1;return this.scaler.valueForPosition(b)},positionInRange:function(a){if(this.startAngle==this.endAngle)return!0;a=l.modAngle(a,360);return 1==this._getOrientationNum()?this.startAngle<this.endAngle?a>=this.startAngle&&a<=this.endAngle:!(a>this.endAngle&&a<this.startAngle):this.startAngle<this.endAngle?!(a>this.startAngle&&a<this.endAngle):a>=
this.endAngle&&a<=this.startAngle},_distance:function(a,b,d,e){return Math.sqrt((d-a)*(d-a)+(e-b)*(e-b))},_layoutLabel:function(a,b,d,e,m,f,h){var k=this._getFont();b=r._base._getTextBox(b,{font:r.makeFontString(r.makeParameters(r.defaultFont,k))}).w;k=r.normalizedLength(k.size);var n=d+Math.cos(f)*m-b/2,p=e-Math.sin(f)*m-k/2,q=[];var c=n;var g=-Math.tan(f)*c+e+Math.tan(f)*d;g>=p&&g<=p+k&&q.push({x:c,y:g});c=n+b;g=-Math.tan(f)*c+e+Math.tan(f)*d;g>=p&&g<=p+k&&q.push({x:c,y:g});c=p;g=-1/Math.tan(f)*
c+d+1/Math.tan(f)*e;g>=n&&g<=n+b&&q.push({x:g,y:c});c=p+k;g=-1/Math.tan(f)*c+d+1/Math.tan(f)*e;g>=n&&g<=n+b&&q.push({x:g,y:c});if("inside"==h)for(h=0;h<q.length;h++){if(c=q[h],c=this._distance(c.x,c.y,d,e)-m,0<=c){n=d+Math.cos(f)*(m-c)-b/2;p=e-Math.sin(f)*(m-c)-k/2;break}}else for(h=0;h<q.length;h++)if(c=q[h],c=this._distance(c.x,c.y,d,e)-m,0>=c){n=d+Math.cos(f)*(m-c)-b/2;p=e-Math.sin(f)*(m-c)-k/2;break}a&&a.setTransform([{dx:n+b/2,dy:p+k}])},refreshRendering:function(){this.inherited(arguments);
if(this._gfxGroup&&this.scaler){this.startAngle=l.modAngle(this.startAngle,360);this.endAngle=l.modAngle(this.endAngle,360);this._ticksGroup.clear();for(var a,b,d=this.scaler.computeTicks(),e,m=0;m<d.length;m++){b=d[m];a=this.tickShapeFunc(this._ticksGroup,this,b);e=this._gauge._computeBoundingBox(a);var f=b.position?this._positionForTickItem(b):this.positionForValue(b.value);a&&a.setTransform([{dx:this.originX,dy:this.originY},r.matrix.rotateg(f),{dx:this.radius-e.width-2*e.x,dy:0}]);if(b=this.tickLabelFunc(b)){a=
this._ticksGroup.createText({x:0,y:0,text:b,align:"middle"}).setFont(this._getFont()).setFill(this._getFont().color?this._getFont().color:"black");var h=this.radius;h="inside"==this.labelPosition?h-(e.width+this.labelGap):h+this.labelGap;this._layoutLabel(a,b,this.originX,this.originY,h,l.toRadians(360-f),this.labelPosition)}}for(var k in this._indicatorsIndex)this._indicatorsRenderers[k]=this._indicatorsIndex[k].invalidateRendering()}}})});