From 2585e81d103b324a74b694a5cdc51278d8f230cf Mon Sep 17 00:00:00 2001 From: samreid Date: Mon, 26 Nov 2018 10:27:06 -0700 Subject: [PATCH] Added "This exists for the lifetime of the sim and doesn't require disposal." where appropriate, see https://github.com/phetsims/wave-interference/issues/191 --- js/common/view/LatticeCanvasNode.js | 2 +- js/common/view/LightEmitterNode.js | 7 +++++-- js/common/view/SceneToggleNode.js | 3 ++- js/common/view/SoundParticleDevPanel.js | 15 +++++++++++++-- js/common/view/TimeControlPanel.js | 4 +++- js/common/view/WaterEmitterNode.js | 1 + js/common/view/WaveAreaGraphNode.js | 3 ++- js/common/view/WaveInterferenceControlPanel.js | 11 ++++++++++- js/common/view/WaveInterferenceSceneIcons.js | 2 ++ js/common/view/WaveInterferenceSlider.js | 3 ++- js/common/view/WaveMeterNode.js | 8 +++++++- js/diffraction/view/DiffractionScreenView.js | 16 ++++++++++++++++ js/interference/view/InterferenceScreenView.js | 8 ++++++++ js/slits/view/BarriersNode.js | 1 + js/slits/view/SlitsControlPanel.js | 17 +++++++++++++++++ js/slits/view/SlitsScreenView.js | 3 +++ js/waves/view/WavesScreenView.js | 7 +++++++ 17 files changed, 100 insertions(+), 11 deletions(-) diff --git a/js/common/view/LatticeCanvasNode.js b/js/common/view/LatticeCanvasNode.js index 2d519a01..eb71d62b 100644 --- a/js/common/view/LatticeCanvasNode.js +++ b/js/common/view/LatticeCanvasNode.js @@ -71,7 +71,7 @@ define( require => { * @param {Vector2} point - point in the local coordinate frame * @returns {Vector2} */ - localPointToLatticePoint( point ) { + static localPointToLatticePoint( point ) { return new Vector2( Math.floor( point.x / CELL_WIDTH ), Math.floor( point.y / CELL_WIDTH ) ); } diff --git a/js/common/view/LightEmitterNode.js b/js/common/view/LightEmitterNode.js index 9646918c..28460beb 100644 --- a/js/common/view/LightEmitterNode.js +++ b/js/common/view/LightEmitterNode.js @@ -31,9 +31,12 @@ define( require => { */ constructor( model, waveAreaNode, isPrimarySource ) { let scene = model.lightScene; - super( model, scene, waveAreaNode, 70, isPrimarySource, new LaserPointerNode( scene.button1PressedProperty, _.extend( { + + // This exists for the lifetime of the sim and doesn't require disposal. + const laserPointerNode = new LaserPointerNode( scene.button1PressedProperty, _.extend( { rightCenter: waveAreaNode.leftCenter.plusXY( 20, 0 ) - }, DEFAULTS ) ) ); + }, DEFAULTS ) ); + super( model, scene, waveAreaNode, 70, isPrimarySource, laserPointerNode ); } /** diff --git a/js/common/view/SceneToggleNode.js b/js/common/view/SceneToggleNode.js index 1d063aac..a2df4fc0 100644 --- a/js/common/view/SceneToggleNode.js +++ b/js/common/view/SceneToggleNode.js @@ -1,7 +1,8 @@ // Copyright 2018, University of Colorado Boulder /** - * A ToggleNode that shows something different for each scene. + * A ToggleNode that shows something different for each scene. All SceneToggleNodes in this sim exist for the lifetime + * of the sim and doesn't require disposal. * * @author Sam Reid (PhET Interactive Simulations) */ diff --git a/js/common/view/SoundParticleDevPanel.js b/js/common/view/SoundParticleDevPanel.js index 4d470866..f44e330a 100644 --- a/js/common/view/SoundParticleDevPanel.js +++ b/js/common/view/SoundParticleDevPanel.js @@ -28,25 +28,36 @@ define( require => { children: [ // TODO: delete or keep? Fine tuning and discussion in https://github.com/phetsims/wave-interference/issues/142 + // This exists for the lifetime of the sim and doesn't require disposal. new NumberControl( 'cutoff', WaveInterferenceConstants.CUTOFF, new Range( 0, 1 ), _.extend( { delta: 0.01, decimalPlaces: 2 }, WaveInterferenceConstants.NUMBER_CONTROL_OPTIONS ) ), + + // This exists for the lifetime of the sim and doesn't require disposal. new NumberControl( 'randomness', WaveInterferenceConstants.SOUND_PARTICLE_RANDOMNESS_PROPERTY, new Range( 0, 30 ), _.extend( { delta: 0.25, decimalPlaces: 2 }, WaveInterferenceConstants.NUMBER_CONTROL_OPTIONS ) ), + + // This exists for the lifetime of the sim and doesn't require disposal. new NumberControl( 'ADJUST home force', WaveInterferenceConstants.SOUND_PARTICLE_RESTORATION_SCALE, new Range( 0.1, 2 ), _.extend( { delta: 0.01, decimalPlaces: 2 }, WaveInterferenceConstants.NUMBER_CONTROL_OPTIONS ) - ), new NumberControl( 'friction (1=none)', + ), + + // This exists for the lifetime of the sim and doesn't require disposal. + new NumberControl( 'friction (1=none)', WaveInterferenceConstants.SOUND_PARTICLE_FRICTION_SCALE_PROPERTY, new Range( 0.7, 1.0 ), _.extend( { delta: 0.005, decimalPlaces: 3 }, WaveInterferenceConstants.NUMBER_CONTROL_OPTIONS ) - ), new NumberControl( 'ADJUST gradient force', + ), + + // This exists for the lifetime of the sim and doesn't require disposal. + new NumberControl( 'ADJUST gradient force', WaveInterferenceConstants.SOUND_PARTICLE_GRADIENT_FORCE_SCALE_PROPERTY, new Range( 0.1, 2 ), _.extend( { delta: 0.01, decimalPlaces: 2 }, WaveInterferenceConstants.NUMBER_CONTROL_OPTIONS ) diff --git a/js/common/view/TimeControlPanel.js b/js/common/view/TimeControlPanel.js index 11d7a97e..a4607346 100644 --- a/js/common/view/TimeControlPanel.js +++ b/js/common/view/TimeControlPanel.js @@ -33,10 +33,12 @@ define( require => { */ constructor( model, options ) { + // This exists for the lifetime of the sim and doesn't require disposal. const playPauseButton = new PlayPauseButton( model.isRunningProperty, { scale: BUTTON_SCALE } ); + // This exists for the lifetime of the sim and doesn't require disposal. const radioButtonGroup = new WaveInterferenceVerticalAquaRadioButtonGroup( [ { node: new WaveInterferenceText( normalString ), value: PlaySpeedEnum.NORMAL, @@ -48,7 +50,7 @@ define( require => { } ] ); const stepButton = new StepButton( { - scale: BUTTON_SCALE + scale: BUTTON_SCALE // TODO: can listener be inlined? } ); // If we need to move forward further than one frame, call advanceTime several times rather than increasing the diff --git a/js/common/view/WaterEmitterNode.js b/js/common/view/WaterEmitterNode.js index 9a585447..7641f15f 100644 --- a/js/common/view/WaterEmitterNode.js +++ b/js/common/view/WaterEmitterNode.js @@ -29,6 +29,7 @@ define( require => { */ constructor( model, waveAreaNode, isPrimarySource ) { + // This exists for the lifetime of the sim and doesn't require disposal. const faucetNode = new FaucetNode( // This value is irrelevant because we use our own faucet water emitting model, but must be nonzero // to prevent a divide by zero problem diff --git a/js/common/view/WaveAreaGraphNode.js b/js/common/view/WaveAreaGraphNode.js index 213d3e73..414517b4 100644 --- a/js/common/view/WaveAreaGraphNode.js +++ b/js/common/view/WaveAreaGraphNode.js @@ -50,7 +50,7 @@ define( require => { // the bottom tab will fit the largest label. const horizontalAxisLabel = new SceneToggleNode( model, scene => new WaveInterferenceText( scene.graphHorizontalAxisLabel ) ); - // Scene-specific title of the chart + // Scene-specific title of the chart. const title = new SceneToggleNode( model, scene => new WaveInterferenceText( scene.graphTitle ) ); const HORIZONTAL_LABEL_VERTICAL_MARGIN = 2; @@ -85,6 +85,7 @@ define( require => { ); const lastTickLabel = horizontalAxisTickLabels[ horizontalAxisTickLabels.length - 1 ]; const tickBubbleXMargin = 2; + const verticalAxisLabel = new SceneToggleNode( model, scene => new WaveInterferenceText( scene.verticalAxisTitle ), { rotation: 3 * Math.PI / 2, right: -TEXT_MARGIN_Y, diff --git a/js/common/view/WaveInterferenceControlPanel.js b/js/common/view/WaveInterferenceControlPanel.js index 27400979..137f2d02 100644 --- a/js/common/view/WaveInterferenceControlPanel.js +++ b/js/common/view/WaveInterferenceControlPanel.js @@ -95,13 +95,15 @@ define( require => { lightFrequencySlider.centerTop = soundFrequencySlider.centerTop.plusXY( 0, 10 ); const frequencySliderContainer = new Node( { children: [ waterFrequencySlider, soundFrequencySlider, lightFrequencySlider ] } ); + const amplitudeSliderContainer = new SceneToggleNode( model, scene => { // For water scene, control the desiredAmplitude (which determines the size of the water drops) - // For other scenes, control the amplitude directly. + // For other scenes, control the amplitude directly. This exists for the lifetime of the sim and doesn't require disposal. return new WaveInterferenceSlider( scene.desiredAmplitudeProperty || scene.amplitudeProperty, scene.amplitudeProperty.range.min, scene.amplitudeProperty.range.max ); } ); + // This exists for the lifetime of the sim and doesn't require disposal. const viewSelectionRadioButtonGroup = new VerticalAquaRadioButtonGroup( [ { node: new WaveInterferenceText( wavesString ), value: SoundViewType.WAVES, @@ -121,9 +123,14 @@ define( require => { radius: 6.5 } } ); + + // This exists for the lifetime of the sim and doesn't require disposal. const graphCheckbox = new Checkbox( new WaveInterferenceText( graphString ), model.showGraphProperty, CHECKBOX_OPTIONS ); + // This exists for the lifetime of the sim and doesn't require disposal. const screenCheckbox = new Checkbox( new WaveInterferenceText( screenString ), model.showScreenProperty, CHECKBOX_OPTIONS ); + + // This exists for the lifetime of the sim and doesn't require disposal. const intensityCheckbox = new Checkbox( new WaveInterferenceText( intensityString ), model.showIntensityGraphProperty, CHECKBOX_OPTIONS ); // Only enable the intensity checkbox when the screen is selected @@ -141,6 +148,8 @@ define( require => { // Create faucet icon, and rasterize to clip out invisible parts (like the ShooterNode) const sceneIcons = new WaveInterferenceSceneIcons(); + + // This exists for the lifetime of the sim and doesn't require disposal. const sceneRadioButtons = new RadioButtonGroup( model.sceneProperty, [ { value: model.waterScene, node: sceneIcons.faucetIcon }, { value: model.soundScene, node: sceneIcons.speakerIcon }, diff --git a/js/common/view/WaveInterferenceSceneIcons.js b/js/common/view/WaveInterferenceSceneIcons.js index e0bd8020..103600ed 100644 --- a/js/common/view/WaveInterferenceSceneIcons.js +++ b/js/common/view/WaveInterferenceSceneIcons.js @@ -22,6 +22,7 @@ define( require => { constructor() { // @public - Faucet icon, and rasterize to clip out invisible parts (like the ShooterNode) + // This exists for the lifetime of the sim and doesn't require disposal. this.faucetIcon = new FaucetNode( 1, new Property( 0 ), new Property( true ), { interactiveProperty: new Property( false ) } ).rasterized(); @@ -30,6 +31,7 @@ define( require => { this.speakerIcon = new Image( speakerImage ); // @public - Laser Pointer icon + // This exists for the lifetime of the sim and doesn't require disposal. this.laserPointerIcon = new LaserPointerNode( new BooleanProperty( false ), LightEmitterNode.DEFAULT_OPTIONS ); // Uniform sizing. diff --git a/js/common/view/WaveInterferenceSlider.js b/js/common/view/WaveInterferenceSlider.js index 3f7d6c8a..6503e1ba 100644 --- a/js/common/view/WaveInterferenceSlider.js +++ b/js/common/view/WaveInterferenceSlider.js @@ -1,7 +1,8 @@ // Copyright 2018, University of Colorado Boulder /** - * Slider abstraction for the frequency and amplitude sliders. + * Slider abstraction for the frequency and amplitude sliders. All instances exist for the lifetime of the sim + * and do not require disposal. * * @author Sam Reid (PhET Interactive Simulations) */ diff --git a/js/common/view/WaveMeterNode.js b/js/common/view/WaveMeterNode.js index 5fca4d6d..e46bfadf 100644 --- a/js/common/view/WaveMeterNode.js +++ b/js/common/view/WaveMeterNode.js @@ -114,6 +114,7 @@ define( require => { model.rotationAmountProperty.link( snapToCenter ); // Add the wire behind the probe. + // This exists for the lifetime of the sim and doesn't require disposal. this.addChild( new WireNode( connectionProperty, new Property( new Vector2( -NORMAL_DISTANCE, 0 ) ), new NodeProperty( probeNode, 'bounds', 'centerBottom' ), new Property( new Vector2( 0, NORMAL_DISTANCE ) ), { lineWidth: WIRE_LINE_WIDTH, @@ -127,7 +128,7 @@ define( require => { this.on( 'visibility', alignProbes ); this.alignProbesEmitter.addListener( alignProbes ); - const dynamicSeries = new DynamicSeries( { color } ); + const dynamicSeries = new DynamicSeries( { color: color } ); dynamicSeries.probeNode = probeNode; const updateSamples = function() { @@ -176,7 +177,10 @@ define( require => { return dynamicSeries; }; + // This exists for the lifetime of the sim and doesn't require disposal. const aboveBottomLeft1 = new DerivedProperty( [ leftBottomProperty ], position => position.isFinite() ? position.plusXY( 0, -20 ) : Vector2.ZERO ); + + // This exists for the lifetime of the sim and doesn't require disposal. const aboveBottomLeft2 = new DerivedProperty( [ leftBottomProperty ], position => position.isFinite() ? position.plusXY( 0, -10 ) : Vector2.ZERO ); const series1 = initializeSeries( SERIES_1_COLOR, WIRE_1_COLOR, 5, 10, aboveBottomLeft1 ); const series2 = initializeSeries( SERIES_2_COLOR, WIRE_2_COLOR, 36, 54, aboveBottomLeft2 ); @@ -198,7 +202,9 @@ define( require => { const timeProperty = new DynamicProperty( model.sceneProperty, { derive: 'timeProperty' } ); + const scrollingChartNode = new LabeledScrollingChartNode( + // This exists for the lifetime of the sim and doesn't require disposal. new ScrollingChartNode( timeProperty, [ series1, series2 ], { width: 150, height: 110 diff --git a/js/diffraction/view/DiffractionScreenView.js b/js/diffraction/view/DiffractionScreenView.js index 1a29b730..fb5aeee8 100644 --- a/js/diffraction/view/DiffractionScreenView.js +++ b/js/diffraction/view/DiffractionScreenView.js @@ -50,6 +50,8 @@ define( require => { // @private this.model = model; + + // This exists for the lifetime of the sim and doesn't require disposal. const laserPointerNode = new LaserPointerNode( model.onProperty, { left: 10, centerY: 50, @@ -72,6 +74,8 @@ define( require => { value: 'circle', node: new Circle( 10, { fill: 'black' } ) } ]; + + // This exists for the lifetime of the sim and doesn't require disposal. const radioButtonGroup = new RadioButtonGroup( model.sceneProperty, toggleButtonsContent, { left: 10, bottom: this.layoutBounds.bottom - 10 @@ -129,9 +133,13 @@ define( require => { this.squareControlPanel = new Panel( new VBox( { spacing: BOX_SPACING, children: [ + + // This exists for the lifetime of the sim and doesn't require disposal. new NumberControl( 'width', model.squareWidthProperty, new Range( 2, 30 ), _.extend( { delta: 2 // avoid odd/even artifacts }, NUMBER_CONTROL_OPTIONS ) ), + + // This exists for the lifetime of the sim and doesn't require disposal. new NumberControl( 'height', model.squareHeightProperty, new Range( 2, 30 ), _.extend( { delta: 2 // avoid odd/even artifacts }, NUMBER_CONTROL_OPTIONS ) ) ] @@ -143,7 +151,11 @@ define( require => { this.gaussianControlPanel = new Panel( new VBox( { spacing: BOX_SPACING, children: [ + + // This exists for the lifetime of the sim and doesn't require disposal. new NumberControl( 'sigmaX', model.sigmaXProperty, new Range( 2, 10 ), NUMBER_CONTROL_OPTIONS ), + + // This exists for the lifetime of the sim and doesn't require disposal. new NumberControl( 'sigmaY', model.sigmaYProperty, new Range( 2, 10 ), NUMBER_CONTROL_OPTIONS ) ] } ), _.extend( { @@ -154,7 +166,11 @@ define( require => { this.slitsControlPanel = new Panel( new VBox( { spacing: BOX_SPACING, children: [ + + // This exists for the lifetime of the sim and doesn't require disposal. new NumberControl( 'number of lines', model.numberOfLinesProperty, new Range( 2, 200 ), NUMBER_CONTROL_OPTIONS ), + + // This exists for the lifetime of the sim and doesn't require disposal. new NumberControl( 'angle', model.angleProperty, new Range( 0, Math.PI * 2 ), _.extend( { delta: 0.01 }, NUMBER_CONTROL_OPTIONS ) ) diff --git a/js/interference/view/InterferenceScreenView.js b/js/interference/view/InterferenceScreenView.js index 7d3b94e8..62221cec 100644 --- a/js/interference/view/InterferenceScreenView.js +++ b/js/interference/view/InterferenceScreenView.js @@ -33,8 +33,12 @@ define( require => { const createLabelText = string => new WaveInterferenceText( string, { fontSize: 10 } ); + // This exists for the lifetime of the sim and doesn't require disposal. + // TODO: use SceneToggleNode? const toggleNode = new ToggleNode( model.sceneProperty, [ { value: model.waterScene, + + // This exists for the lifetime of the sim and doesn't require disposal. node: new NumberControl( separationString, model.waterScene.desiredSourceSeparationProperty, new Range( 1, 5 ), _.extend( { delta: 1, valuePattern: cmValueString, @@ -45,6 +49,8 @@ define( require => { }, WaveInterferenceConstants.NUMBER_CONTROL_OPTIONS ) ) }, { value: model.soundScene, + + // This exists for the lifetime of the sim and doesn't require disposal. node: new NumberControl( separationString, model.soundScene.sourceSeparationProperty, new Range( 100, 200 ), _.extend( { delta: 5, valuePattern: cmValueString, @@ -54,6 +60,8 @@ define( require => { }, WaveInterferenceConstants.NUMBER_CONTROL_OPTIONS ) ) }, { value: model.lightScene, + + // This exists for the lifetime of the sim and doesn't require disposal. node: new NumberControl( separationString, model.lightScene.sourceSeparationProperty, new Range( 500, 2500 ), _.extend( { delta: 500, valuePattern: nmValueString, diff --git a/js/slits/view/BarriersNode.js b/js/slits/view/BarriersNode.js index 025d29e6..cb0a2e1a 100644 --- a/js/slits/view/BarriersNode.js +++ b/js/slits/view/BarriersNode.js @@ -69,6 +69,7 @@ define( require => { // @private - Convert from model coordinates to view coordinates this.modelViewTransform = ModelViewTransform2.createRectangleMapping( this.scene.getWaveAreaBounds(), viewBounds ); + // This exists for the lifetime of the sim and doesn't require disposal. this.addInputListener( new DragListener( { locationProperty: scene.barrierLocationProperty, transform: this.modelViewTransform, diff --git a/js/slits/view/SlitsControlPanel.js b/js/slits/view/SlitsControlPanel.js index 2ecf7cba..4ce53000 100644 --- a/js/slits/view/SlitsControlPanel.js +++ b/js/slits/view/SlitsControlPanel.js @@ -44,6 +44,8 @@ define( require => { derive: 'barrierTypeProperty', bidirectional: true } ); + + // This exists for the lifetime of the sim and doesn't require disposal. const comboBox = new ComboBox( [ ComboBox.createItem( new WaveInterferenceText( noBarrierString ), BarrierTypeEnum.NO_BARRIER ), ComboBox.createItem( new WaveInterferenceText( oneSlitString ), BarrierTypeEnum.ONE_SLIT ), @@ -60,22 +62,30 @@ define( require => { ]; const waterRange = new Range( 0, 5 ); + + // This exists for the lifetime of the sim and doesn't require disposal. const waterSlitWidthControl = new NumberControl( slitWidthString, model.waterScene.slitWidthProperty, waterRange, _.extend( { valuePattern: cmValueString, majorTicks: createTicks( waterRange ) }, WaveInterferenceConstants.NUMBER_CONTROL_OPTIONS ) ); const soundRange = new Range( 0, 100 ); + + // This exists for the lifetime of the sim and doesn't require disposal. const soundSlitWidthControl = new NumberControl( slitWidthString, model.soundScene.slitWidthProperty, soundRange, _.extend( { valuePattern: cmValueString, majorTicks: createTicks( soundRange ) }, WaveInterferenceConstants.NUMBER_CONTROL_OPTIONS ) ); const lightRange = new Range( 0, 2000 ); + + // This exists for the lifetime of the sim and doesn't require disposal. const lightSlitWidthControl = new NumberControl( slitWidthString, model.lightScene.slitWidthProperty, lightRange, _.extend( { valuePattern: nmValueString, majorTicks: createTicks( lightRange ) }, WaveInterferenceConstants.NUMBER_CONTROL_OPTIONS ) ); + + // This exists for the lifetime of the sim and doesn't require disposal. const slitWidthControl = new ToggleNode( model.sceneProperty, [ { value: model.waterScene, node: waterSlitWidthControl }, { value: model.soundScene, node: soundSlitWidthControl }, @@ -89,23 +99,30 @@ define( require => { } ); const waterSeparationRange = new Range( 0, 5 ); + + // This exists for the lifetime of the sim and doesn't require disposal. const waterSeparationControl = new NumberControl( slitSeparationString, model.waterScene.slitSeparationProperty, waterSeparationRange, _.extend( { valuePattern: cmValueString, majorTicks: createTicks( waterSeparationRange ) }, WaveInterferenceConstants.NUMBER_CONTROL_OPTIONS ) ); const soundSeparationRange = new Range( 0, 200 ); + + // This exists for the lifetime of the sim and doesn't require disposal. const soundSeparationControl = new NumberControl( slitSeparationString, model.soundScene.slitSeparationProperty, soundSeparationRange, _.extend( { valuePattern: cmValueString, majorTicks: createTicks( soundSeparationRange ) }, WaveInterferenceConstants.NUMBER_CONTROL_OPTIONS ) ); const lightSeparationRange = new Range( 0, 2000 ); + + // This exists for the lifetime of the sim and doesn't require disposal. const lightSeparationControl = new NumberControl( slitSeparationString, model.lightScene.slitSeparationProperty, lightSeparationRange, _.extend( { valuePattern: nmValueString, majorTicks: createTicks( lightSeparationRange ) }, WaveInterferenceConstants.NUMBER_CONTROL_OPTIONS ) ); + // This exists for the lifetime of the sim and doesn't require disposal. const slitSeparationControl = new ToggleNode( model.sceneProperty, [ { value: model.waterScene, node: waterSeparationControl }, { value: model.soundScene, node: soundSeparationControl }, diff --git a/js/slits/view/SlitsScreenView.js b/js/slits/view/SlitsScreenView.js index 33439356..e4ab2a40 100644 --- a/js/slits/view/SlitsScreenView.js +++ b/js/slits/view/SlitsScreenView.js @@ -36,6 +36,7 @@ define( require => { } ); // The Slits screen has an additional control panel below the main control panel, which controls the barrier/slits + // This exists for the lifetime of the sim and doesn't require disposal. const slitControlPanel = new SlitsControlPanel( alignGroup, model, this ); // When the alignGroup changes the size of the slitsControlPanel, readjust its positioning. Should only happen @@ -69,6 +70,8 @@ define( require => { // When enabled by a query parameter, show the theoretical interference pattern. if ( WaveInterferenceQueryParameters.theory ) { + + // This exists for the lifetime of the sim and doesn't require disposal. this.addChild( new TheoryInterferenceOverlay( model, this.waveAreaNode.bounds, { clipArea: Shape.bounds( this.waveAreaNode.bounds ) } ) ); diff --git a/js/waves/view/WavesScreenView.js b/js/waves/view/WavesScreenView.js index 355c12de..726ca626 100644 --- a/js/waves/view/WavesScreenView.js +++ b/js/waves/view/WavesScreenView.js @@ -216,6 +216,7 @@ define( require => { */ const toolboxContains = point => toolboxPanel.parentToGlobalBounds( toolboxPanel.bounds ).containsPoint( point ); + // This exists for the lifetime of the sim and doesn't require disposal. const measuringTapeNode = new MeasuringTapeNode( measuringTapeProperty, new BooleanProperty( true ), { // translucent white background, same value as in Projectile Motion, see https://github.com/phetsims/projectile-motion/issues/156 @@ -233,6 +234,7 @@ define( require => { } ); model.isMeasuringTapeInPlayAreaProperty.linkAttribute( measuringTapeNode, 'visible' ); + // This exists for the lifetime of the sim and doesn't require disposal. const timerNode = new WaveInterferenceTimerNode( model, { // Drop in toolbox @@ -309,6 +311,7 @@ define( require => { this.addChild( this.controlPanel ); if ( options.showPulseContinuousRadioButtons ) { + this.addChild( new SceneToggleNode( model, scene => new PulseContinuousRadioButtonGroup( scene.waveTemporalTypeProperty ), { bottom: this.layoutBounds.bottom - MARGIN, left: this.layoutBounds.left + MARGIN @@ -316,6 +319,8 @@ define( require => { } if ( options.showViewRadioButtonGroup ) { + + // This exists for the lifetime of the sim and doesn't require disposal. this.addChild( new ViewRadioButtonGroup( model.viewTypeProperty, { bottom: this.layoutBounds.bottom - MARGIN, left: this.waveAreaNode.left + SPACING + 10 @@ -400,6 +405,8 @@ define( require => { /** * Creates a ToggleNode that shows the primary or secondary source + * This exists for the lifetime of the sim and doesn't require disposal. + * TODO: use SceneToggleNode? * @param {boolean} isPrimarySource - true if it should show the primary source */ const createEmitterToggleNode = isPrimarySource => new ToggleNode( model.sceneProperty, [