Skip to content

Commit

Permalink
use isDisposable:false where appropriate, phetsims/axon#436
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jul 5, 2023
1 parent 6d53bc2 commit b5c901e
Show file tree
Hide file tree
Showing 36 changed files with 50 additions and 266 deletions.
1 change: 1 addition & 0 deletions js/common/FMWConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const PANEL_OPTIONS: PanelOptions = {
const WAVE_PACKET_NUMBER_CONTROL_OPTIONS: NumberControlOptions = {

// NumberControl options
isDisposable: false,
includeArrowButtons: false,
layoutFunction: ( titleNode: Node, numberDisplay: NumberDisplay, slider: Slider, leftArrowButton: ArrowButton | null, rightArrowButton: ArrowButton | null ): Node => new VBox( {
spacing: 5,
Expand Down
7 changes: 1 addition & 6 deletions js/common/model/FourierSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @author Chris Malley (PixelZoom, Inc.)
*/

import Disposable from '../../../../axon/js/Disposable.js';
import BooleanProperty from '../../../../axon/js/BooleanProperty.js';
import DerivedProperty, { UnknownDerivedProperty } from '../../../../axon/js/DerivedProperty.js';
import NumberProperty from '../../../../axon/js/NumberProperty.js';
Expand Down Expand Up @@ -77,6 +76,7 @@ export default class FourierSeries extends PhetioObject {
amplitudes: DEFAULT_AMPLITUDES, // {number[]} initial amplitudes for the harmonics

// PhetioObjectOptions
isDisposable: false,
phetioState: false
}, providedOptions );

Expand Down Expand Up @@ -131,11 +131,6 @@ export default class FourierSeries extends PhetioObject {
} );
}

public override dispose(): void {
Disposable.assertNotDisposable();
super.dispose();
}

/**
* Resets the Fourier series.
*/
Expand Down
7 changes: 1 addition & 6 deletions js/common/model/Harmonic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @author Chris Malley (PixelZoom, Inc.)
*/

import Disposable from '../../../../axon/js/Disposable.js';
import NumberProperty from '../../../../axon/js/NumberProperty.js';
import TReadOnlyProperty from '../../../../axon/js/TReadOnlyProperty.js';
import Range from '../../../../dot/js/Range.js';
Expand Down Expand Up @@ -61,6 +60,7 @@ export default class Harmonic extends PhetioObject {
amplitude: 0,

// PhetioObjectOptions
isDisposable: false,
phetioState: false
}, providedOptions );

Expand All @@ -84,11 +84,6 @@ export default class Harmonic extends PhetioObject {
} );
}

public override dispose(): void {
Disposable.assertNotDisposable();
super.dispose();
}

public reset(): void {
this.amplitudeProperty.reset();
}
Expand Down
7 changes: 1 addition & 6 deletions js/common/view/AmplitudeKeypadDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* @author Chris Malley (PixelZoom, Inc.)
*/

import Disposable from '../../../../axon/js/Disposable.js';
import NumberProperty from '../../../../axon/js/NumberProperty.js';
import PatternStringProperty from '../../../../axon/js/PatternStringProperty.js';
import Range from '../../../../dot/js/Range.js';
Expand Down Expand Up @@ -67,6 +66,7 @@ export default class AmplitudeKeypadDialog extends Dialog {
decimalPlaces: FMWConstants.DISCRETE_AMPLITUDE_DECIMAL_PLACES,

// DialogOptions
isDisposable: false,
closeButtonLength: 12,
cornerRadius: FMWConstants.PANEL_CORNER_RADIUS,
layoutStrategy: ( dialog: Dialog, simBounds: Bounds2, screenBounds: Bounds2, scale: number ) => {
Expand Down Expand Up @@ -223,11 +223,6 @@ export default class AmplitudeKeypadDialog extends Dialog {
this.closeCallback = null;
this.keypad.clear();
}

public override dispose(): void {
Disposable.assertNotDisposable();
super.dispose();
}
}

/**
Expand Down
7 changes: 1 addition & 6 deletions js/common/view/AmplitudeNumberDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* @author Chris Malley (PixelZoom, Inc.)
*/

import Disposable from '../../../../axon/js/Disposable.js';
import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import NumberDisplay, { NumberDisplayOptions } from '../../../../scenery-phet/js/NumberDisplay.js';
import PhetColorScheme from '../../../../scenery-phet/js/PhetColorScheme.js';
Expand Down Expand Up @@ -54,6 +53,7 @@ export default class AmplitudeNumberDisplay extends InteractiveHighlighting( VBo
},

// VBoxOptions
isDisposable: false,
cursor: 'pointer',
spacing: 2,
align: 'center',
Expand Down Expand Up @@ -127,11 +127,6 @@ export default class AmplitudeNumberDisplay extends InteractiveHighlighting( VBo
}
} );
}

