Skip to content

Commit

Permalink
avoid decorator pattern for RichText, see phetsims/sun#860
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Aug 19, 2024
1 parent 704fba5 commit 2c4a10e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions js/micro/view/SpectrumDiagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,15 @@ const addBandLabel = ( thisNode, lowEndFrequency, highEndFrequency, labelString,
const width = rightBoundaryX - leftBoundaryX;
const centerX = leftBoundaryX + width / 2;

const contentNode = new Node();

// Create and add the label.
const labelText = new RichText( labelString, {
replaceNewlines: true,
align: 'center',
font: LABEL_FONT
} );
thisNode.addChild( labelText );
contentNode.addChild( labelText );

if ( ( labelText.width + 10 ) > width ) {
// Scale the label to fit with a little bit of padding on each side.
Expand All @@ -496,7 +498,9 @@ const addBandLabel = ( thisNode, lowEndFrequency, highEndFrequency, labelString,
labelText.setCenter( new Vector2( centerX, STRIP_HEIGHT / 2 ) );

// pdom
addFrequencyAndLabelDescriptions( labelText, pdomLabel, frequencyDescription, wavelengthDescription );
addFrequencyAndLabelDescriptions( contentNode, pdomLabel, frequencyDescription, wavelengthDescription );

thisNode.addChild( contentNode );
};

/**
Expand Down

0 comments on commit 2c4a10e

Please sign in to comment.