From b96f9ff57b6f5a313af6c2dd524a63f5c8f115ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 26 Nov 2013 19:27:09 +0100 Subject: [PATCH] Rearrange method sequence in Item. --- src/item/Item.js | 138 +++++++++++++++++++++++------------------------ 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index 89a0992a..7ed58d7b 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -766,75 +766,6 @@ var Item = Base.extend(Callback, /** @lends Item# */{ // translate the item. Pass true for dontLink, as we do not need a // LinkedPoint to simply calculate this distance. this.translate(Point.read(arguments).subtract(this.getPosition(true))); - }, - - /** - * The item's transformation matrix, defining position and dimensions in - * relation to its parent item in which it is contained. - * - * @type Matrix - * @bean - */ - getMatrix: function() { - return this._matrix; - }, - - setMatrix: function(matrix) { - // Use Matrix#initialize to easily copy over values. - this._matrix.initialize(matrix); - if (this._transformContent) - this.applyMatrix(true); - this._changed(/*#=*/ Change.GEOMETRY); - }, - - /** - * The item's global transformation matrix in relation to the global project - * coordinate space. - * - * @type Matrix - * @bean - */ - getGlobalMatrix: function() { - // TODO: if drawCount is out of sync, we still need to walk up the chain - // and concatenate the matrices. - return this._drawCount === this._project._drawCount - && this._globalMatrix || null; - }, - - /** - * Converts the specified point from global project coordinates to local - * coordinates in relation to the the item's own coordinate space. - * - * @param {Point} point the point to be transformed - * @return {Point} the transformed point as a new instance - */ - globalToLocal: function(/* point */) { - var matrix = this.getGlobalMatrix(); - return matrix && matrix._transformPoint(Point.read(arguments)); - }, - - /** - * Converts the specified point from local coordinates to global coordinates - * in relation to the the project coordinate space. - * - * @param {Point} point the point to be transformed - * @return {Point} the transformed point as a new instance - */ - localToGlobal: function(/* point */) { - var matrix = this.getGlobalMatrix(); - return matrix && matrix._inverseTransform(Point.read(arguments)); - }, - - /** - * Specifies whether the item has any content or not. The meaning of what - * content is differs from type to type. For example, a {@link Group} with - * no children, a {@link TextItem} with no text content and a {@link Path} - * with no segments all are considered empty. - * - * @return Boolean - */ - isEmpty: function() { - return !this._children || this._children.length == 0; } }, Base.each(['getBounds', 'getStrokeBounds', 'getHandleBounds', 'getRoughBounds'], function(name) { @@ -1025,6 +956,39 @@ var Item = Base.extend(Callback, /** @lends Item# */{ * @ignore */ }), /** @lends Item# */{ + /** + * The item's transformation matrix, defining position and dimensions in + * relation to its parent item in which it is contained. + * + * @type Matrix + * @bean + */ + getMatrix: function() { + return this._matrix; + }, + + setMatrix: function(matrix) { + // Use Matrix#initialize to easily copy over values. + this._matrix.initialize(matrix); + if (this._transformContent) + this.applyMatrix(true); + this._changed(/*#=*/ Change.GEOMETRY); + }, + + /** + * The item's global transformation matrix in relation to the global project + * coordinate space. + * + * @type Matrix + * @bean + */ + getGlobalMatrix: function() { + // TODO: if drawCount is out of sync, we still need to walk up the chain + // and concatenate the matrices. + return this._drawCount === this._project._drawCount + && this._globalMatrix || null; + }, + /** * {@grouptitle Project Hierarchy} * The project that this item belongs to. @@ -2004,6 +1968,18 @@ var Item = Base.extend(Callback, /** @lends Item# */{ // locking an item currently has no effect /** * {@grouptitle Tests} + * Specifies whether the item has any content or not. The meaning of what + * content is differs from type to type. For example, a {@link Group} with + * no children, a {@link TextItem} with no text content and a {@link Path} + * with no segments all are considered empty. + * + * @return Boolean + */ + isEmpty: function() { + return !this._children || this._children.length == 0; + }, + + /** * Checks whether the item is editable. * * @return {Boolean} {@true when neither the item, nor its parents are @@ -2601,6 +2577,30 @@ var Item = Base.extend(Callback, /** @lends Item# */{ this._changed(/*#=*/ Change.GEOMETRY); }, + /** + * Converts the specified point from global project coordinates to local + * coordinates in relation to the the item's own coordinate space. + * + * @param {Point} point the point to be transformed + * @return {Point} the transformed point as a new instance + */ + globalToLocal: function(/* point */) { + var matrix = this.getGlobalMatrix(); + return matrix && matrix._transformPoint(Point.read(arguments)); + }, + + /** + * Converts the specified point from local coordinates to global coordinates + * in relation to the the project coordinate space. + * + * @param {Point} point the point to be transformed + * @return {Point} the transformed point as a new instance + */ + localToGlobal: function(/* point */) { + var matrix = this.getGlobalMatrix(); + return matrix && matrix._inverseTransform(Point.read(arguments)); + }, + /** * Transform the item so that its {@link #bounds} fit within the specified * rectangle, without changing its aspect ratio.