//>>built
define("demos/sunMap/src/SunDemo",["dojo/_base/declare","dojo/_base/html","dojo/_base/lang","dojo/_base/connect","dojo/date","./Sun","dojox/geo/openlayers/widget/Map","dojox/timing/_base","dojox/geo/openlayers/GfxLayer","dojox/geo/openlayers/GeometryFeature","dojox/geo/openlayers/LineString","dojox/geo/openlayers/Point","dojox/geo/openlayers/JsonImport","./Cities"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e){return _1("dojox.geo.openlayers.tests.sun.SunDemo",null,{now:true,map:null,cities:null,layer:null,sun:null,constructor:function(_f){var _10={name:"TheMap",touchHandler:true};var map=new _7(_10,_f);map.startup();this.map=map;map.map.fitTo([-160,70,160,-70]);var _11=new _e(this);_4.connect(this,"updateFeatures",_11,"updateCities");this.cities=_11;this.sun=new _6();var _12=new _9("sun");this.layer=_12;map.map.addLayer(_12);this.updateFeatures();},showGradients:function(grd){return this.cities.useGradients(grd);},showCircles:function(c){return this.cities.useCircles(c);},showTooltips:function(tt){var map=this.map.map;var ls=map.getLayer("name","sun")[0];var lc=map.getLayer("name","cities")[0];var is=map.layerIndex(ls);var ic=map.layerIndex(lc);var m=Math.min(is,ic);var M=Math.max(is,ic);if(tt){map.layerIndex(ls,m);map.layerIndex(lc,M);}else{map.layerIndex(ls,M);map.layerIndex(lc,m);}},updateFeatures:function(){var l=this.layer;l.removeFeature(l.getFeatures());var f=this.twilightZone({x1:-180,y1:85,x2:180,y2:-85});l.addFeature(f);f=this.createStar();l.addFeature(f);f=this.createSun();l.addFeature(f);l.redraw();},getHour:function(d){if(!d){d=this.sun.getDate();}return d.getHours()+d.getMinutes()/60+d.getSeconds()/3600;},getDay:function(d){if(!d){d=this.sun.getDate();}var _13=new Date(d.getFullYear(),0,1);var _14=1000*60*60*24;var day=Math.floor((d.getTime()-_13.getTime())/_14);return day;},setDay:function(day){var now=this.sun.getDate();var _15=now.getFullYear();var _16=now.getHours();var _17=now.getMinutes();var _18=now.getSeconds();var _19=now.getMilliseconds();var _1a=new Date(_15,0,1,_16,_17,_18,_19);_1a=_5.add(_1a,"day",day);this.setDate(_1a);},setTime:function(t){var d=this.sun.getDate();var _1b=d.getFullYear();var _1c=d.getMonth();var day=d.getDate();var _1d=Math.floor(t);t=60*(t-_1d);var _1e=Math.floor(t);t=60*(t-_1e);var _1f=Math.floor(t);d=new Date(_1b,_1c,day,_1d,_1e,_1f,0);this.setDate(d);},setDate:function(d){this.now=!d;this.sun.setDate(d);this.updateFeatures();},advance:function(ms){var d=this.sun.getDate();d=_5.add(d,"millisecond",ms);this.setDate(d);},getTZone:function(){return this.tZone;},twilightZone:function(_20){var tz=this.sun.twilightZone(_20);var g=new _b(tz);var gf=new _a(g);gf.setStroke([248,236,56]);gf.setFill([252,251,45,0.3]);this.tZone=gf;return gf;},makeStarShape:function(r1,r2,b){var TPI=Math.PI*2;var di=TPI/b;var s=null;var _21=Math.PI;var end=_21+TPI;for(var i=_21;i<end;i+=di){var c1=Math.cos(i);var s1=Math.sin(i);var i2=i+di/2;var c2=Math.cos(i2);var s2=Math.sin(i2);if(s==null){s="M"+(s1*r1).toFixed(2)+","+(c1*r1).toFixed(2)+" ";}else{s+="L"+(s1*r1).toFixed(2)+","+(c1*r1).toFixed(2)+" ";}s+="L"+(s2*r2).toFixed(2)+","+(c2*r2).toFixed(2)+" ";}s+="z";return s;},createStar:function(){var s=this.sun.sun();var _22=new _c(s);var gf=new _a(_22);gf.createShape=_3.hitch(this,function(s){var r1=30;var r2=10;var _23=7;var _24=this.makeStarShape(r1,r2,_23);var _25=s.createPath();_25.setShape({path:_24});_25.setStroke([0,100,0]);_25.setFill([0,100,0]);return _25;});return gf;},makeCrossShape:function(r1,r2,b){var TPI=Math.PI*2;var di=TPI/b;var s="";for(var i=0;i<TPI;i+=di){var c1=Math.cos(i);var s1=Math.sin(i);var i2=i+Math.PI;var c2=Math.cos(i2);var s2=Math.sin(i2);s+="M"+(s1*r1).toFixed(2)+","+(c1*r1).toFixed(2)+" ";s+="L"+(s2*r1).toFixed(2)+","+(c2*r1).toFixed(2)+" ";}return s;},createSun:function(){var s=this.sun.sun();var g=new _c({x:s.x,y:s.y});var gf=new _a(g);var _26=20;gf.setShapeProperties({r:_26});gf.setStroke("");gf.setFill({type:"radial",r:_26,colors:[{offset:0,color:[248,236,100]},{offset:1,color:[255,127,0]}]});return gf;},_timer:null,startTimer:function(_27,_28){var t=this._timer;if(!this._timer){if(!_28){_28=1000;}t=this._timer=new dojox.timing.Timer(_28);t.onTick=_3.hitch(this,function(){if(this.now){this.setDate();}else{this.advance(_28);}});t.onStart=function(){};t.onStop=function(){};}if(_27){t.start();}else{t.stop();}}});});