Skip to content

Commit

Permalink
Apply WebStorm formatting, see phetsims/phet-info#155
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Feb 26, 2021
1 parent c5d6968 commit 9128d36
Show file tree
Hide file tree
Showing 24 changed files with 133 additions and 133 deletions.
2 changes: 1 addition & 1 deletion js/moleculesandlight/view/ObservationWindowDescriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import ObservationWindowAlertManager from './ObservationWindowAlertManager.js';

const emptySpaceString = moleculesAndLightStrings.a11y.emptySpace;
const photonEmitterOffDescriptionPatternString = moleculesAndLightStrings.a11y.photonEmitterOffDescriptionPattern;
const targetMoleculePatternString = moleculesAndLightStrings. a11y.targetMoleculePattern;
const targetMoleculePatternString = moleculesAndLightStrings.a11y.targetMoleculePattern;
const inactiveAndPassesPhaseDescriptionPatternString = moleculesAndLightStrings.a11y.inactiveAndPassesPhaseDescriptionPattern;
const emissionPhaseDescriptionPatternString = moleculesAndLightStrings.a11y.emissionPhaseDescriptionPattern;
const moleculePiecesGoneString = moleculesAndLightStrings.a11y.moleculePiecesGone;
Expand Down
26 changes: 13 additions & 13 deletions js/moleculesandlight/view/QuadEmissionFrequencyControlPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ class QuadEmissionFrequencyControlPanel extends Node {
* @param {Tandem} tandem
*/
constructor( photonAbsorptionModel, tandem ) {

// Supertype constructor
super( {
tagName: 'div',
labelTagName: 'h3',
labelContent: lightSourcesString,
descriptionContent: lightSourceRadioButtonHelpTextString
} );

// Initialize the photon nodes for the control panel. Identity model view transform is used because these photon
// nodes do not correspond to anything in the model. They are just visual elements of the control panel.
const identityTransform = ModelViewTransform2.createIdentity();
Expand All @@ -87,11 +87,11 @@ class QuadEmissionFrequencyControlPanel extends Node {
new Photon( WavelengthConstants.UV_WAVELENGTH, { tandem: Tandem.OPT_OUT } ),
identityTransform
);

// Load the radio button content into an array of object literals which holds the node, label string, and
// value for each button.
const labelFont = new PhetFont( 18 );

// This is sort of hack to pass through the tandem of the radioButtonGroupMember to its child.
const microwaveTandemName = 'microwaveRadioButton';
const infraredTandemName = 'infraredRadioButton';
Expand Down Expand Up @@ -135,25 +135,25 @@ class QuadEmissionFrequencyControlPanel extends Node {
tandemName: ultravioletTandemName,
labelContent: quadWavelengthSelectorUltravioletString
} ];

// Scale the radio button text. This is done mostly to support translations.
// Determine the max width of panels in the radio button group.
const panelWidth = _.maxBy( radioButtonContent, content => content.node.width ).node.width;

// Calculate the minimum scale factor that must be applied to each label. Ensures constant font size for all labels.
let scaleFactor = 1;
_.each( radioButtonContent, content => {
const labelWidth = content.label.width;
scaleFactor = Math.min( scaleFactor, panelWidth / labelWidth );
} );

// If necessary, scale down each label by the minimum scale value.
if ( scaleFactor < 1 ) {
_.each( radioButtonContent, content => {
content.label.scale( scaleFactor );
} );
}

// Create sound generators for the radio buttons. This is done because by default the sound generators for radio
// button groups decrease in pitch from left to right, but these radio buttons will be selecting higher frequency
// light from left to right, so this seems more intuitive.
Expand All @@ -163,7 +163,7 @@ class QuadEmissionFrequencyControlPanel extends Node {
multiSelectionSoundPlayerFactory.getSelectionSoundPlayer( radioButtonContent.length - index - 1 )
);
} );

