text: /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
   * full list of contributors). Published under the 2-clause BSD license.
   * See license.txt in the OpenLayers distribution or repository for the
   * full text of the license. */
  
  OpenLayers.Control.TransformFeature=OpenLayers.Class(OpenLayers.Control,{geometryTypes:null,layer:null,preserveAspectRatio:!1,rotate:!0,feature:null,renderIntent:"temporary",rotationHandleSymbolizer:null,box:null,center:null,scale:1,ratio:1,rotation:0,handles:null,rotationHandles:null,dragControl:null,irregular:!1,initialize:function(e,t){OpenLayers.Control.prototype.initialize.apply(this,[t]),this.layer=e,this.rotationHandleSymbolizer||(this.rotationHandleSymbolizer={stroke:!1,pointRadius:10,fillOpacity:0,cursor:"pointer"}),this.createBox(),this.createControl()},activate:function(){var e=!1;return OpenLayers.Control.prototype.activate.apply(this,arguments)&&(this.dragControl.activate(),this.layer.addFeatures([this.box]),this.rotate&&this.layer.addFeatures(this.rotationHandles),this.layer.addFeatures(this.handles),e=!0),e},deactivate:function(){var e=!1;return OpenLayers.Control.prototype.deactivate.apply(this,arguments)&&(this.layer.removeFeatures(this.handles),this.rotate&&this.layer.removeFeatures(this.rotationHandles),this.layer.removeFeatures([this.box]),this.dragControl.deactivate(),e=!0),e},setMap:function(e){this.dragControl.setMap(e),OpenLayers.Control.prototype.setMap.apply(this,arguments)},setFeature:function(e,t){t=OpenLayers.Util.applyDefaults(t,{rotation:0,scale:1,ratio:1});var n=this.rotation,r=this.center;OpenLayers.Util.extend(this,t);var i=this.events.triggerEvent("beforesetfeature",{feature:e});if(i===!1)return;this.feature=e,this.activate(),this._setfeature=!0;var s=this.feature.geometry.getBounds();this.box.move(s.getCenterLonLat()),this.box.geometry.rotate(-n,r),this._angle=0;var o;if(this.rotation){var u=e.geometry.clone();u.rotate(-this.rotation,this.center);var a=new OpenLayers.Feature.Vector(u.getBounds().toGeometry());a.geometry.rotate(this.rotation,this.center),this.box.geometry.rotate(this.rotation,this.center),this.box.move(a.geometry.getBounds().getCenterLonLat());var f=a.geometry.components[0].components[0];o=f.getBounds().getCenterLonLat()}else o=new OpenLayers.LonLat(s.left,s.bottom);this.handles[0].move(o),delete this._setfeature,this.events.triggerEvent("setfeature",{feature:e})},unsetFeature:function(){this.active?this.deactivate():(this.feature=null,this.rotation=0,this.scale=1,this.ratio=1)},createBox:function(){var e=this;this.center=new OpenLayers.Geometry.Point(0,0),this.box=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString([new OpenLayers.Geometry.Point(-1,-1),new OpenLayers.Geometry.Point(0,-1),new OpenLayers.Geometry.Point(1,-1),new OpenLayers.Geometry.Point(1,0),new OpenLayers.Geometry.Point(1,1),new OpenLayers.Geometry.Point(0,1),new OpenLayers.Geometry.Point(-1,1),new OpenLayers.Geometry.Point(-1,0),new OpenLayers.Geometry.Point(-1,-1)]),null,typeof this.renderIntent=="string"?null:this.renderIntent),this.box.geometry.move=function(t,n){e._moving=!0,OpenLayers.Geometry.LineString.prototype.move.apply(this,arguments),e.center.move(t,n),delete e._moving};var t=function(e,t){OpenLayers.Geometry.Point.prototype.move.apply(this,arguments),this._rotationHandle&&this._rotationHandle.geometry.move(e,t),this._handle.geometry.move(e,t)},n=function(e,t,n){OpenLayers.Geometry.Point.prototype.resize.apply(this,arguments),this._rotationHandle&&this._rotationHandle.geometry.resize(e,t,n),this._handle.geometry.resize(e,t,n)},r=function(e,t){OpenLayers.Geometry.Point.prototype.rotate.apply(this,arguments),this._rotationHandle&&this._rotationHandle.geometry.rotate(e,t),this._handle.geometry.rotate(e,t)},i=function(t,n){var r=this.x,i=this.y;OpenLayers.Geometry.Point.prototype.move.call(this,t,n);if(e._moving)return;var s=e.dragControl.handlers.drag.evt,o=!e._setfeature&&e.preserveAspectRatio,u=!o&&(!s||!s.shiftKey),a=new OpenLayers.Geometry.Point(r,i),f=e.center;this.rotate(-e.rotation,f),a.rotate(-e.rotation,f);var l=this.x-f.x,c=this.y-f.y,h=l-(this.x-a.x),p=c-(this.y-a.y);e.irregular&&!e._setfeature&&(l-=(this.x-a.x)/2,c-=(this.y-a.y)/2),this.x=r,this.y=i;var d,v=1;if(u)d=Math.abs(p)<1e-5?1:c/p,v=(Math.abs(h)<1e-5?1:l/h)/d;else{var m=Math.sqrt(h*h+p*p),g=Math.sqrt(l*l+c*c);d=g/m}e._moving=!0,e.box.geometry.rotate(-e.rotation,f),delete e._moving,e.box.geometry.resize(d,f,v),e.box.geometry.rotate(e.rotation,f),e.transformFeature({scale:d,ratio:v});if(e.irregular&&!e._setfeature){var y=f.clone();y.x+=Math.abs(r-f.x)<1e-5?0:this.x-r,y.y+=Math.abs(i-f.y)<1e-5?0:this.y-i,e.box.geometry.move(this.x-r,this.y-i),e.transformFeature({center:y})}},s=function(t,n){var r=this.x,i=this.y;OpenLayers.Geometry.Point.prototype.move.call(this,t,n);if(e._moving)return;var s=e.dragControl.handlers.drag.evt,o=s&&s.shiftKey?45:1,u=e.center,a=this.x-u.x,f=this.y-u.y,l=a-t,c=f-n;this.x=r,this.y=i;var h=Math.atan2(c,l),p=Math.atan2(f,a),d=p-h;d*=180/Math.PI,e._angle=(e._angle+d)%360;var v=e.rotation%o;if(Math.abs(e._angle)>=o||v!==0)d=Math.round(e._angle/o)*o-v,e._angle=0,e.box.geometry.rotate(d,u),e.transformFeature({rotation:d})},o=new Array(8),u=new Array(4),a,f,l,c=["sw","s","se","e","ne","n","nw","w"];for(var h=0;h<8;++h)a=this.box.geometry.components[h],f=new OpenLayers.Feature.Vector(a.clone(),{role:c[h]+"-resize"},typeof this.renderIntent=="string"?null:this.renderIntent),h%2==0&&(l=new OpenLayers.Feature.Vector(a.clone(),{role:c[h]+"-rotate"},typeof this.rotationHandleSymbolizer=="string"?null:this.rotationHandleSymbolizer),l.geometry.move=s,a._rotationHandle=l,u[h/2]=l),a.move=t,a.resize=n,a.rotate=r,f.geometry.move=i,a._handle=f,o[h]=f;this.rotationHandles=u,this.handles=o},createControl:function(){var e=this;this.dragControl=new OpenLayers.Control.DragFeature(this.layer,{documentDrag:!0,moveFeature:function(t){this.feature===e.feature&&(this.feature=e.box),OpenLayers.Control.DragFeature.prototype.moveFeature.apply(this,arguments)},onDrag:function(t,n){t===e.box&&e.transformFeature({center:e.center})},onStart:function(t,n){var r=!e.geometryTypes||OpenLayers.Util.indexOf(e.geometryTypes,t.geometry.CLASS_NAME)!==-1,i=OpenLayers.Util.indexOf(e.handles,t);i+=OpenLayers.Util.indexOf(e.rotationHandles,t),t!==e.feature&&t!==e.box&&i==-2&&r&&e.setFeature(t)},onComplete:function(t,n){e.events.triggerEvent("transformcomplete",{feature:e.feature})}})},drawHandles:function(){var e=this.layer;for(var t=0;t<8;++t)this.rotate&&t%2===0&&e.drawFeature(this.rotationHandles[t/2],this.rotationHandleSymbolizer),e.drawFeature(this.handles[t],this.renderIntent)},transformFeature:function(e){if(!this._setfeature){this.scale*=e.scale||1,this.ratio*=e.ratio||1;var t=this.rotation;this.rotation=(this.rotation+(e.rotation||0))%360;if(this.events.triggerEvent("beforetransform",e)!==!1){var n=this.feature,r=n.geometry,i=this.center;r.rotate(-t,i),e.scale||e.ratio?r.resize(e.scale,i,e.ratio):e.center&&n.move(e.center.getBounds().getCenterLonLat()),r.rotate(this.rotation,i),this.layer.drawFeature(n),n.toState(OpenLayers.State.UPDATE),this.events.triggerEvent("transform",e)}}this.layer.drawFeature(this.box,this.renderIntent),this.drawHandles()},destroy:function(){var e;for(var t=0;t<8;++t)e=this.box.geometry.components[t],e._handle.destroy(),e._handle=null,e._rotationHandle&&e._rotationHandle.destroy(),e._rotationHandle=null;this.center=null,this.feature=null,this.handles=null,this.rotationHandleSymbolizer=null,this.rotationHandles=null,this.box.destroy(),this.box=null,this.layer=null,this.dragControl.destroy(),this.dragControl=null,OpenLayers.Control.prototype.destroy.apply(this,arguments)},CLASS_NAME:"OpenLayers.Control.TransformFeature"});