Skip to content

Commit

Permalink
Merge pull request #203 from palantir/underscorize-more
Browse files Browse the repository at this point in the history
Underscorize some more names of public or overloaded fields
  • Loading branch information
teamdandelion committed Mar 18, 2014
2 parents ae4bdac + 074fc46 commit 37de99f
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 62 deletions.
8 changes: 4 additions & 4 deletions plottable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
4 changes: 2 additions & 2 deletions src/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ module Plottable {
}
super(scale, orientation, formatter);
super.rowMinimum(Axis.xHeight);
this.fixedWidthVal = false;
this._fixedWidth = false;
this.tickLabelPosition("center");
}

Expand Down Expand Up @@ -311,7 +311,7 @@ module Plottable {
}
super(scale, orientation, formatter);
super.colMinimum(Axis.yWidth);
this.fixedHeightVal = false;
this._fixedHeight = false;
this.tickLabelPosition("MIDDLE");
}

Expand Down
52 changes: 26 additions & 26 deletions src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"];

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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");
}
Expand All @@ -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");
}
Expand All @@ -186,7 +186,7 @@ module Plottable {
* @returns {Component} The calling Component.
*/
public xOffset(offset: number): Component {
this.xOffsetVal = offset;
this._xOffset = offset;
return this;
}

Expand All @@ -197,7 +197,7 @@ module Plottable {
* @returns {Component} The calling Component.
*/
public yOffset(offset: number): Component {
this.yOffsetVal = offset;
this._yOffset = offset;
return this;
}

Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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;
}
}

Expand All @@ -323,7 +323,7 @@ module Plottable {
* @return {boolean} Whether the component has a fixed width.
*/
public isFixedWidth(): boolean {
return this.fixedWidthVal;
return this._fixedWidth;
}

/**
Expand All @@ -333,7 +333,7 @@ module Plottable {
* @return {boolean} Whether the component has a fixed height.
*/
public isFixedHeight(): boolean {
return this.fixedHeightVal;
return this._fixedHeight;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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)");
Expand Down
4 changes: 2 additions & 2 deletions src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 11 additions & 11 deletions test/componentGroupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,35 +50,35 @@ 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");
});

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();
Expand Down
8 changes: 4 additions & 4 deletions test/componentTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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((<any> c).xAlignProportion, 0, "xAlignProportion defaults to 0");
assert.equal((<any> c).yAlignProportion, 0, "yAlignProportion defaults to 0");
assert.equal((<any> c).xOffsetVal, 0, "xOffset defaults to 0");
assert.equal((<any> c).yOffsetVal, 0, "yOffset defaults to 0");
assert.equal((<any> c)._xAlignProportion, 0, "_xAlignProportion defaults to 0");
assert.equal((<any> c)._yAlignProportion, 0, "_yAlignProportion defaults to 0");
assert.equal((<any> c)._xOffset, 0, "xOffset defaults to 0");
assert.equal((<any> c)._yOffset, 0, "yOffset defaults to 0");
svg.remove();
});

Expand Down
18 changes: 9 additions & 9 deletions test/tableTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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");
});
Expand Down

0 comments on commit 37de99f

Please sign in to comment.