Skip to content

Commit

Permalink
rename FMWSymbols fields to *MarkupStringProperty and instrument them,
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jun 5, 2023
1 parent ddebdf3 commit d05801b
Show file tree
Hide file tree
Showing 27 changed files with 166 additions and 138 deletions.
7 changes: 6 additions & 1 deletion js/common/FMWConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import PhetFont from '../../../scenery-phet/js/PhetFont.js';
import { Node, VBox } from '../../../scenery/js/imports.js';
import fourierMakingWaves from '../fourierMakingWaves.js';
import FMWColors from './FMWColors.js';
import Tandem from '../../../tandem/js/Tandem.js';

// constants - view
const PANEL_CORNER_RADIUS = 5;
Expand Down Expand Up @@ -153,7 +154,11 @@ const FMWConstants = {
X_AXIS_LABEL_MAX_WIDTH: 38,
X_AXIS_LABEL_SPACING: 6, // horizontal space between chart rectangle and x-axis label
Y_AXIS_LABEL_SPACING: 36, // horizontal space between chart rectangle and y-axis label
SECONDARY_WAVEFORM_LINE_WIDTH: 4
SECONDARY_WAVEFORM_LINE_WIDTH: 4,

// Tandems
//TODO https://github.com/phetsims/tandem/issues/298
DERIVED_STRINGS_TANDEM: Tandem.GENERAL_MODEL.createTandem( 'strings' ).createTandem( 'fourierMakingWaves' ).createTandem( 'derivedStrings' )
};

// Verify some of the above constants
Expand Down
51 changes: 25 additions & 26 deletions js/common/FMWDerivedStrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,138 +7,137 @@
*/

import fourierMakingWaves from '../fourierMakingWaves.js';
import Tandem from '../../../tandem/js/Tandem.js';
import FMWSymbols from './FMWSymbols.js';
import PatternStringProperty from '../../../axon/js/PatternStringProperty.js';
import FourierMakingWavesStrings from '../FourierMakingWavesStrings.js';
import StringProperty from '../../../axon/js/StringProperty.js';
import FMWConstants from './FMWConstants.js';

//TODO https://github.com/phetsims/tandem/issues/298
const DERIVED_STRINGS_TANDEM = Tandem.GENERAL_MODEL.createTandem( 'strings' ).createTandem( 'fourierMakingWaves' ).createTandem( 'derivedStrings' )
const DERIVED_STRINGS_TANDEM = FMWConstants.DERIVED_STRINGS_TANDEM;

const FMWDerivedStrings = {

k1StringProperty: new PatternStringProperty( new StringProperty( '{{k}}<sub>1</sub>' ), {
k: FMWSymbols.kSymbolProperty
k: FMWSymbols.kMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'k1StringProperty' )
} ),

omega1StringProperty: new PatternStringProperty( new StringProperty( '{{omega}}<sub>1</sub>' ), {
omega: FMWSymbols.omegaSymbolProperty
omega: FMWSymbols.omegaMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'omega1StringProperty' )
} ),

xMetersStringProperty: new PatternStringProperty( FourierMakingWavesStrings.symbolUnitsStringProperty, {
symbol: FMWSymbols.xSymbolProperty,
symbol: FMWSymbols.xMarkupStringProperty,
units: FourierMakingWavesStrings.units.metersStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'xMetersStringProperty' )
} ),

xMillisecondsStringProperty: new PatternStringProperty( FourierMakingWavesStrings.symbolUnitsStringProperty, {
symbol: FMWSymbols.tSymbolProperty,
symbol: FMWSymbols.tMarkupStringProperty,
units: FourierMakingWavesStrings.units.millisecondsStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'xMillisecondsStringProperty' )
} ),

spaceXStringProperty: new PatternStringProperty( FourierMakingWavesStrings.spaceSymbolStringProperty, {
symbol: FMWSymbols.xSymbolProperty
symbol: FMWSymbols.xMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'spaceXStringProperty' )
} ),

timeTStringProperty: new PatternStringProperty( FourierMakingWavesStrings.timeSymbolStringProperty, {
symbol: FMWSymbols.tSymbolProperty
symbol: FMWSymbols.tMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'timeTStringProperty' )
} ),

spaceAndTimeXTStringProperty: new PatternStringProperty( FourierMakingWavesStrings.spaceAndTimeSymbolsStringProperty, {
spaceSymbol: FMWSymbols.xSymbolProperty,
timeSymbol: FMWSymbols.tSymbolProperty
spaceSymbol: FMWSymbols.xMarkupStringProperty,
timeSymbol: FMWSymbols.tMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'spaceAndTimeXTStringProperty' )
} ),

