Skip to content

Commit

Permalink
pull out decayLikelihoodPercentText #119
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Aug 31, 2023
1 parent 59c8608 commit 6630386
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions js/chart-intro/view/DecayEquationNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,28 @@ class DecayEquationNode extends VBox {
`Min content height must be a max so the space is consistent across all equation forms.
Stable string height is ${stableText.height}` );

const decayLikelihoodPercentText = new Text( new PatternStringProperty(
BuildANucleusStrings.percentageInParenthesesPatternStringProperty, {
decayLikelihoodPercent: new DerivedStringProperty( [
unknownSpacePatternStringProperty,
decayEquationModel.currentCellModelProperty
], ( unknownText, currentCellModel ) => currentCellModel ?
( currentCellModel.decayTypeLikelihoodPercent === null ?
unknownText :
`${currentCellModel.decayTypeLikelihoodPercent}` ) :
'' ) // Shouldn't show in this case anyway
} ), {
maxWidth: 100,
font: BANConstants.LEGEND_FONT
} );

decayEquationModel.currentCellModelProperty.link( currentCellModel => {
equationHBox.visible = true;
decayLikelihoodPercentText.visible = true;

if ( currentCellModel ) {
// There exists a cell model, you are a nuclide that exists, so create all the necessary Text and node components.

const decayLikelihoodPercentText = new Text( new PatternStringProperty(
BuildANucleusStrings.percentageInParenthesesPatternStringProperty, {
decayLikelihoodPercent: new DerivedStringProperty( [
unknownSpacePatternStringProperty
], unknownText => currentCellModel.decayTypeLikelihoodPercent === null ?
unknownText : `${currentCellModel.decayTypeLikelihoodPercent}` )
} ), {
maxWidth: 100,
font: BANConstants.LEGEND_FONT
} );

const currentNuclideSymbol = new DecaySymbolNode( currentCellModel.protonNumber,
currentCellModel.protonNumber + currentCellModel.neutronNumber );
assert && assert( currentNuclideSymbol.height < EQUATION_HBOX_MIN_CONTENT_HEIGHT,
Expand Down

0 comments on commit 6630386

Please sign in to comment.