Skip to content

Commit

Permalink
converte to StringProperty, see #350
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Nov 30, 2022
1 parent 91560d0 commit 66f6b2c
Show file tree
Hide file tree
Showing 22 changed files with 85 additions and 123 deletions.
3 changes: 3 additions & 0 deletions energy-skate-park_en.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
"adapted-from-phet"
],
"simulation": true,
"simFeatures": {
"supportsDynamicLocale": true
},
"phet-io": {
"validation": false
},
Expand Down
54 changes: 0 additions & 54 deletions js/EnergySkateParkStrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,145 +10,91 @@ import energySkatePark from './energySkatePark.js';

type StringsType = {
'energy-skate-park': {
'title': string;
'titleStringProperty': LinkableProperty<string>;
};
'physicalControls': {
'gravityControls': {
'gravity': string;
'gravityStringProperty': LinkableProperty<string>;
'earth': string;
'earthStringProperty': LinkableProperty<string>;
'jupiter': string;
'jupiterStringProperty': LinkableProperty<string>;
'moon': string;
'moonStringProperty': LinkableProperty<string>;
'gravityMetersPerSecondSquaredPattern': string;
'gravityMetersPerSecondSquaredPatternStringProperty': LinkableProperty<string>;
'gravityNewtonsPerKilogramPattern': string;
'gravityNewtonsPerKilogramPatternStringProperty': LinkableProperty<string>;
};
'massControls': {
'mass': string;
'massStringProperty': LinkableProperty<string>;
'massKilogramsPattern': string;
'massKilogramsPatternStringProperty': LinkableProperty<string>;
};
'friction': string;
'frictionStringProperty': LinkableProperty<string>;
'custom': string;
'customStringProperty': LinkableProperty<string>;
'small': string;
'smallStringProperty': LinkableProperty<string>;
'large': string;
'largeStringProperty': LinkableProperty<string>;
'lots': string;
'lotsStringProperty': LinkableProperty<string>;
'none': string;
'noneStringProperty': LinkableProperty<string>;
'tiny': string;
'tinyStringProperty': LinkableProperty<string>;
};
'energies': {
'thermal': string;
'thermalStringProperty': LinkableProperty<string>;
'total': string;
'totalStringProperty': LinkableProperty<string>;
'kinetic': string;
'kineticStringProperty': LinkableProperty<string>;
'potential': string;
'potentialStringProperty': LinkableProperty<string>;
'energy': string;
'energyStringProperty': LinkableProperty<string>;
};
'plots': {
'barGraph': {
'label': string;
'labelStringProperty': LinkableProperty<string>;
};
'energyGraph': {
'label': string;
'labelStringProperty': LinkableProperty<string>;
};
'pieChart': {
'label': string;
'labelStringProperty': LinkableProperty<string>;
};
'timeSwitchLabel': string;
'timeSwitchLabelStringProperty': LinkableProperty<string>;
'positionSwitchLabel': string;
'positionSwitchLabelStringProperty': LinkableProperty<string>;
'timeLabel': string;
'timeLabelStringProperty': LinkableProperty<string>;
'positionLabel': string;
'positionLabelStringProperty': LinkableProperty<string>;
'energyLabel': string;
'energyLabelStringProperty': LinkableProperty<string>;
};
'visibilityControls': {
'grid': string;
'gridStringProperty': LinkableProperty<string>;
'referenceHeight': string;
'referenceHeightStringProperty': LinkableProperty<string>;
'path': string;
'pathStringProperty': LinkableProperty<string>;
'speed': string;
'speedStringProperty': LinkableProperty<string>;
};
'skaterControls': {
'label': string;
'labelStringProperty': LinkableProperty<string>;
'skater1MassPattern': string;
'skater1MassPatternStringProperty': LinkableProperty<string>;
'skater2MassPattern': string;
'skater2MassPatternStringProperty': LinkableProperty<string>;
'skater3MassPattern': string;
'skater3MassPatternStringProperty': LinkableProperty<string>;
'skater4MassPattern': string;
'skater4MassPatternStringProperty': LinkableProperty<string>;
'skater5MassPattern': string;
'skater5MassPatternStringProperty': LinkableProperty<string>;
'dogMassPattern': string;
'dogMassPatternStringProperty': LinkableProperty<string>;
'restartSkater': string;
'restartSkaterStringProperty': LinkableProperty<string>;
};
'trackControls': {
'stickToTrack': string;
'stickToTrackStringProperty': LinkableProperty<string>;
};
'screens': {
'intro': string;
'introStringProperty': LinkableProperty<string>;
'graphs': string;
'graphsStringProperty': LinkableProperty<string>;
'playground': string;
'playgroundStringProperty': LinkableProperty<string>;
'measure': string;
'measureStringProperty': LinkableProperty<string>;
};
'heightLabels': {
'zeroM': string;
'zeroMStringProperty': LinkableProperty<string>;
'heightEqualsZero': string;
'heightEqualsZeroStringProperty': LinkableProperty<string>;
};
'pathSensor': {
'energyJoulesPattern': string;
'energyJoulesPatternStringProperty': LinkableProperty<string>;
'heightMetersPattern': string;
'heightMetersPatternStringProperty': LinkableProperty<string>;
'speedMetersPerSecondPattern': string;
'speedMetersPerSecondPatternStringProperty': LinkableProperty<string>;
};
'speedometer': {
'label': string;
'labelStringProperty': LinkableProperty<string>;
'metersPerSecondPattern': string;
'metersPerSecondPatternStringProperty': LinkableProperty<string>;
};
'measuringTape': {
'units': string;
'unitsStringProperty': LinkableProperty<string>;
}
};
Expand Down
10 changes: 5 additions & 5 deletions js/common/view/EnergyBarGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import EnergySkateParkStrings from '../../EnergySkateParkStrings.js';
import EnergySkateParkConstants from '../EnergySkateParkConstants.js';
import EnergySkateParkColorScheme from './EnergySkateParkColorScheme.js';

