Skip to content

Commit

Permalink
Instrument thermometer tick marks, see #83
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisklus committed May 2, 2019
1 parent ca43108 commit 5e8a85b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 6 deletions.
16 changes: 10 additions & 6 deletions js/blackbody-spectrum/view/BlackbodySpectrumThermometer.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ define( function( require ) {
ThermometerNode.call( this, options.minTemperature, options.maxTemperature, temperatureProperty, options );

// labeled tick marks
for ( var i = 0; i < TICK_MARKS.length; i++ ) {
this.addChild( this.createLabeledTick( TICK_MARKS[ i ].text, TICK_MARKS[ i ].temperature, options ) );
}
const tickContainer = new Node( {
children: _.range( 0, TICK_MARKS.length ).map( i => this.createLabeledTick( i, options ) ),
tandem: options.tandem.createTandem( 'labelsNode' )
} );
this.addChild( tickContainer );

var thumbDimension = new Dimension2( options.thumbSize, options.thumbSize );
// @private thumb node thermometer's slider
Expand Down Expand Up @@ -125,13 +127,15 @@ define( function( require ) {

/**
* Creates a labeled tick mark.
* @param {string} text
* @param {number} temperature
* @param {number} tickMarkIndex
* @param {Object} options - options that were provided to BlackbodySpectrumThermometer constructor
* @returns {Node}
* @private
*/
createLabeledTick: function( text, temperature, options ) {
createLabeledTick: function( tickMarkIndex, options ) {
const text = TICK_MARKS[ tickMarkIndex ].text;
const temperature = TICK_MARKS[ tickMarkIndex ].temperature;

var objectHeight = -this.temperatureToYPos( temperature );
var tickMarkLength = options.tubeWidth * 0.5;

Expand Down
44 changes: 44 additions & 0 deletions js/phet-io/blackbody-spectrum-phet-io-elements-baseline.js
Original file line number Diff line number Diff line change
Expand Up @@ -1816,6 +1816,50 @@ window.phet.phetio.phetioElementsBaseline =
"phetioStudioControl": true,
"phetioTypeName": "PropertyIO.<BooleanIO>"
},
"blackbodySpectrum.blackbodySpectrumScreen.view.thermometerNode.labelsNode": {
"phetioDocumentation": "",
"phetioEventType": "model",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": false,
"phetioStudioControl": true,
"phetioTypeName": "NodeIO"
},
"blackbodySpectrum.blackbodySpectrumScreen.view.thermometerNode.labelsNode.opacityProperty": {
"phetioDocumentation": "Opacity of the parent NodeIO, between 0 (invisible) and 1 (fully visible)",
"phetioEventType": "model",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": true,
"phetioStudioControl": true,
"phetioTypeName": "NumberPropertyIO"
},
"blackbodySpectrum.blackbodySpectrumScreen.view.thermometerNode.labelsNode.pickableProperty": {
"phetioDocumentation": "Sets whether the node will be pickable (and hence interactive), see the NodeIO documentation for more details",
"phetioEventType": "model",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": true,
"phetioStudioControl": true,
"phetioTypeName": "PropertyIO.<NullableIO.<BooleanIO>>"
},
"blackbodySpectrum.blackbodySpectrumScreen.view.thermometerNode.labelsNode.visibleProperty": {
"phetioDocumentation": "Controls whether the Node will be visible (and interactive), see the NodeIO documentation for more details.",
"phetioEventType": "model",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": true,
"phetioStudioControl": true,
"phetioTypeName": "PropertyIO.<BooleanIO>"
},
"blackbodySpectrum.blackbodySpectrumScreen.view.thermometerNode.opacityProperty": {
"phetioDocumentation": "Opacity of the parent NodeIO, between 0 (invisible) and 1 (fully visible)",
"phetioEventType": "model",
Expand Down

0 comments on commit 5e8a85b

Please sign in to comment.