Move #matrix accessor from PlacedItem to Item.

This commit is contained in:
Jürg Lehni 2011-11-29 17:19:31 +01:00
parent 5ff3a07b31
commit cf4c2b4919
2 changed files with 18 additions and 16 deletions

View file

@ -212,6 +212,23 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
this._changed(ChangeFlag.ATTRIBUTE);
},
/**
* The item's transformation matrix, defining position and dimensions in the
* document.
*
* @type Matrix
* @bean
*/
getMatrix: function() {
return this._matrix;
},
setMatrix: function(matrix) {
// Use Matrix#initialize to easily copy over values.
this._matrix.initialize(matrix);
this._changed(Change.GEOMETRY);
},
/**
* The item's position within the project. This is the
* {@link Rectangle#center} of the item's {@link #bounds} rectangle.
@ -790,6 +807,7 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
ctx = canvas.getContext('2d'),
matrix = new Matrix().scale(scale).translate(-bounds.x, -bounds.y);
matrix.applyToContext(ctx);
// XXX: Decide how to handle _matrix
this.draw(ctx, {});
var raster = new Raster(canvas);
raster.setBounds(bounds);

View file

@ -32,21 +32,5 @@ var PlacedItem = this.PlacedItem = Item.extend(/** @lends PlacedItem# */{
// raster, simply preconcatenate the internal matrix with the provided
// one.
this._matrix.preConcatenate(matrix);
},
/**
* The item's transformation matrix, defining position and dimensions in the
* document.
*
* @type Matrix
* @bean
*/
getMatrix: function() {
return this._matrix;
},
setMatrix: function(matrix) {
this._matrix = matrix.clone();
this._changed(Change.GEOMETRY);
}
});