Skip to content

Commit d538c9d

Browse files
committed
Rename DisturbanceTypeEnum => DisturbanceType and move to Scene, see phetsims/phet-core#53
1 parent 5c47f1e commit d538c9d

6 files changed

+31
-42
lines changed

js/common/model/DisturbanceTypeEnum.js

-16
This file was deleted.

js/common/model/Scene.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ define( require => {
1515
const BooleanProperty = require( 'AXON/BooleanProperty' );
1616
const Bounds2 = require( 'DOT/Bounds2' );
1717
const DerivedProperty = require( 'AXON/DerivedProperty' );
18-
const DisturbanceTypeEnum = require( 'WAVE_INTERFERENCE/common/model/DisturbanceTypeEnum' );
18+
const Enumeration = require( 'PHET_CORE/Enumeration' );
1919
const Lattice = require( 'WAVE_INTERFERENCE/common/model/Lattice' );
2020
const ModelViewTransform2 = require( 'PHETCOMMON/view/ModelViewTransform2' );
2121
const NumberProperty = require( 'AXON/NumberProperty' );
@@ -241,8 +241,8 @@ define( require => {
241241
);
242242

243243
// @public - pulse or continuous
244-
this.disturbanceTypeProperty = new Property( DisturbanceTypeEnum.CONTINUOUS, {
245-
validValues: DisturbanceTypeEnum.VALUES
244+
this.disturbanceTypeProperty = new Property( Scene.DisturbanceType.CONTINUOUS, {
245+
validValues: Scene.DisturbanceType.VALUES
246246
} );
247247

248248
// The first button can trigger a pulse, or continuous wave, depending on the disturbanceTypeProperty
@@ -393,7 +393,7 @@ define( require => {
393393
const period = 1 / frequency;
394394
const timeSincePulseStarted = time - this.pulseStartTime;
395395
const lattice = this.lattice;
396-
const isContinuous = ( this.disturbanceTypeProperty.get() === DisturbanceTypeEnum.CONTINUOUS );
396+
const isContinuous = ( this.disturbanceTypeProperty.get() === Scene.DisturbanceType.CONTINUOUS );
397397
const continuous1 = isContinuous && this.continuousWave1OscillatingProperty.get();
398398
const continuous2 = isContinuous && this.continuousWave2OscillatingProperty.get();
399399

@@ -689,7 +689,7 @@ define( require => {
689689
if ( isPressed && !this.button2PressedProperty.value ) {
690690
this.resetPhase();
691691
}
692-
if ( isPressed && this.disturbanceTypeProperty.value === DisturbanceTypeEnum.PULSE ) {
692+
if ( isPressed && this.disturbanceTypeProperty.value === Scene.DisturbanceType.PULSE ) {
693693
this.startPulse();
694694
}
695695
else {
@@ -772,5 +772,11 @@ define( require => {
772772
}
773773
}
774774

775+
/**
776+
* A wave can be ongoing (CONTINUOUS) or a single wavelength (PULSE)
777+
* @public
778+
*/
779+
Scene.DisturbanceType = new Enumeration( [ 'PULSE', 'CONTINUOUS' ] );
780+
775781
return waveInterference.register( 'Scene', Scene );
776782
} );

js/common/model/WaterScene.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ define( require => {
1010

1111
// modules
1212
const arrayRemove = require( 'PHET_CORE/arrayRemove' );
13-
const DisturbanceTypeEnum = require( 'WAVE_INTERFERENCE/common/model/DisturbanceTypeEnum' );
1413
const NumberProperty = require( 'AXON/NumberProperty' );
1514
const Scene = require( 'WAVE_INTERFERENCE/common/model/Scene' );
1615
const WaterDrop = require( 'WAVE_INTERFERENCE/common/model/WaterDrop' );
@@ -84,15 +83,15 @@ define( require => {
8483
// Send a water drop if the button is pressed but not if the button is still pressed from the last pulse.
8584
// model.button1PressedProperty.value not consulted because we send a shutoff water drop. so that the previous
8685
// drop gets a full cycle
87-
const isPulseMode = this.disturbanceTypeProperty.value === DisturbanceTypeEnum.PULSE;
86+
const isPulseMode = this.disturbanceTypeProperty.value === Scene.DisturbanceType.PULSE;
8887
const firePulseDrop = isPulseMode && !this.pulseFiringProperty.value && this.button1PressedProperty.value;
8988
if ( !isPulseMode || firePulseDrop ) {
9089

9190
// capture closure vars for when the water drop is absorbed.
9291
const buttonPressed = buttonProperty.value;
9392
const frequency = this.desiredFrequencyProperty.value;
9493
const amplitude = this.desiredAmplitudeProperty.value;
95-
const isPulse = this.disturbanceTypeProperty.value === DisturbanceTypeEnum.PULSE;
94+
const isPulse = this.disturbanceTypeProperty.value === Scene.DisturbanceType.PULSE;
9695

9796
// Distance between the sources, or 0 if there is only 1 source
9897
const sourceSeparation = this.numberOfSources === 2 ? this.desiredSourceSeparationProperty.value : 0;

js/common/view/DisturbanceTypeIconNode.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ define( require => {
99
'use strict';
1010

1111
// modules
12-
const DisturbanceTypeEnum = require( 'WAVE_INTERFERENCE/common/model/DisturbanceTypeEnum' );
1312
const LineStyles = require( 'KITE/util/LineStyles' );
1413
const Node = require( 'SCENERY/nodes/Node' );
1514
const Path = require( 'SCENERY/nodes/Path' );
15+
const Scene = require( 'WAVE_INTERFERENCE/common/model/Scene' );
1616
const Shape = require( 'KITE/Shape' );
1717
const Util = require( 'DOT/Util' );
1818
const waveInterference = require( 'WAVE_INTERFERENCE/waveInterference' );
@@ -27,7 +27,7 @@ define( require => {
2727
class DisturbanceTypeIconNode extends Node {
2828

2929
/**
30-
* @param {DisturbanceTypeEnum} disturbanceType
30+
* @param {Scene.DisturbanceType} disturbanceType
3131
* @param {Object} [options]
3232
*/
3333
constructor( disturbanceType, options ) {
@@ -37,17 +37,17 @@ define( require => {
3737
}, options );
3838
super();
3939

40-
const minAngle = disturbanceType === DisturbanceTypeEnum.PULSE ? Math.PI : 0;
41-
const minX = disturbanceType === DisturbanceTypeEnum.PULSE ? MARGIN : 0;
42-
const maxX = disturbanceType === DisturbanceTypeEnum.PULSE ? ( WIDTH - MARGIN ) : WIDTH;
40+
const minAngle = disturbanceType === Scene.DisturbanceType.PULSE ? Math.PI : 0;
41+
const minX = disturbanceType === Scene.DisturbanceType.PULSE ? MARGIN : 0;
42+
const maxX = disturbanceType === Scene.DisturbanceType.PULSE ? ( WIDTH - MARGIN ) : WIDTH;
4343

4444
const shape = new Shape();
4545
for ( let i = 0; i < NUMBER_OF_SAMPLES; i++ ) {
4646
const angle = Util.linear( 0, NUMBER_OF_SAMPLES - 1, minAngle, MAX_ANGLE, i );
4747
const y = -Math.cos( angle ) * WAVE_HEIGHT;
4848
const x = Util.linear( minAngle, MAX_ANGLE, minX, maxX, angle );
4949
if ( i === 0 ) {
50-
if ( disturbanceType === DisturbanceTypeEnum.PULSE ) {
50+
if ( disturbanceType === Scene.DisturbanceType.PULSE ) {
5151
shape.moveTo( x - MARGIN, y );
5252
shape.lineTo( x, y );
5353
}
@@ -59,7 +59,7 @@ define( require => {
5959
shape.lineTo( x, y );
6060
}
6161
}
62-
if ( disturbanceType === DisturbanceTypeEnum.PULSE ) {
62+
if ( disturbanceType === Scene.DisturbanceType.PULSE ) {
6363
shape.lineToRelative( MARGIN, 0 );
6464
}
6565

js/common/view/DisturbanceTypeRadioButtonGroup.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ define( require => {
99
'use strict';
1010

1111
// modules
12-
const DisturbanceTypeEnum = require( 'WAVE_INTERFERENCE/common/model/DisturbanceTypeEnum' );
1312
const DisturbanceTypeIconNode = require( 'WAVE_INTERFERENCE/common/view/DisturbanceTypeIconNode' );
1413
const RadioButtonGroup = require( 'SUN/buttons/RadioButtonGroup' );
14+
const Scene = require( 'WAVE_INTERFERENCE/common/model/Scene' );
1515
const waveInterference = require( 'WAVE_INTERFERENCE/waveInterference' );
1616

1717
class DisturbanceTypeRadioButtonGroup extends RadioButtonGroup {
1818

1919
/**
20-
* @param {Property.<DisturbanceTypeEnum>} disturbanceTypeProperty
20+
* @param {Property.<Scene.DisturbanceType>} disturbanceTypeProperty
2121
* @param {Object} [options]
2222
*/
2323
constructor( disturbanceTypeProperty, options ) {
2424
super( disturbanceTypeProperty, [ {
25-
value: DisturbanceTypeEnum.CONTINUOUS,
26-
node: new DisturbanceTypeIconNode( DisturbanceTypeEnum.CONTINUOUS )
25+
value: Scene.DisturbanceType.CONTINUOUS,
26+
node: new DisturbanceTypeIconNode( Scene.DisturbanceType.CONTINUOUS )
2727
}, {
28-
value: DisturbanceTypeEnum.PULSE,
29-
node: new DisturbanceTypeIconNode( DisturbanceTypeEnum.PULSE )
28+
value: Scene.DisturbanceType.PULSE,
29+
node: new DisturbanceTypeIconNode( Scene.DisturbanceType.PULSE )
3030
} ], _.extend( {
3131
orientation: 'vertical',
3232
buttonContentXMargin: 1,

js/common/view/WaveGeneratorNode.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ define( require => {
99
'use strict';
1010

1111
// modules
12-
const DisturbanceTypeEnum = require( 'WAVE_INTERFERENCE/common/model/DisturbanceTypeEnum' );
1312
const DisturbanceTypeIconNode = require( 'WAVE_INTERFERENCE/common/view/DisturbanceTypeIconNode' );
1413
const Node = require( 'SCENERY/nodes/Node' );
1514
const RoundStickyToggleButton = require( 'SUN/buttons/RoundStickyToggleButton' );
15+
const Scene = require( 'WAVE_INTERFERENCE/common/model/Scene' );
1616
const ShadedSphereNode = require( 'SCENERY_PHET/ShadedSphereNode' );
1717
const waveInterference = require( 'WAVE_INTERFERENCE/waveInterference' );
1818
const WaveInterferenceConstants = require( 'WAVE_INTERFERENCE/common/WaveInterferenceConstants' );
@@ -33,7 +33,7 @@ define( require => {
3333
verticalOffset = 0,
3434
buttonOffset = 0,
3535
showButtonBackground = false ) {
36-
const pulseIcon = new DisturbanceTypeIconNode( DisturbanceTypeEnum.PULSE, {
36+
const pulseIcon = new DisturbanceTypeIconNode( Scene.DisturbanceType.PULSE, {
3737
scale: 0.36,
3838
stroked: true
3939
} );
@@ -69,17 +69,17 @@ define( require => {
6969
const nodeWithButton = new Node( { children: children } );
7070

7171
const updateEnabled = () => {
72-
if ( scene.disturbanceTypeProperty.value === DisturbanceTypeEnum.PULSE ) {
72+
if ( scene.disturbanceTypeProperty.value === Scene.DisturbanceType.PULSE ) {
7373
button.enabled = !scene.pulseFiringProperty.value && !scene.isAboutToFireProperty.value;
7474
}
75-
else if ( scene.disturbanceTypeProperty.value === DisturbanceTypeEnum.CONTINUOUS ) {
75+
else if ( scene.disturbanceTypeProperty.value === Scene.DisturbanceType.CONTINUOUS ) {
7676
button.enabled = true;
7777
}
7878
};
7979

8080
// When changing between PULSE and CONTINUOUS, update the buttons.
8181
scene.disturbanceTypeProperty.link( disturbanceType => {
82-
pulseIcon.visible = disturbanceType === DisturbanceTypeEnum.PULSE;
82+
pulseIcon.visible = disturbanceType === Scene.DisturbanceType.PULSE;
8383
updateEnabled();
8484
}
8585
);

0 commit comments

Comments
 (0)