From e6b1e18bd7f880a00954f509e4c9fa506d3a4ac6 Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Thu, 27 Apr 2023 05:37:08 -0600 Subject: [PATCH] Rename objectGroup => soccerBallGroup, see https://github.com/phetsims/center-and-variability/issues/160 --- js/common/model/CAVModel.ts | 28 +++++++++---------- js/common/view/CAVPlotNode.ts | 8 +++--- js/common/view/CAVScreenView.ts | 14 +++++----- js/common/view/CardNodeContainer.ts | 4 +-- .../model/MeanAndMedianModel.ts | 2 +- js/mean-and-median/view/MedianPlotNode.ts | 2 +- js/median/model/MedianModel.ts | 2 +- js/variability/view/IQRNode.ts | 2 +- js/variability/view/MADNode.ts | 2 +- js/variability/view/RangeNode.ts | 2 +- 10 files changed, 33 insertions(+), 33 deletions(-) diff --git a/js/common/model/CAVModel.ts b/js/common/model/CAVModel.ts index 12f37ad5..a0d6035d 100644 --- a/js/common/model/CAVModel.ts +++ b/js/common/model/CAVModel.ts @@ -47,7 +47,7 @@ export type CAVModelOptions = SelfOptions; const TIME_BETWEEN_RAPID_KICKS = 0.5; // in seconds export default class CAVModel implements TModel { - public readonly objectGroup: PhetioGroup ]>; + public readonly soccerBallGroup: PhetioGroup ]>; public readonly isShowingTopMeanProperty: BooleanProperty; public readonly isShowingTopMedianProperty: BooleanProperty; @@ -103,12 +103,12 @@ export default class CAVModel implements TModel { const options = optionize()( {}, providedOptions ); - this.objectGroup = new PhetioGroup( ( tandem, providedOptions: StrictOmit ) => { + this.soccerBallGroup = new PhetioGroup( ( tandem, providedOptions: StrictOmit ) => { const options = optionize, EmptySelfOptions, CAVObjectOptions>()( { // If it's the first element in the group, mark as isFirstObject. For creating archetype, the objectGroup does // not yet exist, so just mark it as first - isFirstObject: this.objectGroup ? this.objectGroup.count === 0 : true, + isFirstObject: this.soccerBallGroup ? this.soccerBallGroup.count === 0 : true, tandem: tandem }, providedOptions ); @@ -231,10 +231,10 @@ export default class CAVModel implements TModel { cavObject.valueProperty.link( () => this.objectChangedEmitter.emit( cavObject ) ); cavObject.positionProperty.link( () => this.objectChangedEmitter.emit( cavObject ) ); }; - this.objectGroup.forEach( objectCreatedListener ); - this.objectGroup.elementCreatedEmitter.addListener( objectCreatedListener ); + this.soccerBallGroup.forEach( objectCreatedListener ); + this.soccerBallGroup.elementCreatedEmitter.addListener( objectCreatedListener ); - this.numberOfRemainingObjectsProperty = new DerivedProperty( [ this.objectGroup.countProperty ], count => { + this.numberOfRemainingObjectsProperty = new DerivedProperty( [ this.soccerBallGroup.countProperty ], count => { return this.maxNumberOfObjects - count; } ); @@ -289,7 +289,7 @@ export default class CAVModel implements TModel { } } ); - this.objectGroup.elementCreatedEmitter.addListener( cavObject => { + this.soccerBallGroup.elementCreatedEmitter.addListener( cavObject => { cavObject.valueProperty.link( ( value, oldValue ) => { if ( value !== null && oldValue === null ) { if ( !phet.joist.sim.isSettingPhetioStateProperty.value ) { @@ -319,7 +319,7 @@ export default class CAVModel implements TModel { const sortedObjects = this.getSortedLandedObjects(); const medianObjects = this.medianObjectsFromSortedArray( sortedObjects ); - this.objectGroup.forEach( object => { + this.soccerBallGroup.forEach( object => { object.isMedianObjectProperty.value = medianObjects.includes( object ); } ); @@ -365,7 +365,7 @@ export default class CAVModel implements TModel { * Returns all other objects at the target position of the provided object. */ public getOtherObjectsAtTarget( cavObject: CAVObject ): CAVObject[] { - return this.objectGroup.filter( ( o: CAVObject ) => { + return this.soccerBallGroup.filter( ( o: CAVObject ) => { return o.valueProperty.value === cavObject.valueProperty.value && cavObject !== o; } ); } @@ -393,7 +393,7 @@ export default class CAVModel implements TModel { * Clears out the data and the cards */ public clearData(): void { - this.objectGroup.clear(); + this.soccerBallGroup.clear(); this.numberOfScheduledSoccerBallsToKickProperty.reset(); this.timeProperty.reset(); @@ -423,7 +423,7 @@ export default class CAVModel implements TModel { } public getSortedLandedObjects(): CAVObject[] { - return _.sortBy( this.objectGroup.filter( cavObject => cavObject.valueProperty.value !== null ), + return _.sortBy( this.soccerBallGroup.filter( cavObject => cavObject.valueProperty.value !== null ), // The numerical value takes predence for sorting cavObject => cavObject.valueProperty.value, @@ -440,7 +440,7 @@ export default class CAVModel implements TModel { */ public step( dt: number ): void { this.timeProperty.value += dt; - this.objectGroup.forEach( cavObject => cavObject.step( dt ) ); + this.soccerBallGroup.forEach( cavObject => cavObject.step( dt ) ); const frontPlayer = this.soccerPlayers[ this.activeKickerIndexProperty.value ]; @@ -524,7 +524,7 @@ export default class CAVModel implements TModel { const y0 = CAVObjectType.SOCCER_BALL.radius; const position = new Vector2( 0, y0 ); - return this.objectGroup.createNextElement( { + return this.soccerBallGroup.createNextElement( { position: position } ); } @@ -533,7 +533,7 @@ export default class CAVModel implements TModel { * When a ball lands on the ground, animate all other balls that were at this location above the landed ball. */ private soccerBallLandedListener( cavObject: CAVObject, value: number ): void { - const otherObjectsInStack = this.objectGroup.filter( x => x.valueProperty.value === value && x !== cavObject ); + const otherObjectsInStack = this.soccerBallGroup.filter( x => x.valueProperty.value === value && x !== cavObject ); const sortedOthers = _.sortBy( otherObjectsInStack, object => object.positionProperty.value.y ); sortedOthers.forEach( ( cavObject, index ) => { diff --git a/js/common/view/CAVPlotNode.ts b/js/common/view/CAVPlotNode.ts index 2107ebc4..66edb09d 100644 --- a/js/common/view/CAVPlotNode.ts +++ b/js/common/view/CAVPlotNode.ts @@ -93,7 +93,7 @@ export default class CAVPlotNode extends Node { tandem: tandem, fill: options.dataPointFill } ); - }, () => [ model.objectGroup.archetype ], { + }, () => [ model.soccerBallGroup.archetype ], { phetioType: PhetioGroup.PhetioGroupIO( Node.NodeIO ), tandem: options.tandem.createTandem( 'dotNodeGroup' ), supportsDynamicState: false @@ -112,10 +112,10 @@ export default class CAVPlotNode extends Node { } ); map.set( cavObject, dotNode ); }; - model.objectGroup.forEach( createDotNode ); - model.objectGroup.elementCreatedEmitter.addListener( createDotNode ); + model.soccerBallGroup.forEach( createDotNode ); + model.soccerBallGroup.elementCreatedEmitter.addListener( createDotNode ); - model.objectGroup.elementDisposedEmitter.addListener( cavObject => { + model.soccerBallGroup.elementDisposedEmitter.addListener( cavObject => { const viewNode = map.get( cavObject )!; dotNodeGroup.disposeElement( viewNode ); map.delete( cavObject ); diff --git a/js/common/view/CAVScreenView.ts b/js/common/view/CAVScreenView.ts index 5c4b3dd8..dbc25fe5 100644 --- a/js/common/view/CAVScreenView.ts +++ b/js/common/view/CAVScreenView.ts @@ -97,7 +97,7 @@ export default class CAVScreenView extends ScreenView { fill: null, // Only depict as a soccer ball tandem: tandem } ); - }, () => [ model.objectGroup.archetype ], { + }, () => [ model.soccerBallGroup.archetype ], { phetioType: PhetioGroup.PhetioGroupIO( Node.NodeIO ), tandem: objectNodeGroupTandem, supportsDynamicState: false @@ -128,9 +128,9 @@ export default class CAVScreenView extends ScreenView { // add the dragIndicatorArrowNode above the last object when it is added to the play area. if an object was // moved before this happens, don't show the dragIndicatorArrowNode - if ( model.objectGroup.countProperty.value === this.model.physicalRange.max && + if ( model.soccerBallGroup.countProperty.value === this.model.physicalRange.max && objectNodesInputEnabledProperty.value && - _.every( model.objectGroup.getArray(), cavObject => cavObject.valueProperty.value !== null ) && + _.every( model.soccerBallGroup.getArray(), cavObject => cavObject.valueProperty.value !== null ) && !objectHasBeenDragged ) { dragIndicatorArrowNode.centerX = this.modelViewTransform.modelToViewX( value ); @@ -155,10 +155,10 @@ export default class CAVScreenView extends ScreenView { map.set( cavObject, cavObjectNode ); }; - model.objectGroup.forEach( createObjectNode ); - model.objectGroup.elementCreatedEmitter.addListener( createObjectNode ); + model.soccerBallGroup.forEach( createObjectNode ); + model.soccerBallGroup.elementCreatedEmitter.addListener( createObjectNode ); - model.objectGroup.elementDisposedEmitter.addListener( cavObject => { + model.soccerBallGroup.elementDisposedEmitter.addListener( cavObject => { const viewNode = map.get( cavObject )!; objectNodeGroup.disposeElement( viewNode ); map.delete( cavObject ); @@ -174,7 +174,7 @@ export default class CAVScreenView extends ScreenView { if ( visible ) { // if there is a ball at that location, go above the ball - const ballsAtLocation = model.objectGroup.filter( cavObject => cavObject.valueProperty.value === medianValue ); + const ballsAtLocation = model.soccerBallGroup.filter( cavObject => cavObject.valueProperty.value === medianValue ); const modelHeight = ballsAtLocation.length * CAVObjectType.SOCCER_BALL.radius * 2; // assumes no spacing const viewHeight = this.modelViewTransform.modelToViewDeltaY( modelHeight ); diff --git a/js/common/view/CardNodeContainer.ts b/js/common/view/CardNodeContainer.ts index 0b52b804..06dca39c 100644 --- a/js/common/view/CardNodeContainer.ts +++ b/js/common/view/CardNodeContainer.ts @@ -122,8 +122,8 @@ export default class CardNodeContainer extends Node { } ); }; - model.objectGroup.forEach( objectCreatedListener ); - model.objectGroup.elementCreatedEmitter.addListener( objectCreatedListener ); + model.soccerBallGroup.forEach( objectCreatedListener ); + model.soccerBallGroup.elementCreatedEmitter.addListener( objectCreatedListener ); model.cardModelGroup.elementDisposedEmitter.addListener( cardModel => { const cardNode = this.getCardNode( cardModel.cavObject )!; diff --git a/js/mean-and-median/model/MeanAndMedianModel.ts b/js/mean-and-median/model/MeanAndMedianModel.ts index 87e2d914..5b155e16 100644 --- a/js/mean-and-median/model/MeanAndMedianModel.ts +++ b/js/mean-and-median/model/MeanAndMedianModel.ts @@ -63,7 +63,7 @@ export default class MeanAndMedianModel extends CAVModel { private clearAnimation(): void { this.highlightAnimationIndex = null; - this.objectGroup.forEach( cavObject => cavObject.isShowingAnimationHighlightProperty.set( false ) ); + this.soccerBallGroup.forEach( cavObject => cavObject.isShowingAnimationHighlightProperty.set( false ) ); } private updateAnimation(): void { diff --git a/js/mean-and-median/view/MedianPlotNode.ts b/js/mean-and-median/view/MedianPlotNode.ts index f2e1bb30..8e936504 100644 --- a/js/mean-and-median/view/MedianPlotNode.ts +++ b/js/mean-and-median/view/MedianPlotNode.ts @@ -40,7 +40,7 @@ export default class MedianPlotNode extends CAVPlotNode { const updateMedianBarNode = () => { - const sortedDots = _.sortBy( model.objectGroup.getArrayCopy().filter( object => object.valueProperty.value !== null ), + const sortedDots = _.sortBy( model.soccerBallGroup.getArrayCopy().filter( object => object.valueProperty.value !== null ), object => object.valueProperty.value ); const leftmostDot = sortedDots[ 0 ]; diff --git a/js/median/model/MedianModel.ts b/js/median/model/MedianModel.ts index 428bfe9e..ca0d454d 100644 --- a/js/median/model/MedianModel.ts +++ b/js/median/model/MedianModel.ts @@ -29,7 +29,7 @@ export default class MedianModel extends CAVModel { return new CardModel( cavObject, { tandem: tandem } ); - }, () => [ this.objectGroup.archetype ], { + }, () => [ this.soccerBallGroup.archetype ], { phetioType: PhetioGroup.PhetioGroupIO( CardModel.CardModelIO ), tandem: options.tandem.createTandem( 'cardModelGroup' ) } ); diff --git a/js/variability/view/IQRNode.ts b/js/variability/view/IQRNode.ts index 4e440e4e..4c9a12a5 100644 --- a/js/variability/view/IQRNode.ts +++ b/js/variability/view/IQRNode.ts @@ -100,7 +100,7 @@ export default class IQRNode extends CAVPlotNode { const updateIQRNode = () => { - const sortedDots = _.sortBy( model.objectGroup.getArrayCopy().filter( object => object.valueProperty.value !== null ), + const sortedDots = _.sortBy( model.soccerBallGroup.getArrayCopy().filter( object => object.valueProperty.value !== null ), object => object.valueProperty.value ); const leftmostDot = sortedDots[ 0 ]; const rightmostDot = sortedDots[ sortedDots.length - 1 ]; diff --git a/js/variability/view/MADNode.ts b/js/variability/view/MADNode.ts index ef6108ba..e5e7044b 100644 --- a/js/variability/view/MADNode.ts +++ b/js/variability/view/MADNode.ts @@ -76,7 +76,7 @@ export default class MADNode extends CAVPlotNode { const children: Node[] = []; - const sortedDots = _.sortBy( model.objectGroup.getArrayCopy().filter( object => object.valueProperty.value !== null ), + const sortedDots = _.sortBy( model.soccerBallGroup.getArrayCopy().filter( object => object.valueProperty.value !== null ), object => object.valueProperty.value ); if ( sortedDots.length > 0 ) { diff --git a/js/variability/view/RangeNode.ts b/js/variability/view/RangeNode.ts index 46fb5116..cc05879f 100644 --- a/js/variability/view/RangeNode.ts +++ b/js/variability/view/RangeNode.ts @@ -65,7 +65,7 @@ export default class RangeNode extends CAVPlotNode { const updateRangeNode = () => { - const sortedDots = _.sortBy( model.objectGroup.getArrayCopy().filter( object => object.valueProperty.value !== null ), + const sortedDots = _.sortBy( model.soccerBallGroup.getArrayCopy().filter( object => object.valueProperty.value !== null ), object => object.valueProperty.value ); const leftmostDot = sortedDots[ 0 ]; const rightmostDot = sortedDots[ sortedDots.length - 1 ];