Skip to content

Commit

Permalink
uninstrument Text, #339
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jul 22, 2023
1 parent fdd3e08 commit 2c2a0c2
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 100 deletions.
9 changes: 3 additions & 6 deletions js/common/view/AddMutationsPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ export default class AddMutationsPanel extends NaturalSelectionPanel {
const mutationIconNode = new MutationIconNode();
const dominantColumnText = new Text( NaturalSelectionStrings.dominantStringProperty, {
font: NaturalSelectionConstants.ADD_MUTATION_COLUMN_HEADING_FONT,
maxWidth: 60, // determined empirically
tandem: options.tandem.createTandem( 'dominantColumnText' )
maxWidth: 60 // determined empirically
} );
const recessiveColumnText = new Text( NaturalSelectionStrings.recessiveStringProperty, {
font: NaturalSelectionConstants.ADD_MUTATION_COLUMN_HEADING_FONT,
maxWidth: 60, // determined empirically
tandem: options.tandem.createTandem( 'recessiveColumnText' )
maxWidth: 60 // determined empirically
} );

// Layout of column headings
Expand Down Expand Up @@ -174,8 +172,7 @@ class Row extends HBox {
// label that indicates the gene, to the left of the push buttons
const geneNameText = new Text( gene.nameProperty, {
font: NaturalSelectionConstants.ADD_MUTATION_GENE_FONT,
maxWidth: 50, // determined empirically
tandem: options.tandem.createTandem( 'geneNameText' )
maxWidth: 50 // determined empirically
} );
const geneNameTextWrapper = new AlignBox( geneNameText, {
group: labelColumnAlignGroup,
Expand Down
3 changes: 1 addition & 2 deletions js/common/view/DiedDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export default class DiedDialog extends Dialog {

const messageText = new Text( NaturalSelectionStrings.allOfTheBunniesHaveDiedStringProperty, {
font: NaturalSelectionConstants.DIALOG_FONT,
maxWidth: 450, // determined empirically
tandem: options.tandem.createTandem( 'messageText' )
maxWidth: 450 // determined empirically
} );

super( messageText, options );
Expand Down
6 changes: 1 addition & 5 deletions js/common/view/EnvironmentalFactorsPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,7 @@ export default class EnvironmentalFactorsPanel extends NaturalSelectionPanel {
} );
const titleText = new Text( titleStringProperty, {
font: NaturalSelectionConstants.TITLE_FONT,
maxWidth: 175, // determined empirically,
phetioVisiblePropertyInstrumented: true,
visiblePropertyOptions: {
phetioFeatured: true
}
maxWidth: 175 // determined empirically,
} );

const content = new VBox( combineOptions<VBoxOptions>( {}, NaturalSelectionConstants.VBOX_OPTIONS, {
Expand Down
10 changes: 4 additions & 6 deletions js/common/view/GenerationClockNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,16 @@ export default class GenerationClockNode extends Node {
} );

// The current generation number, displayed below the circle.
const generationNumberTextTandem = options.tandem.createTandem( 'generationNumberText' );
const generationDerivedStringProperty = new PatternStringProperty( NaturalSelectionStrings.generationValueStringProperty, {
const generationNumberStringProperty = new PatternStringProperty( NaturalSelectionStrings.generationValueStringProperty, {
value: generationClock.clockGenerationProperty
}, {
tandem: generationNumberTextTandem.createTandem( Text.STRING_PROPERTY_TANDEM_NAME )
tandem: options.tandem.createTandem( 'generationNumberStringProperty' )
} );
const generationNumberText = new Text( generationDerivedStringProperty, {
const generationNumberText = new Text( generationNumberStringProperty, {
font: GENERATION_FONT,
fill: 'black',
top: circle.bottom + 3,
maxWidth: 100, // determined empirically
tandem: generationNumberTextTandem
maxWidth: 100 // determined empirically
} );

// Keep the generation number centered below the circular part of the clock.
Expand Down
23 changes: 5 additions & 18 deletions js/common/view/GraphChoiceRadioButtonGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
*/

import EnumerationProperty from '../../../../axon/js/EnumerationProperty.js';
import optionize, { combineOptions, EmptySelfOptions } from '../../../../phet-core/js/optionize.js';
import optionize, { EmptySelfOptions } from '../../../../phet-core/js/optionize.js';
import PickRequired from '../../../../phet-core/js/types/PickRequired.js';
import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js';
import { Text, TextOptions } from '../../../../scenery/js/imports.js';
import AquaRadioButton from '../../../../sun/js/AquaRadioButton.js';
import VerticalAquaRadioButtonGroup, { VerticalAquaRadioButtonGroupOptions } from '../../../../sun/js/VerticalAquaRadioButtonGroup.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import naturalSelection from '../../naturalSelection.js';
import NaturalSelectionStrings from '../../NaturalSelectionStrings.js';
import NaturalSelectionConstants from '../NaturalSelectionConstants.js';
Expand Down Expand Up @@ -49,40 +48,28 @@ export default class GraphChoiceRadioButtonGroup extends VerticalAquaRadioButton
// Population
{
value: GraphChoice.POPULATION,
createNode: ( tandem: Tandem ) => new Text( NaturalSelectionStrings.populationStringProperty,
combineOptions<TextOptions>( {
tandem: tandem.createTandem( 'labelText' )
}, TEXT_OPTIONS ) ),
createNode: () => new Text( NaturalSelectionStrings.populationStringProperty, TEXT_OPTIONS ),
tandemName: `population${AquaRadioButton.TANDEM_NAME_SUFFIX}`
},

// Proportions
{
value: GraphChoice.PROPORTIONS,
createNode: ( tandem: Tandem ) => new Text( NaturalSelectionStrings.proportionsStringProperty,
combineOptions<TextOptions>( {
tandem: tandem.createTandem( 'labelText' )
}, TEXT_OPTIONS ) ),
createNode: () => new Text( NaturalSelectionStrings.proportionsStringProperty, TEXT_OPTIONS ),
tandemName: `proportions${AquaRadioButton.TANDEM_NAME_SUFFIX}`
},

// Pedigree
{
value: GraphChoice.PEDIGREE,
createNode: ( tandem: Tandem ) => new Text( NaturalSelectionStrings.pedigreeStringProperty,
combineOptions<TextOptions>( {
tandem: tandem.createTandem( 'labelText' )
}, TEXT_OPTIONS ) ),
createNode: () => new Text( NaturalSelectionStrings.pedigreeStringProperty, TEXT_OPTIONS ),
tandemName: `pedigree${AquaRadioButton.TANDEM_NAME_SUFFIX}`
},

// None
{
value: GraphChoice.NONE,
createNode: ( tandem: Tandem ) => new Text( NaturalSelectionStrings.noneStringProperty,
combineOptions<TextOptions>( {
tandem: tandem.createTandem( 'labelText' )
}, TEXT_OPTIONS ) ),
createNode: () => new Text( NaturalSelectionStrings.noneStringProperty, TEXT_OPTIONS ),
tandemName: `none${AquaRadioButton.TANDEM_NAME_SUFFIX}`
}
];
Expand Down
3 changes: 1 addition & 2 deletions js/common/view/LimitedFoodCheckbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export default class LimitedFoodCheckbox extends EnvironmentalFactorCheckbox {

const labelText = new Text( NaturalSelectionStrings.limitedFoodStringProperty, {
font: NaturalSelectionConstants.CHECKBOX_FONT,
maxWidth: 90, // determined empirically
tandem: options.tandem.createTandem( 'labelText' )
maxWidth: 90 // determined empirically
} );

super( limitedFoodProperty, labelText, alignGroup, options );
Expand Down
3 changes: 1 addition & 2 deletions js/common/view/MutationComingNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ export default class MutationComingNode extends Node {

const labelText = new Text( NaturalSelectionStrings.mutationComingStringProperty, {
font: NaturalSelectionConstants.MUTATION_COMING_FONT,
maxWidth: 128, // determined empirically
tandem: options.tandem.createTandem( 'labelText' )
maxWidth: 128 // determined empirically
} );

const hBox = new HBox( {
Expand Down
3 changes: 1 addition & 2 deletions js/common/view/PerformanceTimesNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ export default class PerformanceTimesNode extends VBox {
);
timeToMateDerivedStringProperty.link( timeToMateString => console.log( timeToMateString ) );

// Time that it last took to mate.
// See https://github.com/phetsims/natural-selection/issues/60
// Time that it last took to mate. See https://github.com/phetsims/natural-selection/issues/60
const timeToMateNode = new Text( timeToMateDerivedStringProperty, {
font: NaturalSelectionConstants.INSTRUCTIONS_FONT
} );
Expand Down
6 changes: 2 additions & 4 deletions js/common/view/PlayButtonGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Multilink from '../../../../axon/js/Multilink.js';
import Property from '../../../../axon/js/Property.js';
import stepTimer from '../../../../axon/js/stepTimer.js';
import TReadOnlyProperty from '../../../../axon/js/TReadOnlyProperty.js';
import optionize, { combineOptions } from '../../../../phet-core/js/optionize.js';
import optionize from '../../../../phet-core/js/optionize.js';
import PickRequired from '../../../../phet-core/js/types/PickRequired.js';
import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js';
import { Node, NodeOptions, Text, TextOptions } from '../../../../scenery/js/imports.js';
Expand Down Expand Up @@ -162,9 +162,7 @@ class TextPushButton extends RectangularPushButton {
isDisposable: false
}, providedOptions );

options.content = new Text( stringProperty, combineOptions<TextOptions>( {}, options.textOptions, {
tandem: options.tandem.createTandem( 'labelText' )
} ) );
options.content = new Text( stringProperty, options.textOptions );

super( options );
}
Expand Down
3 changes: 1 addition & 2 deletions js/common/view/ToughFoodCheckbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export default class ToughFoodCheckbox extends EnvironmentalFactorCheckbox {

const labelText = new Text( NaturalSelectionStrings.toughFoodStringProperty, {
font: NaturalSelectionConstants.CHECKBOX_FONT,
maxWidth: 90, // determined empirically
tandem: options.tandem.createTandem( 'labelText' )
maxWidth: 90 // determined empirically
} );

const icon = new Image( toughShrub3_png, {
Expand Down
3 changes: 1 addition & 2 deletions js/common/view/WolvesCheckbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ export default class WolvesCheckbox extends EnvironmentalFactorCheckbox {

const labelText = new Text( NaturalSelectionStrings.wolvesStringProperty, {
font: NaturalSelectionConstants.CHECKBOX_FONT,
maxWidth: 90, // determined empirically
tandem: options.tandem.createTandem( 'labelText' )
maxWidth: 90 // determined empirically
} );

const icon = new Image( wolf_png );
Expand Down
3 changes: 1 addition & 2 deletions js/common/view/WorldDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ export default class WorldDialog extends Dialog {
const messageText = new Text( NaturalSelectionStrings.bunniesHaveTakenOverTheWorldStringProperty, {
font: NaturalSelectionConstants.DIALOG_FONT,
fill: 'white',
maxWidth: worldNode.width,
tandem: options.tandem.createTandem( 'messageText' )
maxWidth: worldNode.width
} );

const content = new VBox( {
Expand Down
3 changes: 1 addition & 2 deletions js/common/view/pedigree/AlleleNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ export default class AlleleNode extends HBox {

const text = new Text( abbreviationProperty, {
font: NaturalSelectionConstants.CHECKBOX_FONT,
maxWidth: 12, // determined empirically
tandem: options.tandem.createTandem( 'text' )
maxWidth: 12 // determined empirically
} );

const imageNode = new Image( image, {
Expand Down
6 changes: 2 additions & 4 deletions js/common/view/pedigree/AllelesPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ export default class AllelesPanel extends NaturalSelectionPanel {
// Alleles - title is plural, since we're always showing at least 2 alleles
const titleText = new Text( NaturalSelectionStrings.allelesStringProperty, {
font: NaturalSelectionConstants.TITLE_FONT,
maxWidth: 125, // determined empirically
tandem: options.tandem.createTandem( 'titleText' )
maxWidth: 125 // determined empirically
} );

// A row for each gene
Expand Down Expand Up @@ -125,8 +124,7 @@ class Row extends VBox {

const text = new Text( gene.nameProperty, {
font: NaturalSelectionConstants.CHECKBOX_FONT,
maxWidth: 100, // determined empirically
tandem: checkboxTandem.createTandem( 'text' )
maxWidth: 100 // determined empirically
} );

const checkbox = new Checkbox( visibleProperty, text,
Expand Down
3 changes: 1 addition & 2 deletions js/common/view/pedigree/PedigreeGraphNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ export default class PedigreeGraphNode extends Node {
// 'Select a Bunny' is displayed when there is no selected bunny.
const selectABunnyText = new Text( NaturalSelectionStrings.selectABunnyStringProperty, {
font: NaturalSelectionConstants.INSTRUCTIONS_FONT,
maxWidth: 0.5 * backgroundNode.width,
tandem: options.tandem.createTandem( 'selectABunnyText' )
maxWidth: 0.5 * backgroundNode.width
} );
selectABunnyText.boundsProperty.link( bounds => {
selectABunnyText.centerX = backgroundNode.centerX;
Expand Down
3 changes: 1 addition & 2 deletions js/common/view/population/PopulationGenerationScroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ export default class PopulationGenerationScroller extends HBox {
// label
const labelNode = new Text( NaturalSelectionStrings.generationStringProperty, {
font: options.font,
maxWidth: 250, // determined empirically
tandem: options.tandem.createTandem( 'labelText' )
maxWidth: 250 // determined empirically
} );

// back button
Expand Down
6 changes: 2 additions & 4 deletions js/common/view/population/PopulationGraphNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ export default class PopulationGraphNode extends Node {
const yAxisLabelText = new Text( NaturalSelectionStrings.populationStringProperty, {
font: NaturalSelectionConstants.POPULATION_AXIS_FONT,
rotation: -Math.PI / 2,
maxWidth: 90, // determined empirically
tandem: options.tandem.createTandem( 'yAxisLabelText' )
maxWidth: 90 // determined empirically
} );

// Wrap yAxisLabelText because we'll be observing its boundsProperty.
Expand Down Expand Up @@ -111,8 +110,7 @@ export default class PopulationGraphNode extends Node {
font: NaturalSelectionConstants.INSTRUCTIONS_FONT,
maxWidth: 0.75 * gridWidth,
centerX: gridNode.x + gridWidth / 2,
centerY: gridNode.y + gridHeight / 2,
tandem: options.tandem.createTandem( 'zoomOutToSeeDataText' )
centerY: gridNode.y + gridHeight / 2
} );

options.children = [
Expand Down
3 changes: 1 addition & 2 deletions js/common/view/population/PopulationLegendCheckbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ export default class PopulationLegendCheckbox extends Checkbox {
// text label
const labelText = new Text( labelStringProperty, {
font: NaturalSelectionConstants.CHECKBOX_FONT,
maxWidth: 100, // determined empirically
tandem: options.tandem.createTandem( 'labelText' )
maxWidth: 100 // determined empirically
} );

const hBox = new HBox( {
Expand Down
6 changes: 2 additions & 4 deletions js/common/view/population/PopulationPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,17 @@ export default class PopulationPanel extends NaturalSelectionPanel {
} );

// Data Probe checkbox
const dataProbeCheckboxTandem = options.tandem.createTandem( 'dataProbeCheckbox' );
const labelText = new Text( NaturalSelectionStrings.dataProbeStringProperty, {
font: NaturalSelectionConstants.CHECKBOX_FONT,
maxWidth: 135, // determined empirically
tandem: dataProbeCheckboxTandem.createTandem( 'labelText' )
maxWidth: 135 // determined empirically
} );
const dataProbeCheckboxContent = new AlignBox( labelText, {
group: alignGroup,
xAlign: 'left'
} );
const dataProbeCheckbox = new Checkbox( populationModel.dataProbe.visibleProperty, dataProbeCheckboxContent,
combineOptions<CheckboxOptions>( {}, NaturalSelectionConstants.CHECKBOX_OPTIONS, {
tandem: dataProbeCheckboxTandem
tandem: options.tandem.createTandem( 'dataProbeCheckbox' )
} ) );
dataProbeCheckbox.touchArea = dataProbeCheckbox.localBounds.dilatedXY( xDilation, yDilation );
dataProbeCheckbox.mouseArea = dataProbeCheckbox.localBounds.dilatedXY( xDilation, yDilation );
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/proportions/ProportionsBarNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export default class ProportionsBarNode extends Node {
} );

// Percentages for non-mutant and mutant counts.
// These Text nodes do not take a string Property argument. They are updated via Multilink below.
// These Text nodes do not take a string Property argument, and are updated via Multilink below, so instrument
// them. See https://github.com/phetsims/natural-selection/issues/339
const percentageOptions = {
font: PERCENTAGE_FONT,
bottom: -4,
Expand Down
33 changes: 13 additions & 20 deletions js/common/view/proportions/ProportionsGraphNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import optionize, { combineOptions, EmptySelfOptions } from '../../../../../phet
import PickRequired from '../../../../../phet-core/js/types/PickRequired.js';
import StringUtils from '../../../../../phetcommon/js/util/StringUtils.js';
import PhetFont from '../../../../../scenery-phet/js/PhetFont.js';
import { AlignBox, AlignGroup, HBox, Node, NodeOptions, Rectangle, Text, TextOptions, VBox, VBoxOptions } from '../../../../../scenery/js/imports.js';
import { AlignBox, AlignGroup, HBox, Node, NodeOptions, Rectangle, Text, VBox, VBoxOptions } from '../../../../../scenery/js/imports.js';
import Checkbox, { CheckboxOptions } from '../../../../../sun/js/Checkbox.js';
import naturalSelection from '../../../naturalSelection.js';
import NaturalSelectionStrings from '../../../NaturalSelectionStrings.js';
Expand Down Expand Up @@ -169,8 +169,7 @@ export default class ProportionsGraphNode extends Node {
// 'No Data', visible when we have no data to display.
const noDataText = new Text( NaturalSelectionStrings.noDataStringProperty, {
font: NaturalSelectionConstants.INSTRUCTIONS_FONT,
maxWidth: 0.5 * backgroundNode.width,
tandem: options.tandem.createTandem( 'noDataText' )
maxWidth: 0.5 * backgroundNode.width
} );
noDataText.boundsProperty.link( bounds => {
noDataText.centerX = backgroundNode.centerX;
Expand Down Expand Up @@ -265,23 +264,18 @@ class RowLabel extends VBox {
// 'bunnies' (plural) in multiple translated strings.

// The first line of text indicates which generation the data is related to.
const firstLineOfText = new Text( firstLineStringProperty, combineOptions<TextOptions>( {
tandem: options.tandem.createTandem( 'firstLineOfText' )
}, textOptions ) );
const firstLineOfText = new Text( firstLineStringProperty, textOptions );

// The second line of text shows the count of bunnies.
const secondLineOfTextTandem = options.tandem.createTandem( 'secondLineOfText' );
const secondLineOfTextDerivedStringProperty = new DerivedStringProperty( [
countProperty,
NaturalSelectionStrings.oneBunnyStringProperty,
NaturalSelectionStrings.countBunniesStringProperty
], ( count, oneBunnyString, countBunniesString ) =>
( count === 1 ) ? oneBunnyString : StringUtils.fillIn( countBunniesString, { count: count } ), {
tandem: secondLineOfTextTandem.createTandem( Text.STRING_PROPERTY_TANDEM_NAME )
} );
const secondLineOfText = new Text( secondLineOfTextDerivedStringProperty, combineOptions<TextOptions>( {
tandem: secondLineOfTextTandem
}, textOptions ) );
const secondLineOfTextStringProperty = new DerivedStringProperty( [
countProperty,
NaturalSelectionStrings.oneBunnyStringProperty,
NaturalSelectionStrings.countBunniesStringProperty
],
( count, oneBunnyString, countBunniesString ) =>
( count === 1 ) ? oneBunnyString : StringUtils.fillIn( countBunniesString, { count: count } )
);
const secondLineOfText = new Text( secondLineOfTextStringProperty, textOptions );

options.children = [ firstLineOfText, secondLineOfText ];

Expand Down Expand Up @@ -329,8 +323,7 @@ class Column extends VBox {
const checkboxTandem = options.tandem.createTandem( 'checkbox' );
const text = new Text( gene.nameProperty, {
font: COLUMN_LABEL_FONT,
maxWidth: 100, // determined empirically
tandem: checkboxTandem.createTandem( 'text' )
maxWidth: 100 // determined empirically
} );
const checkbox = new Checkbox( geneVisibleProperty, text,
combineOptions<CheckboxOptions>( {}, NaturalSelectionConstants.CHECKBOX_OPTIONS, {
Expand Down
3 changes: 1 addition & 2 deletions js/common/view/proportions/ProportionsLegendNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ class AlleleLegendNode extends HBox {

const text = new Text( alleleNameProperty, {
font: NaturalSelectionConstants.PROPORTIONS_LEGEND_FONT,
maxWidth: 92, // determined empirically
tandem: options.tandem.createTandem( 'text' )
maxWidth: 92 // determined empirically
} );

options.children = [ rectangleNode, text ];
Expand Down
Loading

0 comments on commit 2c2a0c2

Please sign in to comment.