From 074fc461082ab95e0502a48a27e9aef3d77501e9 Mon Sep 17 00:00:00 2001 From: Daniel Mane Date: Mon, 17 Mar 2014 18:11:27 -0700 Subject: [PATCH] Underscorize some more names of public or overloaded fields --- plottable.d.ts | 8 +++--- src/axis.ts | 4 +-- src/component.ts | 52 ++++++++++++++++++------------------- src/label.ts | 8 +++--- src/renderer.ts | 4 +-- test/componentGroupTests.ts | 22 ++++++++-------- test/componentTests.ts | 8 +++--- test/tableTests.ts | 18 ++++++------- 8 files changed, 62 insertions(+), 62 deletions(-) diff --git a/plottable.d.ts b/plottable.d.ts index 3aa42e794f..3ec7aa8394 100644 --- a/plottable.d.ts +++ b/plottable.d.ts @@ -77,14 +77,14 @@ declare module Plottable { public backgroundContainer: D3.Selection; public foregroundContainer: D3.Selection; public clipPathEnabled: boolean; - public fixedWidthVal: boolean; - public fixedHeightVal: boolean; + public _fixedWidth: boolean; + public _fixedHeight: boolean; public availableWidth: number; public availableHeight: number; public xOrigin: number; public yOrigin: number; - public xAlignProportion: number; - public yAlignProportion: number; + public _xAlignProportion: number; + public _yAlignProportion: number; /** * Attaches the Component to a DOM element. Usually only directly invoked on root-level Components. * diff --git a/src/axis.ts b/src/axis.ts index ca1e702930..c2ecd8e8fa 100644 --- a/src/axis.ts +++ b/src/axis.ts @@ -238,7 +238,7 @@ module Plottable { } super(scale, orientation, formatter); super.rowMinimum(Axis.xHeight); - this.fixedWidthVal = false; + this._fixedWidth = false; this.tickLabelPosition("center"); } @@ -311,7 +311,7 @@ module Plottable { } super(scale, orientation, formatter); super.colMinimum(Axis.yWidth); - this.fixedHeightVal = false; + this._fixedHeight = false; this.tickLabelPosition("MIDDLE"); } diff --git a/src/component.ts b/src/component.ts index 251bf8ad09..80a440f037 100644 --- a/src/component.ts +++ b/src/component.ts @@ -13,10 +13,10 @@ module Plottable { public foregroundContainer: D3.Selection; public clipPathEnabled = false; - public fixedWidthVal = true; - public fixedHeightVal = true; - private rowMinimumVal = 0; - private colMinimumVal = 0; + public _fixedWidth = true; + public _fixedHeight = true; + private _rowMinimum = 0; + private _colMinimum = 0; private rootSVG: D3.Selection; private isTopLevelComponent = false; @@ -25,10 +25,10 @@ module Plottable { public availableHeight: number; public xOrigin : number; // Origin of the coordinate space for the component. Passed down from parent public yOrigin : number; - private xOffsetVal = 0; // Offset from Origin, used for alignment and floating positioning - private yOffsetVal = 0; - public xAlignProportion = 0; // What % along the free space do we want to position (0 = left, .5 = center, 1 = right) - public yAlignProportion = 0; + private _xOffset = 0; // Offset from Origin, used for alignment and floating positioning + private _yOffset = 0; + public _xAlignProportion = 0; // What % along the free space do we want to position (0 = left, .5 = center, 1 = right) + public _yAlignProportion = 0; private cssClasses: string[] = ["component"]; @@ -105,15 +105,15 @@ module Plottable { if (this.colMinimum() !== 0 && this.isFixedWidth()) { // The component has free space, so it makes sense to think about how to position or offset it - xPosition += (availableWidth - this.colMinimum()) * this.xAlignProportion; - xPosition += this.xOffsetVal; + xPosition += (availableWidth - this.colMinimum()) * this._xAlignProportion; + xPosition += this._xOffset; // Decrease size so hitbox / bounding box and children are sized correctly availableWidth = availableWidth > this.colMinimum() ? this.colMinimum() : availableWidth; } if (this.rowMinimum() !== 0 && this.isFixedHeight()) { - yPosition += (availableHeight - this.rowMinimum()) * this.yAlignProportion; - yPosition += this.yOffsetVal; + yPosition += (availableHeight - this.rowMinimum()) * this._yAlignProportion; + yPosition += this._yOffset; availableHeight = availableHeight > this.rowMinimum() ? this.rowMinimum() : availableHeight; } @@ -149,11 +149,11 @@ module Plottable { */ public xAlign(alignment: string): Component { if (alignment === "LEFT") { - this.xAlignProportion = 0; + this._xAlignProportion = 0; } else if (alignment === "CENTER") { - this.xAlignProportion = 0.5; + this._xAlignProportion = 0.5; } else if (alignment === "RIGHT") { - this.xAlignProportion = 1; + this._xAlignProportion = 1; } else { throw new Error("Unsupported alignment"); } @@ -168,11 +168,11 @@ module Plottable { */ public yAlign(alignment: string): Component { if (alignment === "TOP") { - this.yAlignProportion = 0; + this._yAlignProportion = 0; } else if (alignment === "CENTER") { - this.yAlignProportion = 0.5; + this._yAlignProportion = 0.5; } else if (alignment === "BOTTOM") { - this.yAlignProportion = 1; + this._yAlignProportion = 1; } else { throw new Error("Unsupported alignment"); } @@ -186,7 +186,7 @@ module Plottable { * @returns {Component} The calling Component. */ public xOffset(offset: number): Component { - this.xOffsetVal = offset; + this._xOffset = offset; return this; } @@ -197,7 +197,7 @@ module Plottable { * @returns {Component} The calling Component. */ public yOffset(offset: number): Component { - this.yOffsetVal = offset; + this._yOffset = offset; return this; } @@ -292,10 +292,10 @@ module Plottable { public rowMinimum(newVal: number): Component; public rowMinimum(newVal?: number): any { if (newVal != null) { - this.rowMinimumVal = newVal; + this._rowMinimum = newVal; return this; } else { - return this.rowMinimumVal; + return this._rowMinimum; } } @@ -309,10 +309,10 @@ module Plottable { public colMinimum(newVal: number): Component; public colMinimum(newVal?: number): any { if (newVal != null) { - this.colMinimumVal = newVal; + this._colMinimum = newVal; return this; } else { - return this.colMinimumVal; + return this._colMinimum; } } @@ -323,7 +323,7 @@ module Plottable { * @return {boolean} Whether the component has a fixed width. */ public isFixedWidth(): boolean { - return this.fixedWidthVal; + return this._fixedWidth; } /** @@ -333,7 +333,7 @@ module Plottable { * @return {boolean} Whether the component has a fixed height. */ public isFixedHeight(): boolean { - return this.fixedHeightVal; + return this._fixedHeight; } /** diff --git a/src/label.ts b/src/label.ts index fc8bdb415c..ce5d86215a 100644 --- a/src/label.ts +++ b/src/label.ts @@ -22,9 +22,9 @@ module Plottable { if (orientation === "horizontal" || orientation === "vertical-left" || orientation === "vertical-right") { this.orientation = orientation; if (orientation === "horizontal") { - this.fixedWidthVal = false; + this._fixedWidth = false; } else { - this.fixedHeightVal = false; + this._fixedHeight = false; } } else { throw new Error(orientation + " is not a valid orientation for LabelComponent"); @@ -83,10 +83,10 @@ module Plottable { if (this.orientation === "horizontal") { this.truncateTextAndRemeasure(this.availableWidth); - xShift = (this.availableWidth - this.textLength) * this.xAlignProportion; + xShift = (this.availableWidth - this.textLength) * this._xAlignProportion; } else { this.truncateTextAndRemeasure(this.availableHeight); - xShift = (this.availableHeight - this.textLength) * this.yAlignProportion; + xShift = (this.availableHeight - this.textLength) * this._yAlignProportion; if (this.orientation === "vertical-right") { this.textElement.attr("transform", "rotate(90)"); diff --git a/src/renderer.ts b/src/renderer.ts index 1a4c25ff06..813f7941dd 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -31,8 +31,8 @@ module Plottable { constructor(dataset?: IDataset) { super(); this.clipPathEnabled = true; - this.fixedWidthVal = false; - this.fixedHeightVal = false; + this._fixedWidth = false; + this._fixedHeight = false; this.classed("renderer", true); if (dataset != null) { this.dataset(dataset); diff --git a/test/componentGroupTests.ts b/test/componentGroupTests.ts index a0a24fed12..b7ef654bcd 100644 --- a/test/componentGroupTests.ts +++ b/test/componentGroupTests.ts @@ -50,23 +50,23 @@ describe("ComponentGroups", () => { it("component fixity is computed appropriately", () => { var cg = new Plottable.ComponentGroup(); var c1 = new Plottable.Component(); - c1.fixedHeightVal = false; - c1.fixedWidthVal = false; + c1._fixedHeight = false; + c1._fixedWidth = false; var c2 = new Plottable.Component(); - c2.fixedHeightVal = false; - c2.fixedWidthVal = false; + c2._fixedHeight = false; + c2._fixedWidth = false; cg.merge(c1).merge(c2); assert.isFalse(cg.isFixedHeight(), "height not fixed when both components unfixed"); assert.isFalse(cg.isFixedWidth(), "width not fixed when both components unfixed"); - c1.fixedHeightVal = true; - c1.fixedWidthVal = true; + c1._fixedHeight = true; + c1._fixedWidth = true; assert.isFalse(cg.isFixedHeight(), "height not fixed when one component unfixed"); assert.isFalse(cg.isFixedWidth(), "width not fixed when one component unfixed"); - c2.fixedHeightVal = true; + c2._fixedHeight = true; assert.isTrue(cg.isFixedHeight(), "height fixed when both components fixed"); assert.isFalse(cg.isFixedWidth(), "width unfixed when one component unfixed"); }); @@ -74,11 +74,11 @@ describe("ComponentGroups", () => { it("componentGroup subcomponents have xOffset, yOffset of 0", () => { var cg = new Plottable.ComponentGroup(); var c1 = new Plottable.Component(); - c1.fixedHeightVal = false; - c1.fixedWidthVal = false; + c1._fixedHeight = false; + c1._fixedWidth = false; var c2 = new Plottable.Component(); - c2.fixedHeightVal = false; - c2.fixedWidthVal = false; + c2._fixedHeight = false; + c2._fixedWidth = false; cg.merge(c1).merge(c2); var svg = generateSVG(); diff --git a/test/componentTests.ts b/test/componentTests.ts index 033df1b200..7ad5e94202 100644 --- a/test/componentTests.ts +++ b/test/componentTests.ts @@ -140,10 +140,10 @@ describe("Component behavior", () => { it("component defaults are as expected", () => { assert.equal(c.rowMinimum(), 0, "rowMinimum defaults to 0"); assert.equal(c.colMinimum(), 0, "colMinimum defaults to 0"); - assert.equal(( c).xAlignProportion, 0, "xAlignProportion defaults to 0"); - assert.equal(( c).yAlignProportion, 0, "yAlignProportion defaults to 0"); - assert.equal(( c).xOffsetVal, 0, "xOffset defaults to 0"); - assert.equal(( c).yOffsetVal, 0, "yOffset defaults to 0"); + assert.equal(( c)._xAlignProportion, 0, "_xAlignProportion defaults to 0"); + assert.equal(( c)._yAlignProportion, 0, "_yAlignProportion defaults to 0"); + assert.equal(( c)._xOffset, 0, "xOffset defaults to 0"); + assert.equal(( c)._yOffset, 0, "yOffset defaults to 0"); svg.remove(); }); diff --git a/test/tableTests.ts b/test/tableTests.ts index 3bbefcf088..db194025ba 100644 --- a/test/tableTests.ts +++ b/test/tableTests.ts @@ -107,8 +107,8 @@ describe("Tables", () => { var components = tableAndcomponents.components; // force the components to have non-fixed layout; eg. as if they were renderers components.forEach((c) => { - c.fixedWidthVal = false; - c.fixedHeightVal = false; + c._fixedWidth = false; + c._fixedHeight = false; }); var svg = generateSVG(); @@ -134,8 +134,8 @@ describe("Tables", () => { var components = tableAndcomponents.components; // force the components to have non-fixed layout; eg. as if they were renderers components.forEach((c) => { - c.fixedWidthVal = false; - c.fixedHeightVal = false; + c._fixedWidth = false; + c._fixedHeight = false; }); table.padding(5,5); @@ -172,8 +172,8 @@ describe("Tables", () => { components[7].rowMinimum(30); components[3].colMinimum(50); components[5].colMinimum(50); - components[4].fixedWidthVal = false; - components[4].fixedHeightVal = false; + components[4]._fixedWidth = false; + components[4]._fixedHeight = false; // finally the center 'plot' object has a weight table.renderTo(svg); @@ -208,11 +208,11 @@ describe("Tables", () => { var components = tableAndcomponents.components; assert.isTrue(table.isFixedWidth(), "fixed width when all subcomponents fixed width"); assert.isTrue(table.isFixedHeight(), "fixedHeight when all subcomponents fixed height"); - components[0].fixedWidthVal = false; + components[0]._fixedWidth = false; assert.isFalse(table.isFixedWidth(), "width not fixed when some subcomponent width not fixed"); assert.isTrue(table.isFixedHeight(), "the height is still fixed when some subcomponent width not fixed"); - components[8].fixedHeightVal = false; - components[0].fixedWidthVal = true; + components[8]._fixedHeight = false; + components[0]._fixedWidth = true; assert.isTrue(table.isFixedWidth(), "width fixed again once no subcomponent width not fixed"); assert.isFalse(table.isFixedHeight(), "height unfixed now that a subcomponent has unfixed height"); });