Skip to content

Commit

Permalink
Mark attributes as private, remove unused, see #93
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Dec 20, 2024
1 parent 70eeb96 commit ca84c22
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 30 deletions.
9 changes: 0 additions & 9 deletions js/least-squares-regression/model/DataPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,6 @@ export default class DataPoint extends Disposable {
} );
}

/**
* Resets all the properties of DataPoint.
*/
public reset(): void {
this.positionProperty.reset();
this.userControlledProperty.reset();
this.animatingProperty.reset();
}

/**
* Function that animates the DataPoint back to the bucket.
*/
Expand Down
6 changes: 0 additions & 6 deletions js/least-squares-regression/model/Graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ export default class Graph {
// Array of dataPoints currently on the graph
public dataPointsOnGraph: DataPoint[];

// Graph domain ranges
public xRange!: Range;
public yRange!: Range;

// Factors for slope and intercept conversions
public slopeFactor!: number;
public interceptFactor!: number;
Expand Down Expand Up @@ -130,8 +126,6 @@ export default class Graph {
* for the slope and intercept.
*/
public setGraphDomain( xRange: Range, yRange: Range ): void {
this.xRange = xRange;
this.yRange = yRange;
this.slopeFactor = ( yRange.max - yRange.min ) / ( xRange.max - xRange.min ) / ( this.bounds.height / this.bounds.width );
this.interceptFactor = ( yRange.max - yRange.min ) / this.bounds.height;
this.interceptOffset = ( yRange.min );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export default class LeastSquaresRegressionModel {
* Function that adds position listener and user Controlled listener;
* Useful for dynamical points
*/
public addDataPointControlledListener( dataPoint: DataPoint ): void {
private addDataPointControlledListener( dataPoint: DataPoint ): void {

dataPoint.userControlledListener = ( userControlled: boolean ) => {
const isOnGraph = this.graph.isDataPointPositionOverlappingGraph( dataPoint.positionProperty.value );
Expand Down
7 changes: 1 addition & 6 deletions js/least-squares-regression/model/Residual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ export default class Residual {
*/
public readonly isSquaredResidualToTheLeft: boolean;

public constructor(
public readonly dataPoint: DataPoint,
slope: number, intercept: number ) {

// Store the dataPoint to be able to identify residual node.
this.dataPoint = dataPoint;
public constructor( dataPoint: DataPoint, slope: number, intercept: number ) {

// Calculate the y-value on the line corresponding to the dataPoint's x-coordinate.
const yValue = slope * dataPoint.positionProperty.value.x + intercept;
Expand Down
2 changes: 1 addition & 1 deletion js/least-squares-regression/view/EquationNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class EquationNode extends Node {
// Public Text nodes
public readonly yText: Text;
public readonly equalText: Text;
public readonly signSlopeText: Text;
private readonly signSlopeText: Text;
public readonly valueSlopeText: Text;
public readonly xText: Text;
public readonly signInterceptText: Text;
Expand Down
6 changes: 3 additions & 3 deletions js/least-squares-regression/view/GraphNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export default class GraphNode extends Node {
// private readonly bestFitResiduals: Node[] = [];
private readonly residualCanvasNode: ResidualCanvasNode;

public constructor( public readonly graph: Graph,
public readonly viewBounds: Bounds2,
public readonly modelViewTransform: ModelViewTransform2 ) {
public constructor( private readonly graph: Graph,
private readonly viewBounds: Bounds2,
private readonly modelViewTransform: ModelViewTransform2 ) {

super();

Expand Down
4 changes: 2 additions & 2 deletions js/least-squares-regression/view/ResidualCanvasNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import Residual from '../model/Residual.js';
export default class ResidualCanvasNode extends CanvasNode {

public constructor(
public readonly graph: Graph,
public readonly modelViewTransform: ModelViewTransform2,
private readonly graph: Graph,
private readonly modelViewTransform: ModelViewTransform2,
stageWidth: number, stageHeight: number ) {

super( {
Expand Down
4 changes: 2 additions & 2 deletions js/least-squares-regression/view/ResidualLineAndSquareNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class ResidualLineAndSquareNode extends Node {
private readonly squareVisibilityPropertyListener: ( visible: boolean ) => void;
private readonly updateLineAndSquareListener: () => void;

public constructor( public readonly residualProperty: Property<Residual>,
public constructor( private readonly residualProperty: Property<Residual>,
lineColor: { SQUARED_RESIDUAL_COLOR: string; RESIDUAL_COLOR: string },
private viewBounds: Bounds2,
private modelViewTransform: ModelViewTransform2,
Expand Down Expand Up @@ -72,7 +72,7 @@ export default class ResidualLineAndSquareNode extends Node {
/**
* Update the Line and Square Residual
*/
public updateLineAndSquare(): void {
private updateLineAndSquare(): void {
const point1 = this.modelViewTransform.modelToViewPosition( this.residualProperty.value.point1 );
const point2 = this.modelViewTransform.modelToViewPosition( this.residualProperty.value.point2 );

Expand Down

0 comments on commit ca84c22

Please sign in to comment.