const energyEnergyString = EnergySkateParkStrings.energies.energy;
const energyKineticString = EnergySkateParkStrings.energies.kinetic;
const energyPotentialString = EnergySkateParkStrings.energies.potential;
const energyThermalString = EnergySkateParkStrings.energies.thermal;
const energyTotalString = EnergySkateParkStrings.energies.total;
const energyEnergyString = EnergySkateParkStrings.energies.energyStringProperty;
const energyKineticString = EnergySkateParkStrings.energies.kineticStringProperty;
const energyPotentialString = EnergySkateParkStrings.energies.potentialStringProperty;
const energyThermalString = EnergySkateParkStrings.energies.thermalStringProperty;
const energyTotalString = EnergySkateParkStrings.energies.totalStringProperty;

// constants
const ZOOM_BUTTON_TOUCH_DILATION = 5;
Expand Down
2 changes: 1 addition & 1 deletion js/common/view/EnergySkateParkGravityControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import GravityNumberControl from './GravityNumberControl.js';
import GravitySlider from './GravitySlider.js';

// constants
const gravityNewtonsPerKilogramPatternString = EnergySkateParkStrings.physicalControls.gravityControls.gravityNewtonsPerKilogramPattern;
const gravityNewtonsPerKilogramPatternString = EnergySkateParkStrings.physicalControls.gravityControls.gravityNewtonsPerKilogramPatternStringProperty;