const radioButtonGroup = new RectangularRadioButtonGroup( photonAbsorptionModel.photonWavelengthProperty, radioButtonContent, {
orientation: 'horizontal',
spacing: 15,
Expand All @@ -177,7 +177,7 @@ class QuadEmissionFrequencyControlPanel extends Node {
soundPlayers: radioButtonSoundPlayers,
tandem: radioButtonGroupTandem
} );

// Draw an arrow node to illustrate energy of the emitted photons.
const energyText = new Text( quadWavelengthSelectorHigherEnergyString, { font: new PhetFont( 19 ) } );
const energyArrow = new ArrowNode( 0, 0, ARROW_LENGTH, 0, {
Expand All @@ -188,17 +188,17 @@ class QuadEmissionFrequencyControlPanel extends Node {
tailWidth: ARROW_TAIL_WIDTH,
tandem: tandem.createTandem( 'energyArrow' )
} );

// Scale the text below the arrow node. Max text length is the arrow tail length minus twice the head width.
if ( energyText.width > ARROW_LENGTH - 2 * ARROW_HEAD_WIDTH ) {
energyText.scale( ( ARROW_LENGTH - 2 * ARROW_HEAD_WIDTH ) / energyText.width );
}

// Set the positions of all components of the control panel.
energyArrow.centerX = energyText.centerX = radioButtonGroup.centerX; // All have the same center x component.
energyArrow.top = radioButtonGroup.bottom + 15; // Arrow is below the buttons by an offset which is chosen empirically.
energyText.top = energyArrow.bottom;

// Add all components to the control panel.
this.addChild( radioButtonGroup );
this.addChild( energyArrow );
Expand Down
6 changes: 3 additions & 3 deletions js/photon-absorption/model/BreakApartStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import NullPhotonAbsorptionStrategy from './NullPhotonAbsorptionStrategy.js';
import PhotonAbsorptionStrategy from './PhotonAbsorptionStrategy.js';

class BreakApartStrategy extends PhotonAbsorptionStrategy {

/**
* Constructor for the break apart strategy.
*
* @param {Molecule} molecule - The molecule which will use this strategy.
*/
constructor( molecule ) {

// Supertype constructor
super( molecule );

}


Expand Down
4 changes: 2 additions & 2 deletions js/photon-absorption/model/ExcitationStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import moleculesAndLight from '../../moleculesAndLight.js';
import PhotonHoldStrategy from './PhotonHoldStrategy.js';

class ExcitationStrategy extends PhotonHoldStrategy {

/**
* Constructor for the excitation strategy.
*
* @param {Molecule} molecule - The molecule which will use this strategy.
*/
constructor( molecule ) {

// Supertype constructor
super( molecule );
}
Expand Down
6 changes: 3 additions & 3 deletions js/photon-absorption/model/NullPhotonAbsorptionStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import moleculesAndLight from '../../moleculesAndLight.js';
import PhotonAbsorptionStrategy from './PhotonAbsorptionStrategy.js';

class NullPhotonAbsorptionStrategy extends PhotonAbsorptionStrategy {

/**
* Constructor for the null absorption strategy. This strategy does nothing.
*
* @param {Molecule} molecule - The molecule which will use this strategy.
*/
constructor( molecule ) {

// Supertype constructor
super( molecule );

}

/**
Expand Down
8 changes: 4 additions & 4 deletions js/photon-absorption/model/PhotonAbsorptionStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ const MIN_PHOTON_HOLD_TIME = 1.1; // seconds
const MAX_PHOTON_HOLD_TIME = 1.3; // seconds

class PhotonAbsorptionStrategy {

/**
* Constructor for photon absorption strategy.
*
* @param {Molecule} molecule - The molecule which will use this strategy.
*/
constructor( molecule ) {

// Property that contains the probability that a given photon will be absorbed.
this.photonAbsorptionProbabilityProperty = new Property( 0.5 ); // @private

this.molecule = molecule; // @protected

// Variables involved in the holding and re-emitting of photons.
// @protected
this.isPhotonAbsorbed = false;
Expand Down
4 changes: 2 additions & 2 deletions js/photon-absorption/model/PhotonHoldStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import NullPhotonAbsorptionStrategy from './NullPhotonAbsorptionStrategy.js';
import PhotonAbsorptionStrategy from './PhotonAbsorptionStrategy.js';

class PhotonHoldStrategy extends PhotonAbsorptionStrategy {

/**
* Constructor for the photon hold strategy.
*
* @param {Molecule} molecule - The molecule which will use this strategy.
*/
constructor( molecule ) {

// Supertype constructor
super( molecule );
}
Expand Down
16 changes: 8 additions & 8 deletions js/photon-absorption/model/PhotonTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ const PhotonTarget = Enumeration.byKeys( [
* @returns {string} - the control panel molecule name
*/
enumeration.getMoleculeName = photonTarget => photonTarget === enumeration.SINGLE_CO_MOLECULE ? controlPanelCarbonMonoxideString :
photonTarget === enumeration.SINGLE_N2_MOLECULE ? controlPanelNitrogenString :
photonTarget === enumeration.SINGLE_O2_MOLECULE ? controlPanelOxygenString :
photonTarget === enumeration.SINGLE_CO2_MOLECULE ? controlPanelCarbonDioxideString :
photonTarget === enumeration.SINGLE_NO2_MOLECULE ? controlPanelNitrogenDioxideString :
photonTarget === enumeration.SINGLE_H2O_MOLECULE ? controlPanelWaterString :
photonTarget === enumeration.SINGLE_O3_MOLECULE ? controlPanelOzoneString :
photonTarget === enumeration.SINGLE_CH4_MOLECULE ? controlPanelMethaneString :
assert && assert( false, 'unknown' );
photonTarget === enumeration.SINGLE_N2_MOLECULE ? controlPanelNitrogenString :
photonTarget === enumeration.SINGLE_O2_MOLECULE ? controlPanelOxygenString :
photonTarget === enumeration.SINGLE_CO2_MOLECULE ? controlPanelCarbonDioxideString :
photonTarget === enumeration.SINGLE_NO2_MOLECULE ? controlPanelNitrogenDioxideString :
photonTarget === enumeration.SINGLE_H2O_MOLECULE ? controlPanelWaterString :
photonTarget === enumeration.SINGLE_O3_MOLECULE ? controlPanelOzoneString :
photonTarget === enumeration.SINGLE_CH4_MOLECULE ? controlPanelMethaneString :
assert && assert( false, 'unknown' );
}
} );
moleculesAndLight.register( 'PhotonTarget', PhotonTarget );
Expand Down
4 changes: 2 additions & 2 deletions js/photon-absorption/model/RotationStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ const RAND = {
};

class RotationStrategy extends PhotonHoldStrategy {

/**
* Constructor for a rotation strategy.
*
* @param {Molecule} molecule - The molecule which will use this strategy.
*/
constructor( molecule ) {

// Supertype constructor
super( molecule );
}
Expand Down
6 changes: 3 additions & 3 deletions js/photon-absorption/model/VibrationStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import moleculesAndLight from '../../moleculesAndLight.js';
import PhotonHoldStrategy from './PhotonHoldStrategy.js';

class VibrationStrategy extends PhotonHoldStrategy {

/**
* Constructor for the break apart strategy.
*
* @param {Molecule} molecule - The molecule which will use this strategy.
*/
constructor( molecule ) {

// Supertype constructor
super( molecule );

}


Expand Down
8 changes: 4 additions & 4 deletions js/photon-absorption/model/atoms/AtomicBond.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ class AtomicBond {
* @param {Object} [options]
*/
constructor( atom1, atom2, options ) {

options = merge( {
// defaults
bondCount: 1, // Indicates whether this is a single, double, triple, etc. bond.

// {boolean} if true, the atom will be in the top layer in the visualization, to support 3D looking molecules
topLayer: false,

// offsets for the positions of the bond endpoints, relative to the centers of each atom in model coordinates
atom1PositionOffset: new Vector2( 0, 0 ),
atom2PositionOffset: new Vector2( 0, 0 )
}, options );

// @public (read-only)
this.atom1 = atom1;
this.atom2 = atom2;
Expand Down
12 changes: 6 additions & 6 deletions js/photon-absorption/model/molecules/CH4.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@ const HYDROGEN_VIBRATION_DISTANCE_X = HYDROGEN_VIBRATION_DISTANCE * Math.cos( HY
const HYDROGEN_VIBRATION_DISTANCE_Y = HYDROGEN_VIBRATION_DISTANCE * Math.sin( HYDROGEN_VIBRATION_ANGLE );

class CH4 extends Molecule {

/**
* Constructor for a Methane molecule.
*
* @param {Object} [options]
*/
constructor( options ) {

// Supertype constructor
super( options );

// Instance data for the CH4 molecule - @private
this.carbonAtom = Atom.carbon();
this.hydrogenAtom1 = Atom.hydrogen( { topLayer: true } );
this.hydrogenAtom2 = Atom.hydrogen();
this.hydrogenAtom3 = Atom.hydrogen();
this.hydrogenAtom4 = Atom.hydrogen( { topLayer: true } );

// Configure the base class.
this.addAtom( this.carbonAtom );
this.addAtom( this.hydrogenAtom1 );
Expand All @@ -63,10 +63,10 @@ class CH4 extends Molecule {
this.addAtomicBond( new AtomicBond( this.carbonAtom, this.hydrogenAtom2 ) );
this.addAtomicBond( new AtomicBond( this.carbonAtom, this.hydrogenAtom3 ) );
this.addAtomicBond( new AtomicBond( this.carbonAtom, this.hydrogenAtom4, { topLayer: true, atom1PositionOffset: new Vector2( PERSPECTIVE_OFFSET / 2, -PERSPECTIVE_OFFSET ) } ) );

// Set up the photon wavelengths to absorb.
this.setPhotonAbsorptionStrategy( WavelengthConstants.IR_WAVELENGTH, new VibrationStrategy( this ) );

// Set the initial offsets.
this.initializeAtomOffsets();
}
Expand Down
14 changes: 7 additions & 7 deletions js/photon-absorption/model/molecules/CO.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,33 @@ const INITIAL_CARBON_OXYGEN_DISTANCE = 170; // In picometers.
const VIBRATION_MAGNITUDE = 20; // In picometers.

class CO extends Molecule {

/**
* Constructor for a carbon monoxide molecule.
*
* @param {Object} [options]
*/
constructor( options ) {

// Supertype constructor
super( options );

// @private
this.carbonAtom = Atom.carbon();
this.oxygenAtom = Atom.oxygen();

// Configure the base class.
this.addAtom( this.carbonAtom );
this.addAtom( this.oxygenAtom );
this.addAtomicBond( new AtomicBond( this.carbonAtom, this.oxygenAtom, { bondCount: 3 } ) );

// Set up the photon wavelengths to absorb
this.setPhotonAbsorptionStrategy( WavelengthConstants.MICRO_WAVELENGTH, new RotationStrategy( this ) );
this.setPhotonAbsorptionStrategy( WavelengthConstants.IR_WAVELENGTH, new VibrationStrategy( this ) );

// Set the initial offsets.
this.initializeAtomOffsets();

}


Expand Down
Loading

0 comments on commit 9128d36

Please sign in to comment.