diff --git a/src/text/PointText.js b/src/text/PointText.js index f73c30db..699a101b 100644 --- a/src/text/PointText.js +++ b/src/text/PointText.js @@ -37,9 +37,8 @@ var PointText = this.PointText = TextItem.extend(/** @lends PointText# */{ */ initialize: function(point) { this.base(); - point = Point.read(arguments); - this._point = LinkedPoint.create(this, 'setPoint', point.x, point.y); - this._matrix = new Matrix().translate(point); + this._point = Point.read(arguments).clone(); + this._matrix = new Matrix().translate(this._point); }, clone: function() { @@ -56,13 +55,10 @@ var PointText = this.PointText = TextItem.extend(/** @lends PointText# */{ * @bean */ getPoint: function() { - // this._point is a LinkedPoint, so we can use _x and _y. - // Do not cache LinkedPoints directly, since we would not be able to - // use them to calculate the difference in #setPoint, as when it is - // modified, it would hold new values already and only then cause the - // calling of #setPoint. - return LinkedPoint.create(this, 'setPoint', this._point._x, - this._point._y); + // Se Item#getPosition for an explanation why we create new LinkedPoint + // objects each time. + return LinkedPoint.create(this, 'setPoint', + this._point.x, this._point.y); }, setPoint: function(point) { @@ -72,7 +68,8 @@ var PointText = this.PointText = TextItem.extend(/** @lends PointText# */{ }, // TODO: Position should be the center point of the bounds but we currently - // don't support bounds for PointText. + // don't support bounds for PointText, so let's return the same as #point + // for the time being. getPosition: function() { return this.getPoint(); }, @@ -83,10 +80,8 @@ var PointText = this.PointText = TextItem.extend(/** @lends PointText# */{ _transform: function(matrix, flags) { this._matrix.preConcatenate(matrix); - // We need to transform the LinkedPoint, passing true for dontNotify so - // chaning it won't trigger calls of setPoint(), leading to an endless - // recursion. - matrix._transformPoint(this._point, this._point, true); + // Also transform _point: + matrix._transformPoint(this._point, this._point); }, draw: function(ctx) {