class EnergySkateParkGravityControls extends VBox {

Expand Down
2 changes: 1 addition & 1 deletion js/common/view/EnergySkateParkGridNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class EnergySkateParkGridNode extends Node {
this.labelXPosition = this.modelViewTransform.modelToViewX( -5 );

// @private {TextPanel} - a unique label for the zero meter reference height position
this.zeroMeterLabel = new TextPanel( EnergySkateParkStrings.heightLabels.zeroM, {
this.zeroMeterLabel = new TextPanel( EnergySkateParkStrings.heightLabels.zeroMStringProperty, {
bottom: this.modelViewTransform.modelToViewY( 0 ) - 2,
right: this.labelXPosition - 2
} );
Expand Down
6 changes: 3 additions & 3 deletions js/common/view/EnergySkateParkScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ import ToolboxPanel from './ToolboxPanel.js';
import TrackNode from './TrackNode.js';
import VisibilityControlsPanel from './VisibilityControlsPanel.js';

const controlsRestartSkaterString = EnergySkateParkStrings.skaterControls.restartSkater;
const controlsRestartSkaterString = EnergySkateParkStrings.skaterControls.restartSkaterStringProperty;
const propertiesSpeedStringProperty = EnergySkateParkStrings.speedometer.labelStringProperty;
const speedometerMetersPerSecondPatternString = EnergySkateParkStrings.speedometer.metersPerSecondPattern;
const measuringTapeUnitsString = EnergySkateParkStrings.measuringTape.units;
const speedometerMetersPerSecondPatternString = EnergySkateParkStrings.speedometer.metersPerSecondPatternStringProperty;
const measuringTapeUnitsString = EnergySkateParkStrings.measuringTape.unitsStringProperty;

// constants
// for wider screens, panels can float to the left and right by this much beyond dev bounds in view coordinates
Expand Down
12 changes: 6 additions & 6 deletions js/common/view/EnergySkateParkVisibilityControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import EnergySkateParkStrings from '../../EnergySkateParkStrings.js';
import EnergySkateParkConstants from '../EnergySkateParkConstants.js';
import EnergySkateParkCheckboxItem from './EnergySkateParkCheckboxItem.js';

const controlsPathString = EnergySkateParkStrings.visibilityControls.path;
const controlsReferenceHeightString = EnergySkateParkStrings.visibilityControls.referenceHeight;
const controlsShowGridString = EnergySkateParkStrings.visibilityControls.grid;
const controlsStickToTrackString = EnergySkateParkStrings.trackControls.stickToTrack;
const pieChartString = EnergySkateParkStrings.plots.pieChart.label;
const propertiesSpeedString = EnergySkateParkStrings.visibilityControls.speed;
const controlsPathString = EnergySkateParkStrings.visibilityControls.pathStringProperty;
const controlsReferenceHeightString = EnergySkateParkStrings.visibilityControls.referenceHeightStringProperty;
const controlsShowGridString = EnergySkateParkStrings.visibilityControls.gridStringProperty;
const controlsStickToTrackString = EnergySkateParkStrings.trackControls.stickToTrackStringProperty;
const pieChartString = EnergySkateParkStrings.plots.pieChart.labelStringProperty;
const propertiesSpeedString = EnergySkateParkStrings.visibilityControls.speedStringProperty;

// constants
const TEXT_OPTIONS = {
Expand Down
2 changes: 1 addition & 1 deletion js/common/view/FrictionSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import EnergySkateParkStrings from '../../EnergySkateParkStrings.js';
import EnergySkateParkConstants from '../EnergySkateParkConstants.js';
import PhysicalSlider from './PhysicalSlider.js';

const controlsFrictionTitleString = EnergySkateParkStrings.physicalControls.friction;
const controlsFrictionTitleString = EnergySkateParkStrings.physicalControls.frictionStringProperty;

class FrictionSlider extends PhysicalSlider {

Expand Down
6 changes: 3 additions & 3 deletions js/common/view/GravityComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import EnergySkateParkStrings from '../../EnergySkateParkStrings.js';
import EnergySkateParkConstants from '../EnergySkateParkConstants.js';
import PhysicalComboBox from './PhysicalComboBox.js';

const gravityMoonString = EnergySkateParkStrings.physicalControls.gravityControls.moon;
const gravityEarthString = EnergySkateParkStrings.physicalControls.gravityControls.earth;
const gravityJupiterString = EnergySkateParkStrings.physicalControls.gravityControls.jupiter;
const gravityMoonString = EnergySkateParkStrings.physicalControls.gravityControls.moonStringProperty;
const gravityEarthString = EnergySkateParkStrings.physicalControls.gravityControls.earthStringProperty;
const gravityJupiterString = EnergySkateParkStrings.physicalControls.gravityControls.jupiterStringProperty;

class GravityComboBox extends PhysicalComboBox {

Expand Down
4 changes: 2 additions & 2 deletions js/common/view/GravityNumberControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import EnergySkateParkStrings from '../../EnergySkateParkStrings.js';
import EnergySkateParkConstants from '../EnergySkateParkConstants.js';
import PhysicalNumberControl from './PhysicalNumberControl.js';

const controlsGravityLabelString = EnergySkateParkStrings.physicalControls.gravityControls.gravity;
const gravityMetersPerSecondSquaredPatternString = EnergySkateParkStrings.physicalControls.gravityControls.gravityMetersPerSecondSquaredPattern;
const controlsGravityLabelString = EnergySkateParkStrings.physicalControls.gravityControls.gravityStringProperty;
const gravityMetersPerSecondSquaredPatternString = EnergySkateParkStrings.physicalControls.gravityControls.gravityMetersPerSecondSquaredPatternStringProperty;

class GravityNumberControl extends PhysicalNumberControl {

Expand Down
4 changes: 2 additions & 2 deletions js/common/view/GravitySlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import EnergySkateParkStrings from '../../EnergySkateParkStrings.js';
import EnergySkateParkConstants from '../EnergySkateParkConstants.js';
import PhysicalSlider from './PhysicalSlider.js';

const controlsGravityLabelString = EnergySkateParkStrings.physicalControls.gravityControls.gravity;
const controlsValueTinyString = EnergySkateParkStrings.physicalControls.tiny;
const controlsGravityLabelString = EnergySkateParkStrings.physicalControls.gravityControls.gravityStringProperty;
const controlsValueTinyString = EnergySkateParkStrings.physicalControls.tinyStringProperty;

class GravitySlider extends PhysicalSlider {

Expand Down
14 changes: 7 additions & 7 deletions js/common/view/MassComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import SkaterMasses from '../SkaterMasses.js';
import LabelledComboBox from './LabelledComboBox.js';
import PhysicalComboBox from './PhysicalComboBox.js';

const controlsSkaterString = EnergySkateParkStrings.skaterControls.label;
const controlsSkater1MassPatternString = EnergySkateParkStrings.skaterControls.skater1MassPattern;
const controlsSkater2MassPatternString = EnergySkateParkStrings.skaterControls.skater2MassPattern;
const controlsSkater3MassPatternString = EnergySkateParkStrings.skaterControls.skater3MassPattern;
const controlsSkater4MassPatternString = EnergySkateParkStrings.skaterControls.skater4MassPattern;
const controlsSkater5MassPatternString = EnergySkateParkStrings.skaterControls.skater5MassPattern;
const controlsDogMassPatternString = EnergySkateParkStrings.skaterControls.dogMassPattern;
const controlsSkaterString = EnergySkateParkStrings.skaterControls.labelStringProperty;
const controlsSkater1MassPatternString = EnergySkateParkStrings.skaterControls.skater1MassPatternStringProperty;
const controlsSkater2MassPatternString = EnergySkateParkStrings.skaterControls.skater2MassPatternStringProperty;
const controlsSkater3MassPatternString = EnergySkateParkStrings.skaterControls.skater3MassPatternStringProperty;
const controlsSkater4MassPatternString = EnergySkateParkStrings.skaterControls.skater4MassPatternStringProperty;
const controlsSkater5MassPatternString = EnergySkateParkStrings.skaterControls.skater5MassPatternStringProperty;
const controlsDogMassPatternString = EnergySkateParkStrings.skaterControls.dogMassPatternStringProperty;

class MassComboBox extends LabelledComboBox {

Expand Down
4 changes: 2 additions & 2 deletions js/common/view/MassNumberControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import energySkatePark from '../../energySkatePark.js';
import EnergySkateParkStrings from '../../EnergySkateParkStrings.js';
import PhysicalNumberControl from './PhysicalNumberControl.js';

const controlsMassString = EnergySkateParkStrings.physicalControls.massControls.mass;
const massKilogramsPatternString = EnergySkateParkStrings.physicalControls.massControls.massKilogramsPattern;
const controlsMassString = EnergySkateParkStrings.physicalControls.massControls.massStringProperty;
const massKilogramsPatternString = EnergySkateParkStrings.physicalControls.massControls.massKilogramsPatternStringProperty;

class MassNumberControl extends PhysicalNumberControl {

Expand Down
6 changes: 3 additions & 3 deletions js/common/view/MassSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import energySkatePark from '../../energySkatePark.js';
import EnergySkateParkStrings from '../../EnergySkateParkStrings.js';
import PhysicalSlider from './PhysicalSlider.js';

const controlsMassString = EnergySkateParkStrings.physicalControls.massControls.mass;
const smallString = EnergySkateParkStrings.physicalControls.small;
const largeString = EnergySkateParkStrings.physicalControls.large;
const controlsMassString = EnergySkateParkStrings.physicalControls.massControls.massStringProperty;
const smallString = EnergySkateParkStrings.physicalControls.smallStringProperty;
const largeString = EnergySkateParkStrings.physicalControls.largeStringProperty;

class MassSlider extends PhysicalSlider {

Expand Down
2 changes: 1 addition & 1 deletion js/common/view/PhysicalComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import EnergySkateParkStrings from '../../EnergySkateParkStrings.js';
import EnergySkateParkConstants from '../EnergySkateParkConstants.js';

// constants
const controlsGravityCustomString = EnergySkateParkStrings.physicalControls.custom;
const controlsGravityCustomString = EnergySkateParkStrings.physicalControls.customStringProperty;

class PhysicalComboBox extends ComboBox {

Expand Down
4 changes: 2 additions & 2 deletions js/common/view/PhysicalSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import EnergySkateParkStrings from '../../EnergySkateParkStrings.js';
import EnergySkateParkConstants from '../EnergySkateParkConstants.js';
import PhysicalNumberControl from './PhysicalNumberControl.js';

const controlsValueLotsString = EnergySkateParkStrings.physicalControls.lots;
const controlsValueNoneString = EnergySkateParkStrings.physicalControls.none;
const controlsValueLotsString = EnergySkateParkStrings.physicalControls.lotsStringProperty;
const controlsValueNoneString = EnergySkateParkStrings.physicalControls.noneStringProperty;

class PhysicalSlider extends PhysicalNumberControl {

Expand Down
10 changes: 5 additions & 5 deletions js/common/view/PieChartLegend.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import EnergySkateParkStrings from '../../EnergySkateParkStrings.js';
import EnergySkateParkConstants from '../EnergySkateParkConstants.js';
import EnergySkateParkColorScheme from './EnergySkateParkColorScheme.js';

const energyEnergyString = EnergySkateParkStrings.energies.energy;
const energyKineticString = EnergySkateParkStrings.energies.kinetic;
const energyPotentialString = EnergySkateParkStrings.energies.potential;
const energyThermalString = EnergySkateParkStrings.energies.thermal;
const energyTotalString = EnergySkateParkStrings.energies.total;
const energyEnergyString = EnergySkateParkStrings.energies.energyStringProperty;
const energyKineticString = EnergySkateParkStrings.energies.kineticStringProperty;
const energyPotentialString = EnergySkateParkStrings.energies.potentialStringProperty;
const energyThermalString = EnergySkateParkStrings.energies.thermalStringProperty;
const energyTotalString = EnergySkateParkStrings.energies.totalStringProperty;

class PieChartLegend extends Panel {

Expand Down
2 changes: 1 addition & 1 deletion js/common/view/ReferenceHeightLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import EnergySkateParkStrings from '../../EnergySkateParkStrings.js';
import EnergySkateParkColorScheme from './EnergySkateParkColorScheme.js';
import TextPanel from './TextPanel.js';

const heightEqualsZeroString = EnergySkateParkStrings.heightLabels.heightEqualsZero;
const heightEqualsZeroString = EnergySkateParkStrings.heightLabels.heightEqualsZeroStringProperty;

class ReferenceHeightLine extends Node {

Expand Down
6 changes: 3 additions & 3 deletions js/common/view/TextPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import EnergySkateParkColorScheme from './EnergySkateParkColorScheme.js';
class TextPanel extends Panel {

/**
* @param {string} textContent - text to fill the panel
* @param {LinkableProperty<string>} stringProperty - text to fill the panel
* @param {Object} [options]
*/
constructor( textContent, options ) {
constructor( stringProperty, options ) {

options = merge( {

Expand All @@ -37,7 +37,7 @@ class TextPanel extends Panel {
resize: false // assumes the text content is static
}, options );

const text = new Text( textContent, {
const text = new Text( stringProperty, {
font: options.font,
maxWidth: options.textMaxWidth
} );
Expand Down
Loading

0 comments on commit 66f6b2c

Please sign in to comment.