Merge branch 'master' into tile-fade-in

This commit is contained in:
Éric Lemoine
2012-01-03 08:27:20 +01:00
9 changed files with 189 additions and 107 deletions

View File

@@ -166,6 +166,15 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
*/
dragControl: null,
/**
* APIProperty: irregular
* {Boolean} Make scaling/resizing work irregularly. If true then
* dragging a handle causes the feature to resize in the direction
* of movement. If false then the feature resizes symetrically
* about it's center.
*/
irregular: false,
/**
* Constructor: OpenLayers.Control.TransformFeature
* Create a new transform feature control.
@@ -390,6 +399,10 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
var dy1 = this.y - centerGeometry.y;
var dx0 = dx1 - (this.x - oldGeom.x);
var dy0 = dy1 - (this.y - oldGeom.y);
if (control.irregular && !control._setfeature) {
dx1 -= (this.x - oldGeom.x) / 2;
dy1 -= (this.y - oldGeom.y) / 2;
}
this.x = oldX;
this.y = oldY;
var scale, ratio = 1;
@@ -411,6 +424,13 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
control.box.geometry.resize(scale, centerGeometry, ratio);
control.box.geometry.rotate(control.rotation, centerGeometry);
control.transformFeature({scale: scale, ratio: ratio});
if (control.irregular && !control._setfeature) {
var newCenter = centerGeometry.clone();
newCenter.x += Math.abs(oldX - centerGeometry.x) < 0.00001 ? 0 : (this.x - oldX);
newCenter.y += Math.abs(oldY - centerGeometry.y) < 0.00001 ? 0 : (this.y - oldY);
control.box.geometry.move(this.x - oldX, this.y - oldY);
control.transformFeature({center: newCenter});
}
};
// Override for rotation handle move - make sure that the box and

View File

@@ -1,99 +0,0 @@
/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the Clear BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/Geometry.js
*/
/**
* Class: OpenLayers.Geometry.Rectangle
* This class is *not supported*, and probably isn't what you're looking for.
* Instead, most users probably want something like:
* (code)
* var poly = new OpenLayers.Bounds(0,0,10,10).toGeometry();
* (end)
* This will create a rectangular Polygon geometry.
*
* Inherits:
* - <OpenLayers.Geometry>
*/
OpenLayers.Geometry.Rectangle = OpenLayers.Class(OpenLayers.Geometry, {
/**
* Property: x
* {Float}
*/
x: null,
/**
* Property: y
* {Float}
*/
y: null,
/**
* Property: width
* {Float}
*/
width: null,
/**
* Property: height
* {Float}
*/
height: null,
/**
* Constructor: OpenLayers.Geometry.Rectangle
*
* Parameters:
* points - {Array(<OpenLayers.Geometry.Point>)}
*/
initialize: function(x, y, width, height) {
OpenLayers.Geometry.prototype.initialize.apply(this, arguments);
this.x = x;
this.y = y;
this.width = width;
this.height = height;
},
/**
* Method: calculateBounds
* Recalculate the bounds for the geometry.
*/
calculateBounds: function() {
this.bounds = new OpenLayers.Bounds(this.x, this.y,
this.x + this.width,
this.y + this.height);
},
/**
* APIMethod: getLength
*
* Returns:
* {Float} The length of the geometry
*/
getLength: function() {
var length = (2 * this.width) + (2 * this.height);
return length;
},
/**
* APIMethod: getArea
*
* Returns:
* {Float} The area of the geometry
*/
getArea: function() {
var area = this.width * this.height;
return area;
},
CLASS_NAME: "OpenLayers.Geometry.Rectangle"
});