public override dispose(): void {
Disposable.assertNotDisposable();
super.dispose();
}
}

fourierMakingWaves.register( 'AmplitudeNumberDisplay', AmplitudeNumberDisplay );
19 changes: 3 additions & 16 deletions js/common/view/AmplitudeSlider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* @author Chris Malley (PixelZoom, Inc.)
*/

import Disposable from '../../../../axon/js/Disposable.js';
import BooleanProperty from '../../../../axon/js/BooleanProperty.js';
import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import Dimension2 from '../../../../dot/js/Dimension2.js';
Expand Down Expand Up @@ -59,6 +58,7 @@ export default class AmplitudeSlider extends Slider {
mouseTouchStep: FMWConstants.DISCRETE_AMPLITUDE_STEP,

// SliderOptions
isDisposable: false,
startDrag: _.noop,
endDrag: _.noop,
orientation: Orientation.VERTICAL,
Expand Down Expand Up @@ -139,11 +139,6 @@ export default class AmplitudeSlider extends Slider {
this.visibleProperty.link( () => this.interruptSubtreeInput() );
}

public override dispose(): void {
Disposable.assertNotDisposable();
super.dispose();
}

/**
* Creates a non-interactive icon for an AmplitudeSlider.
*/
Expand Down Expand Up @@ -196,14 +191,10 @@ class GrippyThumb extends Node {

super( {
children: [ rectangle, dotsNode ],
isDisposable: false,
tandem: tandem
} );
}

public override dispose(): void {
Disposable.assertNotDisposable();
super.dispose();
}
}

/**
Expand Down Expand Up @@ -231,6 +222,7 @@ class BarTrack extends SliderTrack {
const options = optionize<BarTrackOptions, BarTrackSelfOptions, SliderTrackOptions>()( {

// SliderTrackOptions
isDisposable: false,
size: new Dimension2( 10, 10 )
}, providedOptions );

Expand Down Expand Up @@ -285,11 +277,6 @@ class BarTrack extends SliderTrack {
( isPressed, isOverVisible ) => ( isPressed || isOverVisible )
);
}

public override dispose(): void {
Disposable.assertNotDisposable();
super.dispose();
}
}

fourierMakingWaves.register( 'AmplitudeSlider', AmplitudeSlider );
11 changes: 4 additions & 7 deletions js/common/view/DomainChartNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* @author Chris Malley (PixelZoom, Inc.)
*/

import Disposable from '../../../../axon/js/Disposable.js';
import Multilink from '../../../../axon/js/Multilink.js';
import AxisLine, { AxisLineOptions } from '../../../../bamboo/js/AxisLine.js';
import ChartRectangle, { ChartRectangleOptions } from '../../../../bamboo/js/ChartRectangle.js';
Expand Down Expand Up @@ -152,7 +151,10 @@ export default class DomainChartNode extends Node {
},
yTickLabelSetOptions: {
edge: DEFAULT_EDGE
}
},

// NodeOptions
isDisposable: false
}, providedOptions );

// the transform between model and view coordinate frames
Expand Down Expand Up @@ -256,11 +258,6 @@ export default class DomainChartNode extends Node {
this.chartRectangle = chartRectangle;
}

public override dispose(): void {
Disposable.assertNotDisposable();
super.dispose();
}

/**
* Computes the clipArea that will trim any data that is outside of a given amplitude range.
* This is used to trim anomalies that occur when the x-axis is zoomed way out.
Expand Down
7 changes: 1 addition & 6 deletions js/common/view/DomainComboBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* @author Chris Malley (PixelZoom, Inc.)
*/

import Disposable from '../../../../axon/js/Disposable.js';
import { Node } from '../../../../scenery/js/imports.js';
import ComboBox from '../../../../sun/js/ComboBox.js';
import fourierMakingWaves from '../../fourierMakingWaves.js';
Expand Down Expand Up @@ -49,14 +48,10 @@ export default class DomainComboBox extends FMWComboBox<Domain> {
textOptions: {
maxWidth: 100 // determined empirically
},
isDisposable: false,
tandem: tandem
} );
}

