Skip to content

Commit

Permalink
Add Enum suffix, see #273
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Dec 20, 2018
1 parent b792041 commit 6fbfce5
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ define( require => {
const Enumeration = require( 'PHET_CORE/Enumeration' );
const waveInterference = require( 'WAVE_INTERFERENCE/waveInterference' );

return waveInterference.register( 'DisturbanceType', new Enumeration( [ 'PULSE', 'CONTINUOUS' ] ) );
return waveInterference.register( 'DisturbanceTypeEnum', new Enumeration( [ 'PULSE', 'CONTINUOUS' ] ) );
} );
28 changes: 14 additions & 14 deletions js/common/model/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ define( require => {
const BooleanProperty = require( 'AXON/BooleanProperty' );
const Bounds2 = require( 'DOT/Bounds2' );
const DerivedProperty = require( 'AXON/DerivedProperty' );
const DisturbanceType = require( 'WAVE_INTERFERENCE/common/model/DisturbanceType' );
const DisturbanceTypeEnum = require( 'WAVE_INTERFERENCE/common/model/DisturbanceTypeEnum' );
const Lattice = require( 'WAVE_INTERFERENCE/common/model/Lattice' );
const ModelViewTransform2 = require( 'PHETCOMMON/view/ModelViewTransform2' );
const NumberProperty = require( 'AXON/NumberProperty' );
const Property = require( 'AXON/Property' );
const Range = require( 'DOT/Range' );
const Rectangle = require( 'DOT/Rectangle' );
const SceneType = require( 'WAVE_INTERFERENCE/common/model/SceneType' );
const SceneTypeEnum = require( 'WAVE_INTERFERENCE/common/model/SceneTypeEnum' );
const StringUtils = require( 'PHETCOMMON/util/StringUtils' );
const Util = require( 'DOT/Util' );
const Vector2 = require( 'DOT/Vector2' );
const waveInterference = require( 'WAVE_INTERFERENCE/waveInterference' );
const WaveInterferenceConstants = require( 'WAVE_INTERFERENCE/common/WaveInterferenceConstants' );
const WaveSpatialType = require( 'WAVE_INTERFERENCE/common/model/WaveSpatialType' );
const WaveSpatialTypeEnum = require( 'WAVE_INTERFERENCE/common/model/WaveSpatialTypeEnum' );

// strings
const distanceUnitsString = require( 'string!WAVE_INTERFERENCE/distanceUnits' );
Expand All @@ -44,7 +44,7 @@ define( require => {
*/
constructor( config ) {

// @public {WaveSpatialType}
// @public {WaveSpatialTypeEnum}
this.waveSpatialType = config.waveSpatialType;

// @public - the grid that contains the wave values
Expand Down Expand Up @@ -174,17 +174,17 @@ define( require => {
} );

// @public - pulse or continuous
this.disturbanceTypeProperty = new Property( DisturbanceType.CONTINUOUS, {
validValues: DisturbanceType.VALUES
this.disturbanceTypeProperty = new Property( DisturbanceTypeEnum.CONTINUOUS, {
validValues: DisturbanceTypeEnum.VALUES
} );

// The first button can trigger a pulse, or continuous wave, depending on the disturbanceTypeProperty
this.button1PressedProperty.lazyLink( isPressed => {
if ( config.sceneType !== SceneType.WATER ) {
if ( config.sceneType !== SceneTypeEnum.WATER ) {
if ( isPressed ) {
this.resetPhase();
}
if ( isPressed && this.disturbanceTypeProperty.value === DisturbanceType.PULSE ) {
if ( isPressed && this.disturbanceTypeProperty.value === DisturbanceTypeEnum.PULSE ) {
this.startPulse();
}
else {
Expand All @@ -195,15 +195,15 @@ define( require => {
}

// Clear plane waves if the red button is deselected when paused.
if ( this.waveSpatialType === WaveSpatialType.PLANE && !isPressed ) {
if ( this.waveSpatialType === WaveSpatialTypeEnum.PLANE && !isPressed ) {
this.setSourceValues();
this.lattice.changedEmitter.emit();
}
} );

// The 2nd button starts the second continuous wave
this.button2PressedProperty.lazyLink( isPressed => {
if ( config.sceneType === SceneType.SOUND || config.sceneType === SceneType.LIGHT ) {
if ( config.sceneType === SceneTypeEnum.SOUND || config.sceneType === SceneTypeEnum.LIGHT ) {
if ( isPressed ) {
this.resetPhase();
}
Expand Down Expand Up @@ -269,14 +269,14 @@ define( require => {
this.phase = proposedPhase;

// The wave area resets when the wavelength changes in the light scene
if ( config.sceneType === SceneType.LIGHT ) {
if ( config.sceneType === SceneTypeEnum.LIGHT ) {
this.clear();
}
};
this.frequencyProperty.lazyLink( phaseUpdate );

// Everything below here is just for plane wave screen.
if ( this.waveSpatialType === WaveSpatialType.PLANE ) {
if ( this.waveSpatialType === WaveSpatialTypeEnum.PLANE ) {

// @public - type of the barrier in the lattice
this.barrierTypeProperty = new Property( BarrierTypeEnum.ONE_SLIT, {
Expand Down Expand Up @@ -342,12 +342,12 @@ define( require => {
// scenes, this is set through the amplitudeProperty.
const amplitude = this.desiredAmplitudeProperty ? this.desiredAmplitudeProperty.get() : this.amplitudeProperty.get();
const time = this.timeProperty.value;
if ( this.waveSpatialType === WaveSpatialType.POINT ) {
if ( this.waveSpatialType === WaveSpatialTypeEnum.POINT ) {
const frequency = this.frequencyProperty.get();
const period = 1 / frequency;
const timeSincePulseStarted = time - this.pulseStartTime;
const lattice = this.lattice;
const isContinuous = ( this.disturbanceTypeProperty.get() === DisturbanceType.CONTINUOUS );
const isContinuous = ( this.disturbanceTypeProperty.get() === DisturbanceTypeEnum.CONTINUOUS );
const continuous1 = isContinuous && this.continuousWave1OscillatingProperty.get();
const continuous2 = isContinuous && this.continuousWave2OscillatingProperty.get();
if ( continuous1 || continuous2 || this.pulseFiringProperty.get() ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ define( require => {
const Enumeration = require( 'PHET_CORE/Enumeration' );
const waveInterference = require( 'WAVE_INTERFERENCE/waveInterference' );

return waveInterference.register( 'SceneType', new Enumeration( [ 'WATER', 'SOUND', 'LIGHT' ] ) );
return waveInterference.register( 'SceneTypeEnum', new Enumeration( [ 'WATER', 'SOUND', 'LIGHT' ] ) );
} );
6 changes: 3 additions & 3 deletions js/common/model/SoundScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ define( require => {
const Property = require( 'AXON/Property' );
const Scene = require( 'WAVE_INTERFERENCE/common/model/Scene' );
const SoundParticle = require( 'WAVE_INTERFERENCE/common/model/SoundParticle' );
const SoundViewType = require( 'WAVE_INTERFERENCE/common/model/SoundViewType' );
const SoundViewTypeEnum = require( 'WAVE_INTERFERENCE/common/model/SoundViewTypeEnum' );
const Util = require( 'DOT/Util' );
const waveInterference = require( 'WAVE_INTERFERENCE/waveInterference' );

Expand All @@ -36,8 +36,8 @@ define( require => {
this.showSoundParticles = showSoundParticles;

// @public - indicates the selected view for sound
this.viewSelectionProperty = new Property( SoundViewType.WAVES, {
validValues: SoundViewType.VALUES
this.viewSelectionProperty = new Property( SoundViewTypeEnum.WAVES, {
validValues: SoundViewTypeEnum.VALUES
} );

// @public (read-only) {SoundParticle[]} particles for the sound scene.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ define( require => {
const Enumeration = require( 'PHET_CORE/Enumeration' );
const waveInterference = require( 'WAVE_INTERFERENCE/waveInterference' );

return waveInterference.register( 'SoundViewType', new Enumeration( [ 'WAVES', 'PARTICLES', 'BOTH' ] ) );
return waveInterference.register( 'SoundViewTypeEnum', new Enumeration( [ 'WAVES', 'PARTICLES', 'BOTH' ] ) );
} );
10 changes: 5 additions & 5 deletions js/common/model/WaterScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ define( require => {
const Scene = require( 'WAVE_INTERFERENCE/common/model/Scene' );
const WaterDrop = require( 'WAVE_INTERFERENCE/common/model/WaterDrop' );
const waveInterference = require( 'WAVE_INTERFERENCE/waveInterference' );
const WaveSpatialType = require( 'WAVE_INTERFERENCE/common/model/WaveSpatialType' );
const DisturbanceType = require( 'WAVE_INTERFERENCE/common/model/DisturbanceType' );
const WaveSpatialTypeEnum = require( 'WAVE_INTERFERENCE/common/model/WaveSpatialTypeEnum' );
const DisturbanceTypeEnum = require( 'WAVE_INTERFERENCE/common/model/DisturbanceTypeEnum' );

class WaterScene extends Scene {

Expand Down Expand Up @@ -77,15 +77,15 @@ define( require => {
// Send a water drop if the button is pressed but not if the button is still pressed from the last pulse.
// model.button1PressedProperty.value not consulted because we send a shutoff water drop. so that the previous
// drop gets a full cycle
const isPulseMode = this.disturbanceTypeProperty.value === DisturbanceType.PULSE;
const isPulseMode = this.disturbanceTypeProperty.value === DisturbanceTypeEnum.PULSE;
const firePulseDrop = isPulseMode && !this.pulseFiringProperty.value && this.button1PressedProperty.value;
if ( !isPulseMode || firePulseDrop ) {

// capture closure vars for when the water drop is absorbed.
const buttonPressed = buttonProperty.value;
const frequency = this.desiredFrequencyProperty.value;
const amplitude = this.desiredAmplitudeProperty.value;
const isPulse = this.disturbanceTypeProperty.value === DisturbanceType.PULSE;
const isPulse = this.disturbanceTypeProperty.value === DisturbanceTypeEnum.PULSE;
const sourceSeparation = this.desiredSourceSeparationProperty.value;
this.waterDrops.push( new WaterDrop(
amplitude,
Expand Down Expand Up @@ -134,7 +134,7 @@ define( require => {
const timeSinceLastDrop = time - this.lastDropTime;

// Emit water drops if the phase matches up, but not for the plane waves screen
if ( this.waveSpatialType === WaveSpatialType.POINT &&
if ( this.waveSpatialType === WaveSpatialTypeEnum.POINT &&
( this.lastDropTime === null || timeSinceLastDrop > period ) ) {

this.launchWaterDrop( this.button1PressedProperty, this.continuousWave1OscillatingProperty, +1 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ define( require => {
const Enumeration = require( 'PHET_CORE/Enumeration' );
const waveInterference = require( 'WAVE_INTERFERENCE/waveInterference' );

return waveInterference.register( 'WaveSpatialType', new Enumeration( [ 'POINT', 'PLANE' ] ) );
return waveInterference.register( 'WaveSpatialTypeEnum', new Enumeration( [ 'POINT', 'PLANE' ] ) );
} );
14 changes: 7 additions & 7 deletions js/common/view/DisturbanceTypeIconNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define( require => {
const Shape = require( 'KITE/Shape' );
const Util = require( 'DOT/Util' );
const waveInterference = require( 'WAVE_INTERFERENCE/waveInterference' );
const DisturbanceType = require( 'WAVE_INTERFERENCE/common/model/DisturbanceType' );
const DisturbanceTypeEnum = require( 'WAVE_INTERFERENCE/common/model/DisturbanceTypeEnum' );

// constants
const NUMBER_OF_SAMPLES = 100; // Number of samples to take along the curve
Expand All @@ -26,23 +26,23 @@ define( require => {
class DisturbanceTypeIconNode extends Node {

/**
* @param {DisturbanceType} disturbanceType
* @param {DisturbanceTypeEnum} disturbanceType
* @param {Object} [options]
*/
constructor( disturbanceType, options ) {
super();

const minAngle = disturbanceType === DisturbanceType.PULSE ? Math.PI : 0;
const minX = disturbanceType === DisturbanceType.PULSE ? MARGIN : 0;
const maxX = disturbanceType === DisturbanceType.PULSE ? ( WIDTH - MARGIN ) : WIDTH;
const minAngle = disturbanceType === DisturbanceTypeEnum.PULSE ? Math.PI : 0;
const minX = disturbanceType === DisturbanceTypeEnum.PULSE ? MARGIN : 0;
const maxX = disturbanceType === DisturbanceTypeEnum.PULSE ? ( WIDTH - MARGIN ) : WIDTH;

const shape = new Shape();
for ( let i = 0; i < NUMBER_OF_SAMPLES; i++ ) {
const angle = Util.linear( 0, NUMBER_OF_SAMPLES - 1, minAngle, MAX_ANGLE, i );
const y = -Math.cos( angle ) * WAVE_HEIGHT;
const x = Util.linear( minAngle, MAX_ANGLE, minX, maxX, angle );
if ( i === 0 ) {
if ( disturbanceType === DisturbanceType.PULSE ) {
if ( disturbanceType === DisturbanceTypeEnum.PULSE ) {
shape.moveTo( x - MARGIN, y );
shape.lineTo( x, y );
}
Expand All @@ -54,7 +54,7 @@ define( require => {
shape.lineTo( x, y );
}
}
if ( disturbanceType === DisturbanceType.PULSE ) {
if ( disturbanceType === DisturbanceTypeEnum.PULSE ) {
shape.lineToRelative( MARGIN, 0 );
}

Expand Down
12 changes: 6 additions & 6 deletions js/common/view/DisturbanceTypeRadioButtonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ define( require => {
const DisturbanceTypeIconNode = require( 'WAVE_INTERFERENCE/common/view/DisturbanceTypeIconNode' );
const RadioButtonGroup = require( 'SUN/buttons/RadioButtonGroup' );
const waveInterference = require( 'WAVE_INTERFERENCE/waveInterference' );
const DisturbanceType = require( 'WAVE_INTERFERENCE/common/model/DisturbanceType' );
const DisturbanceTypeEnum = require( 'WAVE_INTERFERENCE/common/model/DisturbanceTypeEnum' );

class DisturbanceTypeRadioButtonGroup extends RadioButtonGroup {

/**
* @param {Property.<DisturbanceType>} disturbanceTypeProperty
* @param {Property.<DisturbanceTypeEnum>} disturbanceTypeProperty
* @param {Object} [options]
*/
constructor( disturbanceTypeProperty, options ) {
super( disturbanceTypeProperty, [ {
value: DisturbanceType.CONTINUOUS,
node: new DisturbanceTypeIconNode( DisturbanceType.CONTINUOUS )
value: DisturbanceTypeEnum.CONTINUOUS,
node: new DisturbanceTypeIconNode( DisturbanceTypeEnum.CONTINUOUS )
}, {
value: DisturbanceType.PULSE,
node: new DisturbanceTypeIconNode( DisturbanceType.PULSE )
value: DisturbanceTypeEnum.PULSE,
node: new DisturbanceTypeIconNode( DisturbanceTypeEnum.PULSE )
} ], _.extend( {
orientation: 'vertical',
buttonContentXMargin: 0,
Expand Down
12 changes: 6 additions & 6 deletions js/common/view/WaveGeneratorNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ define( require => {
const ShadedSphereNode = require( 'SCENERY_PHET/ShadedSphereNode' );
const waveInterference = require( 'WAVE_INTERFERENCE/waveInterference' );
const WaveInterferenceConstants = require( 'WAVE_INTERFERENCE/common/WaveInterferenceConstants' );
const DisturbanceType = require( 'WAVE_INTERFERENCE/common/model/DisturbanceType' );
const DisturbanceTypeEnum = require( 'WAVE_INTERFERENCE/common/model/DisturbanceTypeEnum' );

class WaveGeneratorNode extends Node {

Expand All @@ -35,7 +35,7 @@ define( require => {
verticalOffset = 0,
buttonOffset = 0,
showButtonBackground = false ) {
const pulseIcon = new DisturbanceTypeIconNode( DisturbanceType.PULSE, { scale: 0.48 } );
const pulseIcon = new DisturbanceTypeIconNode( DisturbanceTypeEnum.PULSE, { scale: 0.48 } );

const buttonOptions = {
centerY: sourceNode.centerY + buttonOffset,
Expand Down Expand Up @@ -68,20 +68,20 @@ define( require => {
const nodeWithButton = new Node( { children: children } );

const updateEnabled = () => {
if ( scene.disturbanceTypeProperty.value === DisturbanceType.PULSE ) {
if ( scene.disturbanceTypeProperty.value === DisturbanceTypeEnum.PULSE ) {
button.enabled = !scene.pulseFiringProperty.value && !scene.isAboutToFireProperty.value;
}
else if ( scene.disturbanceTypeProperty.value === DisturbanceType.CONTINUOUS ) {
else if ( scene.disturbanceTypeProperty.value === DisturbanceTypeEnum.CONTINUOUS ) {
button.enabled = true;
}
};

// When changing between PULSE and CONTINUOUS, update the buttons.
scene.disturbanceTypeProperty.link( disturbanceType => {
button.setBaseColor( disturbanceType === DisturbanceType.CONTINUOUS ?
button.setBaseColor( disturbanceType === DisturbanceTypeEnum.CONTINUOUS ?
WaveInterferenceConstants.CONTINUOUS_DISTURBANCE_BUTTON_COLOR :
WaveInterferenceConstants.PULSE_DISTURBANCE_BUTTON_COLOR );
pulseIcon.visible = disturbanceType === DisturbanceType.PULSE;
pulseIcon.visible = disturbanceType === DisturbanceTypeEnum.PULSE;
updateEnabled();
}
);
Expand Down
8 changes: 4 additions & 4 deletions js/common/view/WaveInterferenceControlPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ define( require => {
const Property = require( 'AXON/Property' );
const SceneToggleNode = require( 'WAVE_INTERFERENCE/common/view/SceneToggleNode' );
const SceneRadioButtonGroup = require( 'WAVE_INTERFERENCE/common/view/SceneRadioButtonGroup' );
const SoundViewType = require( 'WAVE_INTERFERENCE/common/model/SoundViewType' );
const SoundViewTypeEnum = require( 'WAVE_INTERFERENCE/common/model/SoundViewTypeEnum' );
const Util = require( 'DOT/Util' );
const VerticalAquaRadioButtonGroup = require( 'SUN/VerticalAquaRadioButtonGroup' );
const waveInterference = require( 'WAVE_INTERFERENCE/waveInterference' );
Expand Down Expand Up @@ -112,15 +112,15 @@ define( require => {

const soundViewTypeRadioButtonGroup = new VerticalAquaRadioButtonGroup( [ {
node: new WaveInterferenceText( wavesString ),
value: SoundViewType.WAVES,
value: SoundViewTypeEnum.WAVES,
property: model.soundScene.viewSelectionProperty
}, {
node: new WaveInterferenceText( particlesString ),
value: SoundViewType.PARTICLES,
value: SoundViewTypeEnum.PARTICLES,
property: model.soundScene.viewSelectionProperty
}, {
node: new WaveInterferenceText( bothString ),
value: SoundViewType.BOTH,
value: SoundViewTypeEnum.BOTH,
property: model.soundScene.viewSelectionProperty
} ], {
spacing: 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ define( require => {
const Enumeration = require( 'PHET_CORE/Enumeration' );
const waveInterference = require( 'WAVE_INTERFERENCE/waveInterference' );

return waveInterference.register( 'ApertureType', new Enumeration( [ 'CIRCLE', 'RECTANGLE', 'SLITS' ] ) );
return waveInterference.register( 'ApertureTypeEnum', new Enumeration( [ 'CIRCLE', 'RECTANGLE', 'SLITS' ] ) );
} );
6 changes: 3 additions & 3 deletions js/diffraction/model/DiffractionModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ define( require => {
'use strict';

// modules
const ApertureType = require( 'WAVE_INTERFERENCE/diffraction/model/ApertureType' );
const ApertureTypeEnum = require( 'WAVE_INTERFERENCE/diffraction/model/ApertureTypeEnum' );
const BooleanProperty = require( 'AXON/BooleanProperty' );
const NumberProperty = require( 'AXON/NumberProperty' );
const Property = require( 'AXON/Property' );
Expand All @@ -35,8 +35,8 @@ define( require => {
this.angleProperty = new NumberProperty( 0 );

// @public - selected scene
this.sceneProperty = new Property( ApertureType.CIRCLE, {
validValues: ApertureType.VALUES
this.sceneProperty = new Property( ApertureTypeEnum.CIRCLE, {
validValues: ApertureTypeEnum.VALUES
} );
}

Expand Down
Loading

0 comments on commit 6fbfce5

Please sign in to comment.