-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create NuclideChartCellModel.ts and cellModelArray to keep track of p…
…roton number, neutron number, and decayType of a cell. See #46.
- Loading branch information
Showing
5 changed files
with
79 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2023, University of Colorado Boulder | ||
|
||
/** | ||
* Model of a cell in the Nuclide Chart. Tracks proton number, neutron number, and decay type of cell. | ||
* | ||
* @author Luisa Vargas | ||
* @author Marla Schulz (PhET Interactive Simulations) | ||
*/ | ||
|
||
import buildANucleus from '../../buildANucleus.js'; | ||
import DecayType from '../../common/view/DecayType.js'; | ||
import AtomIdentifier from '../../../../shred/js/AtomIdentifier.js'; | ||
import BANColors from '../../common/BANColors.js'; | ||
import { ColorProperty } from '../../../../scenery/js/imports.js'; | ||
|
||
class NuclideChartCellModel { | ||
|
||
public readonly protonNumber: number; | ||
public readonly neutronNumber: number; | ||
public readonly decayType: DecayType | null; | ||
public readonly colorProperty: ColorProperty; | ||
|
||
public constructor( protonNumber: number, neutronNumber: number ) { | ||
|
||
// get first decay in available decays to color the cell according to that decay type | ||
const decayType = AtomIdentifier.getAvailableDecays( protonNumber, neutronNumber )[ 0 ]; | ||
|
||
this.protonNumber = protonNumber; | ||
this.neutronNumber = neutronNumber; | ||
this.decayType = DecayType.enumeration.getValue( decayType ); | ||
this.colorProperty = AtomIdentifier.isStable( protonNumber, neutronNumber ) ? BANColors.stableColorProperty : | ||
decayType === undefined ? BANColors.unknownColorProperty : // no available decays, unknown decay type | ||
this.decayType.colorProperty; | ||
} | ||
} | ||
|
||
buildANucleus.register( 'NuclideChartCellModel', NuclideChartCellModel ); | ||
export default NuclideChartCellModel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters