/*
 COPYRIGHT 2009 ESRI

 TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
 Unpublished material - all rights reserved under the
 Copyright Laws of the United States and applicable international
 laws, treaties, and conventions.

 For additional information, contact:
 Environmental Systems Research Institute, Inc.
 Attn: Contracts and Legal Services Department
 380 New York Street
 Redlands, California, 92373
 USA

 email: contracts@esri.com
 */
//>>built
define("esri/renderers/ClassBreaksRenderer",["dojo/_base/declare","dojo/_base/array","dojo/_base/lang","dojo/has","esri/kernel","esri/lang","esri/symbols/jsonUtils","esri/renderers/Renderer"],function(_1,_2,_3,_4,_5,_6,_7,_8){var _9=_1(_8,{declaredClass:"esri.renderer.ClassBreaksRenderer",constructor:function(_a,_b){this.breaks=[];this._symbols={};this.infos=[];if(_a&&!_a.declaredClass){var _c=_a;this.attributeField=_c.field;_a=_c.defaultSymbol;if(_a){this.defaultSymbol=_7.fromJson(_a);}this._copy(["defaultLabel","classificationMethod:rest","normalizationType:rest","normalizationField","normalizationTotal"],_c,this);var _d=_c.minValue,_e=_c.classBreakInfos;if(_e&&_e[0]&&_6.isDefined(_e[0].classMaxValue)){_2.forEach(_e,function(_f){var _10=_f.classMaxValue;_f.minValue=_d;_f.maxValue=_10;_d=_10;},this);}_2.forEach(_e,this._addBreakInfo,this);}else{this.defaultSymbol=_a;this.attributeField=_b;}},addBreak:function(min,max,_11){var _12=_3.isObject(min)?min:{minValue:min,maxValue:max,symbol:_11};this._addBreakInfo(_12);},removeBreak:function(min,max){var _13,_14=this.breaks,i,il=_14.length,_15=this._symbols;for(i=0;i<il;i++){_13=_14[i];if(_13[0]==min&&_13[1]==max){_14.splice(i,1);delete _15[min+"-"+max];this.infos.splice(i,1);break;}}},clearBreaks:function(){this.breaks=[];this._symbols={};this.infos=[];},getSymbol:function(_16){var _17=this.attributeField,_18=_16.attributes,val,rs=this.breaks,i,il=rs.length,_19=this._symbols,_1a,_1b=this.isMaxInclusive;if(_3.isFunction(_17)){val=_17(_16);}else{val=parseFloat(_18[_17]);var _1c=this.normalizationType,_1d,_1e;if(_1c){_1d=parseFloat(this.normalizationTotal);_1e=parseFloat(_18[this.normalizationField]);if(_1c==="log"){val=Math.log(val)*Math.LOG10E;}else{if(_1c==="percent-of-total"&&!isNaN(_1d)){val=(val/_1d)*100;}else{if(_1c==="field"&&!isNaN(_1e)){val=val/_1e;}}}}}for(i=0;i<il;i++){_1a=rs[i];if(_1a[0]<=val&&(_1b?(val<=_1a[1]):(val<_1a[1]))){return _19[_1a[0]+"-"+_1a[1]];}}return this.defaultSymbol;},setMaxInclusive:function(_1f){this.isMaxInclusive=_1f;},_normalizationTypeEnums:[["field","esriNormalizeByField"],["log","esriNormalizeByLog"],["percent-of-total","esriNormalizeByPercentOfTotal"]],_classificationMethodEnums:[["natural-breaks","esriClassifyNaturalBreaks"],["equal-interval","esriClassifyEqualInterval"],["quantile","esriClassifyQuantile"],["standard-deviation","esriClassifyStandardDeviation"],["geometrical-interval","esriClassifyGeometricalInterval"]],_copy:function(_20,_21,_22){_2.forEach(_20,function(key){var _23=key.split(":"),_24,_25,_26,_27;if(_23.length>1){key=_23[0];_24=this["_"+key+"Enums"];if(_23[1]==="rest"){_25="1";_26="0";}else{if(_23[1]==="sdk"){_25="0";_26="1";}}}_27=_21[key];if(_27!==undefined){_22[key]=_27;if(_24&&_25){var i,len=_24.length;for(i=0;i<len;i++){if(_24[i][_25]===_27){_22[key]=_24[i][_26];break;}}}}},this);},_addBreakInfo:function(_28){var min=_28.minValue,max=_28.maxValue;this.breaks.push([min,max]);this.infos.push(_28);var _29=_28.symbol;if(_29){if(!_29.declaredClass){_28.symbol=_7.fromJson(_29);}}this._symbols[min+"-"+max]=_28.symbol;},toJson:function(){var _2a=this.infos||[],_2b=_6.fixJson,_2c=_2a[0]&&_2a[0].minValue,_2d={type:"classBreaks",field:this.attributeField,defaultSymbol:this.defaultSymbol&&this.defaultSymbol.toJson(),minValue:(_2c===-Infinity)?-Number.MAX_VALUE:_2c,classBreakInfos:_2.map(_2a,function(_2e){_2e=_3.mixin({},_2e);_2e.symbol=_2e.symbol&&_2e.symbol.toJson();_2e.classMaxValue=(_2e.maxValue===Infinity)?Number.MAX_VALUE:_2e.maxValue;delete _2e.minValue;delete _2e.maxValue;return _2b(_2e);})};this._copy(["defaultLabel","classificationMethod:sdk","normalizationType:sdk","normalizationField","normalizationTotal"],this,_2d);return _2b(_2d);}});if(_4("extend-esri")){_3.setObject("renderer.ClassBreaksRenderer",_9,_5);}return _9;});