Skip to content

Commit

Permalink
use tandem name '*Text' consistently for Text nodes, #323
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Sep 2, 2022
1 parent dc8d862 commit a21486c
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 37 deletions.
20 changes: 10 additions & 10 deletions js/common/view/AddMutationsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ class AddMutationsPanel extends NaturalSelectionPanel {

// Individual column headings
const mutationIconNode = new MutationIconNode();
const dominantColumnLabel = new Text( naturalSelectionStrings.dominantStringProperty, {
const dominantColumnText = new Text( naturalSelectionStrings.dominantStringProperty, {
font: NaturalSelectionConstants.ADD_MUTATION_COLUMN_HEADING_FONT,
maxWidth: 60, // determined empirically
tandem: options.tandem.createTandem( 'dominantColumnLabel' ),
tandem: options.tandem.createTandem( 'dominantColumnText' ),
phetioVisiblePropertyInstrumented: false
} );
const recessiveColumnLabel = new Text( naturalSelectionStrings.recessiveStringProperty, {
const recessiveColumnText = new Text( naturalSelectionStrings.recessiveStringProperty, {
font: NaturalSelectionConstants.ADD_MUTATION_COLUMN_HEADING_FONT,
maxWidth: 60, // determined empirically
tandem: options.tandem.createTandem( 'recessiveColumnLabel' ),
tandem: options.tandem.createTandem( 'recessiveColumnText' ),
phetioVisiblePropertyInstrumented: false
} );

Expand All @@ -78,8 +78,8 @@ class AddMutationsPanel extends NaturalSelectionPanel {
spacing: COLUMN_SPACING,
children: [
new AlignBox( mutationIconNode, { group: labelColumnAlignGroup, xAlign: LABEL_COLUMN_X_ALIGN } ),
new AlignBox( dominantColumnLabel, { group: buttonColumnsAlignGroup, xAlign: BUTTON_COLUMNS_X_ALIGN } ),
new AlignBox( recessiveColumnLabel, { group: buttonColumnsAlignGroup, xAlign: BUTTON_COLUMNS_X_ALIGN } )
new AlignBox( dominantColumnText, { group: buttonColumnsAlignGroup, xAlign: BUTTON_COLUMNS_X_ALIGN } ),
new AlignBox( recessiveColumnText, { group: buttonColumnsAlignGroup, xAlign: BUTTON_COLUMNS_X_ALIGN } )
]
} );

Expand Down Expand Up @@ -186,13 +186,13 @@ class Row extends HBox {
}, options );

// label that indicates the gene, to the left of the push buttons
const geneNameNode = new Text( gene.nameProperty, {
const geneNameText = new Text( gene.nameProperty, {
font: NaturalSelectionConstants.ADD_MUTATION_GENE_FONT,
maxWidth: 50, // determined empirically
tandem: options.tandem.createTandem( 'geneNameNode' ),
tandem: options.tandem.createTandem( 'geneNameText' ),
phetioVisiblePropertyInstrumented: false
} );
const geneNameNodeWrapper = new AlignBox( geneNameNode, {
const geneNameTextWrapper = new AlignBox( geneNameText, {
group: labelColumnAlignGroup,
xAlign: LABEL_COLUMN_X_ALIGN
} );
Expand Down Expand Up @@ -236,7 +236,7 @@ class Row extends HBox {

assert && assert( !options.children, 'Row sets children' );
options.children = [
geneNameNodeWrapper,
geneNameTextWrapper,
new Node( {
children: [
new AlignBox( dominantAlleleIcon, alignBoxOptions ),
Expand Down
8 changes: 4 additions & 4 deletions js/common/view/GraphChoiceRadioButtonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class GraphChoiceRadioButtonGroup extends VerticalAquaRadioButtonGroup {
{
value: GraphChoice.POPULATION,
createNode: tandem => new Text( naturalSelectionStrings.populationStringProperty, merge( {
tandem: tandem.createTandem( 'textNode' )
tandem: tandem.createTandem( 'labelText' )
}, TEXT_OPTIONS ) ),
tandemName: 'populationRadioButton'
},
Expand All @@ -60,7 +60,7 @@ class GraphChoiceRadioButtonGroup extends VerticalAquaRadioButtonGroup {
{
value: GraphChoice.PROPORTIONS,
createNode: tandem => new Text( naturalSelectionStrings.proportionsStringProperty, merge( {
tandem: tandem.createTandem( 'textNode' )
tandem: tandem.createTandem( 'labelText' )
}, TEXT_OPTIONS ) ),
tandemName: 'proportionsRadioButton'
},
Expand All @@ -69,7 +69,7 @@ class GraphChoiceRadioButtonGroup extends VerticalAquaRadioButtonGroup {
{
value: GraphChoice.PEDIGREE,
createNode: tandem => new Text( naturalSelectionStrings.pedigreeStringProperty, merge( {
tandem: tandem.createTandem( 'textNode' )
tandem: tandem.createTandem( 'labelText' )
}, TEXT_OPTIONS ) ),
tandemName: 'pedigreeRadioButton'
},
Expand All @@ -78,7 +78,7 @@ class GraphChoiceRadioButtonGroup extends VerticalAquaRadioButtonGroup {
{
value: GraphChoice.NONE,
createNode: tandem => new Text( naturalSelectionStrings.noneStringProperty, merge( {
tandem: tandem.createTandem( 'textNode' )
tandem: tandem.createTandem( 'labelText' )
}, TEXT_OPTIONS ) ),
tandemName: 'noneRadioButton'
}
Expand Down
6 changes: 3 additions & 3 deletions js/common/view/LimitedFoodCheckbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ class LimitedFoodCheckbox extends EnvironmentalFactorCheckbox {
tandem: Tandem.REQUIRED
}, options );

const textNode = new Text( naturalSelectionStrings.limitedFoodStringProperty, {
const labelText = new Text( naturalSelectionStrings.limitedFoodStringProperty, {
font: NaturalSelectionConstants.CHECKBOX_FONT,
maxWidth: 150, // determined empirically
tandem: options.tandem.createTandem( 'textNode' ),
tandem: options.tandem.createTandem( 'labelText' ),
phetioVisiblePropertyInstrumented: false
} );

super( limitedFoodProperty, textNode, alignGroup, options );
super( limitedFoodProperty, labelText, alignGroup, options );
}
}

Expand Down
6 changes: 3 additions & 3 deletions js/common/view/MutationComingNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ class MutationComingNode extends Node {
listener: () => gene.cancelMutation()
} );

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

const hBox = new HBox( {
spacing: 6,
children: [ cancelButton, textNode ]
children: [ cancelButton, labelText ]
} );

const backgroundWidth = hBox.width + 2 * X_MARGIN;
Expand Down
2 changes: 1 addition & 1 deletion js/common/view/PlayButtonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class TextPushButton extends RectangularPushButton {
assert && assert( !options.content, 'TextPushButton sets content' );
assert && assert( !options.textOptions.tandem, 'TextPushButton sets textOptions.tandem' );
options.content = new Text( stringProperty, merge( {}, options.textOptions, {
tandem: options.tandem.createTandem( 'textNode' )
tandem: options.tandem.createTandem( 'labelText' )
} ) );

super( options );
Expand Down
6 changes: 3 additions & 3 deletions js/common/view/ToughFoodCheckbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class ToughFoodCheckbox extends EnvironmentalFactorCheckbox {
tandem: Tandem.REQUIRED
}, options );

const textNode = new Text( naturalSelectionStrings.toughFoodStringProperty, {
const labelText = new Text( naturalSelectionStrings.toughFoodStringProperty, {
font: NaturalSelectionConstants.CHECKBOX_FONT,
maxWidth: 110, // determined empirically
tandem: options.tandem.createTandem( 'textNode' ),
tandem: options.tandem.createTandem( 'labelText' ),
phetioVisiblePropertyInstrumented: false
} );

Expand All @@ -51,7 +51,7 @@ class ToughFoodCheckbox extends EnvironmentalFactorCheckbox {
} );

const labelNode = new HBox( {
children: [ textNode, icon ],
children: [ labelText, icon ],
spacing: NaturalSelectionConstants.CHECKBOX_X_SPACING
} );

Expand Down
6 changes: 3 additions & 3 deletions js/common/view/WolvesCheckbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class WolvesCheckbox extends EnvironmentalFactorCheckbox {
tandem: Tandem.REQUIRED
}, options );

const textNode = new Text( naturalSelectionStrings.wolvesStringProperty, {
const labelText = new Text( naturalSelectionStrings.wolvesStringProperty, {
font: NaturalSelectionConstants.CHECKBOX_FONT,
maxWidth: 110, // determined empirically
tandem: options.tandem.createTandem( 'textNode' ),
tandem: options.tandem.createTandem( 'labelText' ),
phetioVisiblePropertyInstrumented: false
} );

Expand All @@ -51,7 +51,7 @@ class WolvesCheckbox extends EnvironmentalFactorCheckbox {
icon.setScaleMagnitude( -scale, scale ); // reflect so the wolf is facing left

const labelNode = new HBox( {
children: [ textNode, icon ],
children: [ labelText, icon ],
spacing: NaturalSelectionConstants.CHECKBOX_X_SPACING
} );

Expand Down
20 changes: 10 additions & 10 deletions js/common/view/pedigree/PedigreeBunnyNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class PedigreeBunnyNode extends Node {

// Update the genotype abbreviation, must be disposed
// Not instrumented because we decided not to instrument PedigreeBunnyNode.
const genotypeNodeDerivedStringProperty = new DerivedProperty(
const genotypeDerivedStringProperty = new DerivedProperty(
[
furAllelesVisibleProperty, earsAllelesVisibleProperty, teethAllelesVisibleProperty,
...bunny.genotype.getAbbreviationStringDependencies()
Expand All @@ -82,25 +82,25 @@ class PedigreeBunnyNode extends Node {
);

// Must be disposed
const genotypeNodeVisibleProperty = new DerivedProperty(
const genotypeTextVisibleProperty = new DerivedProperty(
[ furAllelesVisibleProperty, earsAllelesVisibleProperty, teethAllelesVisibleProperty ],
( furAllelesVisible, earsAllelesVisible, teethAllelesVisible ) =>
( furAllelesVisible || earsAllelesVisible || teethAllelesVisible )
);

// Genotype abbreviation
// Not instrumented because we decided not to instrument PedigreeBunnyNode.
const genotypeNode = new Text( genotypeNodeDerivedStringProperty, {
visibleProperty: genotypeNodeVisibleProperty,
const genotypeText = new Text( genotypeDerivedStringProperty, {
visibleProperty: genotypeTextVisibleProperty,
font: GENOTYPE_FONT,
maxWidth: bunnyNode.width
} );
children.push( genotypeNode );
children.push( genotypeText );

// Center the genotype abbreviation above the bunny.
genotypeNode.boundsProperty.link( () => {
genotypeNode.centerX = bunnyNode.centerX;
genotypeNode.top = bunnyNode.bottom + 5;
genotypeText.boundsProperty.link( () => {
genotypeText.centerX = bunnyNode.centerX;
genotypeText.top = bunnyNode.bottom + 5;
} );

// Optional selection rectangle, prepended to children
Expand Down Expand Up @@ -139,8 +139,8 @@ class PedigreeBunnyNode extends Node {

// @private {function}
this.disposePedigreeBunnyNode = () => {
genotypeNodeDerivedStringProperty.dispose();
genotypeNodeVisibleProperty.dispose();
genotypeDerivedStringProperty.dispose();
genotypeTextVisibleProperty.dispose();
if ( bunny.diedEmitter.hasListener( addRedCrossMark ) ) {
bunny.diedEmitter.removeListener( addRedCrossMark );
}
Expand Down

0 comments on commit a21486c

Please sign in to comment.