lambdaAndTStringProperty: new PatternStringProperty( FourierMakingWavesStrings.symbolAndSymbolStringProperty, {
symbol1: FMWSymbols.lambdaSymbolProperty,
symbol2: FMWSymbols.TSymbolProperty
symbol1: FMWSymbols.lambdaMarkupStringProperty,
symbol2: FMWSymbols.TMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'lambdaAndTStringProperty' )
} ),

kAndOmegaStringProperty: new PatternStringProperty( FourierMakingWavesStrings.symbolAndSymbolStringProperty, {
symbol1: FMWSymbols.kSymbolProperty,
symbol2: FMWSymbols.omegaSymbolProperty
symbol1: FMWSymbols.kMarkupStringProperty,
symbol2: FMWSymbols.omegaMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'kAndOmegaStringProperty' )
} ),

ADescriptionStringProperty: new PatternStringProperty( FourierMakingWavesStrings.symbolsDialog.AStringProperty, {
A: FMWSymbols.ASymbolProperty
A: FMWSymbols.AMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'ADescriptionStringProperty' )
} ),

fDescriptionStringProperty: new PatternStringProperty( FourierMakingWavesStrings.symbolsDialog.fStringProperty, {
f: FMWSymbols.fSymbolProperty
f: FMWSymbols.fMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'fDescriptionStringProperty' )
} ),

lambdaDescriptionStringProperty: new PatternStringProperty( FourierMakingWavesStrings.symbolsDialog.lambdaStringProperty, {
lambda: FMWSymbols.lambdaSymbolProperty
lambda: FMWSymbols.lambdaMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'lambdaDescriptionStringProperty' )
} ),

kDescriptionStringProperty: new PatternStringProperty( FourierMakingWavesStrings.symbolsDialog.kStringProperty, {
k: FMWSymbols.kSymbolProperty
k: FMWSymbols.kMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'kDescriptionStringProperty' )
} ),

LDescriptionStringProperty: new PatternStringProperty( FourierMakingWavesStrings.symbolsDialog.LStringProperty, {
L: FMWSymbols.LSymbolProperty
L: FMWSymbols.LMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'LDescriptionStringProperty' )
} ),

nDescriptionStringProperty: new PatternStringProperty( FourierMakingWavesStrings.symbolsDialog.nStringProperty, {
n: FMWSymbols.nSymbolProperty
n: FMWSymbols.nMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'nDescriptionStringProperty' )
} ),

tDescriptionStringProperty: new PatternStringProperty( FourierMakingWavesStrings.symbolsDialog.tStringProperty, {
t: FMWSymbols.tSymbolProperty
t: FMWSymbols.tMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'tDescriptionStringProperty' )
} ),

TDescriptionStringProperty: new PatternStringProperty( FourierMakingWavesStrings.symbolsDialog.TStringProperty, {
T: FMWSymbols.TSymbolProperty
T: FMWSymbols.TMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'TDescriptionStringProperty' )
} ),

omegaDescriptionStringProperty: new PatternStringProperty( FourierMakingWavesStrings.symbolsDialog.omegaStringProperty, {
omega: FMWSymbols.omegaSymbolProperty
omega: FMWSymbols.omegaMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'omegaDescriptionStringProperty' )
} ),

sigmaDescriptionStringProperty: new PatternStringProperty( FourierMakingWavesStrings.symbolsDialog.sigmaStringProperty, {
sigma: FMWSymbols.sigmaSymbolProperty
sigma: FMWSymbols.sigmaMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'sigmaDescriptionStringProperty' )
} ),

xDescriptionStringProperty: new PatternStringProperty( FourierMakingWavesStrings.symbolsDialog.xStringProperty, {
x: FMWSymbols.xSymbolProperty
x: FMWSymbols.xMarkupStringProperty
}, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'xDescriptionStringProperty' )
} )
Expand Down
80 changes: 52 additions & 28 deletions js/common/FMWSymbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,88 +19,112 @@
import MathSymbolFont from '../../../scenery-phet/js/MathSymbolFont.js';
import fourierMakingWaves from '../fourierMakingWaves.js';
import FourierMakingWavesStrings from '../FourierMakingWavesStrings.js';
import FMWConstants from './FMWConstants.js';

const DERIVED_STRINGS_TANDEM = FMWConstants.DERIVED_STRINGS_TANDEM;

const FMWSymbols = {

//-----------------------------------------------------------------------------------------------------------
// Symbols that are translated

// amplitude
ASymbolProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.AStringProperty, {
style: 'normal'
AMarkupStringProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.AStringProperty, {
style: 'normal',
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'AMarkupStringProperty' )
} ),

// cosine
cosSymbolProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.cosStringProperty, {
style: 'normal'
cosMarkupStringProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.cosStringProperty, {
style: 'normal',
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'cosMarkupStringProperty' )
} ),

// differential, like dx
dSymbolProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.dStringProperty ),
dMarkupStringProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.dStringProperty, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'dMarkupStringProperty' )
} ),

