From cf541901dd2fb9e6b5451ccd71485a707b6007fd Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Thu, 21 Apr 2011 19:51:49 +0200 Subject: [PATCH] Rename getSelected methods to isSelected. --- src/item/Item.js | 6 +++--- src/path/Path.js | 10 +++++----- src/path/Segment.js | 12 ++++++------ src/path/SegmentPoint.js | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index 2a043a20..c1ae7530 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -77,10 +77,10 @@ var Item = this.Item = Base.extend({ } }, - getSelected: function() { + isSelected: function() { if (this.children) { for (var i = 0, l = this.children.length; i < l; i++) { - if (this.children[i].getSelected()) + if (this.children[i].isSelected()) return true; } } else { @@ -279,7 +279,7 @@ var Item = this.Item = Base.extend({ * Removes the item. */ remove: function() { - if(this.getSelected()) + if(this.isSelected()) this.setSelected(false); return this.removeFromParent(); }, diff --git a/src/path/Path.js b/src/path/Path.js index 1239a619..ba84e7fd 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -129,12 +129,12 @@ var Path = this.Path = PathItem.extend({ } }, - getSelected: function() { + isSelected: function() { return this._selectedSegmentCount > 0; }, setSelected: function(selected) { - var wasSelected = this.getSelected(); + var wasSelected = this.isSelected(); var length = this._segments.length; if (!wasSelected != !selected && length) { var selectedItems = this._document._selectedItems; @@ -291,16 +291,16 @@ var Path = this.Path = PathItem.extend({ pointSelected = segment._selectionState == SelectionState.POINT; // TODO: draw handles depending on selection state of // segment.point and neighbouring segments. - if (pointSelected || segment.getSelected(segment._handleIn)) + if (pointSelected || segment.isSelected(segment._handleIn)) drawHandle(ctx, point, segment._handleIn); - if (pointSelected || segment.getSelected(segment._handleOut)) + if (pointSelected || segment.isSelected(segment._handleOut)) drawHandle(ctx, point, segment._handleOut); // Draw a rectangle at segment.point: ctx.save(); ctx.beginPath(); ctx.rect(point._x - 2, point._y - 2, 4, 4); ctx.fill(); - // TODO: Only draw white rectangle if point.getSelected() + // TODO: Only draw white rectangle if point.isSelected() // is false: if (!pointSelected) { ctx.beginPath(); diff --git a/src/path/Segment.js b/src/path/Segment.js index 8964a8e1..c3934bc5 100644 --- a/src/path/Segment.js +++ b/src/path/Segment.js @@ -125,7 +125,7 @@ var Segment = this.Segment = Base.extend({ return this._path && this._path._segments[this.getIndex() - 1] || null; }, - getSelected: function(/* point */) { + isSelected: function(/* point */) { var point = arguments.length ? arguments[0] : this.point; var state = this._selectionState; if (point == this.point) { @@ -180,11 +180,11 @@ var Segment = this.Segment = Base.extend({ // instead depending on the selection state of their // neighbors. handleInSelected = previous != null - && (previous._point.getSelected() - || previous._handleOut.getSelected()); + && (previous._point.isSelected() + || previous._handleOut.isSelected()); handleOutSelected = next != null - && (next._point.getSelected() - || next._handleOut.getSelected()); + && (next._point.isSelected() + || next._handleOut.isSelected()); } pointSelected = selected; } @@ -244,7 +244,7 @@ var Segment = this.Segment = Base.extend({ remove: function() { if (this._path) { this._path._segments.splice(this.getIndex(), 1); - if (this.getSelected()) + if (this.isSelected()) this._path._selectedSegmentCount--; return true; } diff --git a/src/path/SegmentPoint.js b/src/path/SegmentPoint.js index 4b2ec0f4..43ca132e 100644 --- a/src/path/SegmentPoint.js +++ b/src/path/SegmentPoint.js @@ -34,8 +34,8 @@ var SegmentPoint = Point.extend({ this._segment.setSelected(this, selected); }, - getSelected: function() { - return this._segment.getSelected(this); + isSelected: function() { + return this._segment.isSelected(this); }, statics: {