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