public override dispose(): void {
Disposable.assertNotDisposable();
super.dispose();
}
}

fourierMakingWaves.register( 'DomainComboBox', DomainComboBox );
9 changes: 2 additions & 7 deletions js/common/view/InteractiveAmplitudesChartNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* @author Chris Malley (PixelZoom, Inc.)
*/

import Disposable from '../../../../axon/js/Disposable.js';
import ChartRectangle from '../../../../bamboo/js/ChartRectangle.js';
import ChartTransform, { ChartTransformOptions } from '../../../../bamboo/js/ChartTransform.js';
import GridLineSet from '../../../../bamboo/js/GridLineSet.js';
Expand Down Expand Up @@ -73,7 +72,8 @@ export default class InteractiveAmplitudesChartNode extends Node {
chartTransformOptions: {
viewWidth: FMWConstants.CHART_RECTANGLE_SIZE.width,
viewHeight: FMWConstants.CHART_RECTANGLE_SIZE.height
}
},
isDisposable: false
}, providedOptions );

assert && assert( !options.chartTransformOptions.modelXRange, 'InteractiveAmplitudesChartNode sets modelXRange' );
Expand Down Expand Up @@ -184,11 +184,6 @@ export default class InteractiveAmplitudesChartNode extends Node {
this.slidersParent = slidersParent;
this.numberDisplays = numberDisplays;
}

public override dispose(): void {
Disposable.assertNotDisposable();
super.dispose();
}
}

fourierMakingWaves.register( 'InteractiveAmplitudesChartNode', InteractiveAmplitudesChartNode );
11 changes: 3 additions & 8 deletions js/common/view/MeasurementToolsKeyboardHelpSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* @author Chris Malley (PixelZoom, Inc.)
*/

import Disposable from '../../../../axon/js/Disposable.js';
import KeyboardHelpIconFactory from '../../../../scenery-phet/js/keyboard/help/KeyboardHelpIconFactory.js';
import KeyboardHelpSection from '../../../../scenery-phet/js/keyboard/help/KeyboardHelpSection.js';
import KeyboardHelpSectionRow from '../../../../scenery-phet/js/keyboard/help/KeyboardHelpSectionRow.js';
Expand Down Expand Up @@ -41,13 +40,9 @@ export default class MeasurementToolsKeyboardHelpSection extends KeyboardHelpSec
[ shiftPlusArrowsIcon, shiftPlusWASDsIcon ] )
];

super( FourierMakingWavesStrings.keyboardHelpDialog.measurementToolsStringProperty, rows );
}

// See https://github.com/phetsims/fourier-making-waves/issues/236
public override dispose(): void {
Disposable.assertNotDisposable();
super.dispose();
super( FourierMakingWavesStrings.keyboardHelpDialog.measurementToolsStringProperty, rows, {
isDisposable: false // see https://github.com/phetsims/fourier-making-waves/issues/236
} );
}
}

Expand Down
7 changes: 1 addition & 6 deletions js/discrete/DiscreteScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* @author Chris Malley (PixelZoom, Inc.
*/

import Disposable from '../../../axon/js/Disposable.js';
import Screen from '../../../joist/js/Screen.js';
import Tandem from '../../../tandem/js/Tandem.js';
import FMWColors from '../common/FMWColors.js';
Expand All @@ -26,6 +25,7 @@ export default class DiscreteScreen extends Screen<DiscreteModel, DiscreteScreen
backgroundColorProperty: FMWColors.discreteScreenBackgroundColorProperty,
homeScreenIcon: FMWIconFactory.createDiscreteHomeScreenIcon(),
createKeyboardHelpNode: () => new DiscreteKeyboardHelpContent(),
isDisposable: false,
tandem: tandem
};

Expand All @@ -35,11 +35,6 @@ export default class DiscreteScreen extends Screen<DiscreteModel, DiscreteScreen
options
);
}

public override dispose(): void {
Disposable.assertNotDisposable();
super.dispose();
}
}

fourierMakingWaves.register( 'DiscreteScreen', DiscreteScreen );
Loading

0 comments on commit b5c901e

Please sign in to comment.