/*
 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/geometry/screenUtils",["dojo/_base/array","dojo/_base/lang","dojo/sniff","esri/kernel","esri/geometry/Point","esri/geometry/ScreenPoint","esri/geometry/Polyline","esri/geometry/Polygon","esri/geometry/Multipoint","esri/geometry/Extent"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a){function _b(_c,wd,ht,pt,_d){var _e=_c.spatialReference,_f=pt.spatialReference,x=pt.x,y=pt.y,_10;if(_e&&_f&&!_e.equals(_f)&&_e._canProject(_f)){_10=_e.isWebMercator()?_5.lngLatToXY(x,y):_5.xyToLngLat(x,y,true);x=_10[0];y=_10[1];}x=(x-_c.xmin)*(wd/_c.getWidth());y=(_c.ymax-y)*(ht/_c.getHeight());if(!_d){x=Math.round(x);y=Math.round(y);}return new _6(x,y);};function _11(ext,wd,ht,g){var x=ext.xmin,y=ext.ymax,rwd=wd/ext.getWidth(),rht=ht/ext.getHeight(),_12=_1.forEach,_13=Math.round;if(g instanceof _5){return new _5(_13((g.x-x)*rwd),_13((y-g.y)*rht));}else{if(g instanceof _9){var mp=new _9(),mpp=mp.points;_12(g.points,function(pt,i){mpp[i]=[_13((pt[0]-x)*rwd),_13((y-pt[1])*rht)];});return mp;}else{if(g instanceof _a){return new _a(_13((g.xmin-x)*rwd),_13((y-g.ymin)*rht),_13((g.xmax-x)*rwd),_13((y-g.ymax)*rwd));}else{if(g instanceof _7){var _14=new _7(),_15=_14.paths,_16;_12(g.paths,function(_17,i){_16=(_15[i]=[]);_12(_17,function(pt,j){_16[j]=[_13((pt[0]-x)*rwd),_13((y-pt[1])*rht)];});});return _14;}else{if(g instanceof _8){var _18=new _8(),_19=_18.rings,_1a;_12(g.rings,function(_1b,i){_1a=(_19[i]=[]);_12(_1b,function(pt,j){_1a[j]=[_13((pt[0]-x)*rwd),_13((y-pt[1])*rht)];});});return _18;}}}}}};var _1c=(function(){if(_3("ie")<9){return function(x,y,rwd,rht,dx,dy,_1d,_1e,_1f){var _20=[],_21=Math.round,p,pl=_1d.length,_22,_23,_24,pt,x1,y1,x2,y2;for(p=0;p<pl;p++){_22=_1d[p];pt=_1e?_1e(_22[0][0],_22[0][1],_1f):_22[0];if((_24=_22.length)>1){x1=_21(((pt[0]-x)*rwd)+dx);y1=_21(((y-pt[1])*rht)+dy);pt=_1e?_1e(_22[1][0],_22[1][1],_1f):_22[1];x2=_21(((pt[0]-x)*rwd)+dx);y2=_21(((y-pt[1])*rht)+dy);_20.push("M",x1+","+y1,"L",x2+","+y2);for(_23=2;_23<_24;_23++){pt=_1e?_1e(_22[_23][0],_22[_23][1],_1f):_22[_23];x1=_21(((pt[0]-x)*rwd)+dx);y1=_21(((y-pt[1])*rht)+dy);_20.push(x1+","+y1);}}else{x1=_21(((pt[0]-x)*rwd)+dx);y1=_21(((y-pt[1])*rht)+dy);_20.push("M",x1+","+y1);}}return _20;};}else{return function(x,y,rwd,rht,dx,dy,_25,_26,_27){var _28=[],i,j,il,jl,_29,pt,_2a=Math.round;for(i=0,il=_25?_25.length:0;i<il;i++){_29=_25[i];_28.push("M");for(j=0,jl=_29?_29.length:0;j<jl;j++){pt=_26?_26(_29[j][0],_29[j][1],_27):_29[j];_28.push(_2a(((pt[0]-x)*rwd)+dx)+","+_2a(((y-pt[1])*rht)+dy));}}return _28;};}}());function _2b(ext,wd,ht,g,dx,dy){var _2c=g instanceof _7,_2d=ext.spatialReference,_2e=g.spatialReference,_2f,_30;if(_2d&&_2e&&!_2d.equals(_2e)&&_2d._canProject(_2e)){if(_2d.isWebMercator()){_2f=_5.lngLatToXY;}else{_2f=_5.xyToLngLat;_30=true;}}return _1c(ext.xmin,ext.ymax,wd/ext.getWidth(),ht/ext.getHeight(),dx,dy,_2c?g.paths:g.rings,_2f,_30);};function _31(ext,wd,ht,pt){return new _5(ext.xmin+(pt.x/(wd/ext.getWidth())),ext.ymax-(pt.y/(ht/ext.getHeight())),ext.spatialReference);};function _32(ext,wd,ht,g){var x=ext.xmin,y=ext.ymax,sr=ext.spatialReference,rwd=wd/ext.getWidth(),rht=ht/ext.getHeight(),_33=_1.forEach;if(g instanceof _5){return new _5(x+(g.x/rwd),y-(g.y/rht),sr);}else{if(g instanceof _9){var mp=new _9(sr),mpp=mp.points;_33(g.points,function(pt,i){mpp[i]=[x+(pt[0]/rwd),y-(pt[1]/rht)];});return mp;}else{if(g instanceof _a){return new _a(x+(g.xmin/rwd),y-(g.ymin/rht),x+(g.xmax/rwd),y-(g.ymax/rht),sr);}else{if(g instanceof _7){var _34=new _7(sr),_35=_34.paths,_36;_33(g.paths,function(_37,i){_36=(_35[i]=[]);_33(_37,function(pt,j){_36[j]=[x+(pt[0]/rwd),y-(pt[1]/rht)];});});return _34;}else{if(g instanceof _8){var _38=new _8(sr),_39=_38.rings,_3a;_33(g.rings,function(_3b,i){_3a=(_39[i]=[]);_33(_3b,function(pt,j){_3a[j]=[x+(pt[0]/rwd),y-(pt[1]/rht)];});});return _38;}}}}}};var _3c={toScreenPoint:_b,toScreenGeometry:_11,_toScreenPath:_2b,toMapPoint:_31,toMapGeometry:_32};if(_3("extend-esri")){_2.mixin(_2.getObject("geometry",true,_4),_3c);}return _3c;});