-
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.
Add colors to DecayType.ts. Move DecayType.ts to common. Create Nucli…
…deChartNode.ts that has decay legend boxes. See #46.
- Loading branch information
Showing
6 changed files
with
85 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2022, University of Colorado Boulder | ||
|
||
/** | ||
* Node that represents the initial part of the Nuclide chart, up to 10 protons and 12 neutrons. | ||
* | ||
* @author Luisa Vargas | ||
*/ | ||
|
||
import Dimension2 from '../../../../dot/js/Dimension2.js'; | ||
import { HBox, Node, NodeOptions, ProfileColorProperty, Rectangle, Text } from '../../../../scenery/js/imports.js'; | ||
import buildANucleus from '../../buildANucleus.js'; | ||
import BANColors from '../../common/BANColors.js'; | ||
import BuildANucleusStrings from '../../BuildANucleusStrings.js'; | ||
import PhetFont from '../../../../scenery-phet/js/PhetFont.js'; | ||
import DecayType from '../../common/view/DecayType.js'; | ||
|
||
type NuclideChartNodeOptions = NodeOptions; | ||
|
||
// constants | ||
const LEGEND_FONT = new PhetFont( 16 ); | ||
const LEGEND_KEY_BOX_SIZE = 30; | ||
|
||
class NuclideChartNode extends Node { | ||
|
||
public constructor( providedOptions: NuclideChartNodeOptions ) { | ||
|
||
super( providedOptions ); | ||
|
||
const createLegendItem = ( decayTypeText: string, decayTypeColor: ProfileColorProperty ): HBox => { | ||
return new HBox( { | ||
children: [ | ||
new Rectangle( { rectSize: new Dimension2( LEGEND_KEY_BOX_SIZE, LEGEND_KEY_BOX_SIZE ), fill: decayTypeColor } ), | ||
new Text( decayTypeText, { font: LEGEND_FONT } ) | ||
], | ||
spacing: 10 | ||
// TODO: add maxWidth | ||
} ); | ||
}; | ||
|
||
const decayHBoxes = []; | ||
const stableHBox = createLegendItem( BuildANucleusStrings.stable, BANColors.stableColorProperty ); | ||
decayHBoxes.push( stableHBox ); | ||
|
||
DecayType.enumeration.values.forEach( decayType => { | ||
decayHBoxes.push( createLegendItem( decayType.label, decayType.colorProperty ) ); | ||
} ); | ||
|
||
} | ||
} | ||
|
||
buildANucleus.register( 'NuclideChartNode', NuclideChartNode ); | ||
export default NuclideChartNode; |
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
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