-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
state descriptions for the InfraredPanel, see #374
- Loading branch information
1 parent
e2bd37c
commit b38d56a
Showing
7 changed files
with
75 additions
and
17 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
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
37 changes: 37 additions & 0 deletions
37
js/layer-model/view/describers/SunlightIntensityDescriptionProperty.ts
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,37 @@ | ||
// Copyright 2021, University of Colorado Boulder | ||
|
||
/** | ||
* An observable string that will describe the value of sunlight intensity. This description is relative to | ||
* our sun, and will return something like | ||
* | ||
* "same as our sun" or | ||
* "50% of our sun" | ||
* | ||
* @author Jesse Greenberg (PhET Interactive Simulations) | ||
*/ | ||
import greenhouseEffect from '../../../greenhouseEffect.js'; | ||
import StringProperty from '../../../../../axon/js/StringProperty.js'; | ||
import Multilink from '../../../../../axon/js/Multilink.js'; | ||
import Utils from '../../../../../dot/js/Utils.js'; | ||
import TRangedProperty from '../../../../../axon/js/TRangedProperty.js'; | ||
|
||
class SunlightIntensityDescriptionProperty extends StringProperty { | ||
public constructor( intensityProperty: TRangedProperty ) { | ||
super( '' ); | ||
|
||
// Monitor the intensity Property and update the value of the string. | ||
Multilink.multilink( [ intensityProperty ], intensity => { | ||
const describedIntensityPercentage = Utils.toFixedNumber( intensity, 2 ) * 100; | ||
|
||
if ( describedIntensityPercentage === 100 ) { | ||
this.value = 'same as our sun'; | ||
} | ||
else { | ||
this.value = `${describedIntensityPercentage}% of our sun`; | ||
} | ||
} ); | ||
} | ||
} | ||
|
||
greenhouseEffect.register( 'SunlightIntensityDescriptionProperty', SunlightIntensityDescriptionProperty ); | ||
export default SunlightIntensityDescriptionProperty; |