// function of frequency
FSymbolProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.FStringProperty, {
style: 'normal'
FMarkupStringProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.FStringProperty, {
style: 'normal',
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'FMarkupStringProperty' )
} ),

// frequency
fSymbolProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.fStringProperty ),
fMarkupStringProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.fStringProperty, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'fMarkupStringProperty' )
} ),

// wave number
kSymbolProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.kStringProperty ),
kMarkupStringProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.kStringProperty, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'kMarkupStringProperty' )
} ),

// string length, if this were a plucked string
LSymbolProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.LStringProperty, {
style: 'normal'
LMarkupStringProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.LStringProperty, {
style: 'normal',
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'LMarkupStringProperty' )
} ),

// wavelength
lambdaSymbolProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.lambdaStringProperty, {
style: 'normal'
lambdaMarkupStringProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.lambdaStringProperty, {
style: 'normal',
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'lambdaMarkupStringProperty' )
} ),

// mode, order, or harmonic number
nSymbolProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.nStringProperty ),
nMarkupStringProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.nStringProperty, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'nMarkupStringProperty' )
} ),

// angular frequency
omegaSymbolProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.omegaStringProperty, {
style: 'normal'
omegaMarkupStringProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.omegaStringProperty, {
style: 'normal',
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'omegaMarkupStringProperty' )
} ),

// width of the Gaussian wave packet (dx)
sigmaSymbolProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.sigmaStringProperty, {
style: 'normal'
sigmaMarkupStringProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.sigmaStringProperty, {
style: 'normal',
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'sigmaMarkupStringProperty' )
} ),

// sine
sinSymbolProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.sinStringProperty, {
style: 'normal'
sinMarkupStringProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.sinStringProperty, {
style: 'normal',
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'sinMarkupStringProperty' )
} ),

// sampling period, or period of the 1st harmonic
TSymbolProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.TStringProperty, {
style: 'normal'
TMarkupStringProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.TStringProperty, {
style: 'normal',
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'TMarkupStringProperty' )
} ),

// time
tSymbolProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.tStringProperty ),
tMarkupStringProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.tStringProperty, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'tMarkupStringProperty' )
} ),

// position in space along L
xSymbolProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.xStringProperty ),
xMarkupStringProperty: MathSymbolFont.createDerivedProperty( FourierMakingWavesStrings.symbol.xStringProperty, {
tandem: DERIVED_STRINGS_TANDEM.createTandem( 'xMarkupStringProperty' )
} ),

//-----------------------------------------------------------------------------------------------------------
// Symbols that are not translated

infinity: MathSymbolFont.getRichTextMarkup( '\u221e', 'normal' ),
infinityMarkup: MathSymbolFont.getRichTextMarkup( '\u221e', 'normal' ),

// integration symbol
integral: MathSymbolFont.getRichTextMarkup( '\u222B', 'normal' ),
integralMarkup: MathSymbolFont.getRichTextMarkup( '\u222B', 'normal' ),

// pi
pi: MathSymbolFont.getRichTextMarkup( '\u03c0', 'normal' ),
piMarkup: MathSymbolFont.getRichTextMarkup( '\u03c0', 'normal' ),

// summation symbol
SIGMA: MathSymbolFont.getRichTextMarkup( '\u03a3', 'normal' )
sigmaMarkup: MathSymbolFont.getRichTextMarkup( '\u03a3', 'normal' )
};

fourierMakingWaves.register( 'FMWSymbols', FMWSymbols );
Expand Down
2 changes: 1 addition & 1 deletion js/common/view/AmplitudeKeypadDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default class AmplitudeKeypadDialog extends Dialog {

// Title indicates which amplitude we're editing, e.g. A<sub>2</sub>.
const titleStringProperty = new DerivedProperty(
[ FMWSymbols.ASymbolProperty, orderProperty ],
[ FMWSymbols.AMarkupStringProperty, orderProperty ],
( A, order ) => `${A}<sub>${order}</sub>`, {
tandem: options.tandem.createTandem( 'titleStringProperty' ),
phetioValueType: StringIO
Expand Down
2 changes: 1 addition & 1 deletion js/common/view/AmplitudeNumberDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class AmplitudeNumberDisplay extends InteractiveHighlighting( VBo
options.numberDisplayOptions );

const labelStringProperty = new DerivedProperty(
[ FMWSymbols.ASymbolProperty ],
[ FMWSymbols.AMarkupStringProperty ],
A => `${A}<sub>${harmonic.order}</sub>`, {
tandem: options.tandem.createTandem( 'labelStringProperty' ),
phetioValueType: StringIO
Expand Down
Loading

0 comments on commit d05801b

Please sign in to comment.