From 5e8a85bae1b906e687e3381f93c02f83566b59fb Mon Sep 17 00:00:00 2001 From: chrisklus Date: Wed, 1 May 2019 21:52:17 -0600 Subject: [PATCH] Instrument thermometer tick marks, see https://github.com/phetsims/blackbody-spectrum/issues/83 --- .../view/BlackbodySpectrumThermometer.js | 16 ++++--- ...body-spectrum-phet-io-elements-baseline.js | 44 +++++++++++++++++++ 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/js/blackbody-spectrum/view/BlackbodySpectrumThermometer.js b/js/blackbody-spectrum/view/BlackbodySpectrumThermometer.js index 87453e0..82b4142 100644 --- a/js/blackbody-spectrum/view/BlackbodySpectrumThermometer.js +++ b/js/blackbody-spectrum/view/BlackbodySpectrumThermometer.js @@ -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 @@ -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; diff --git a/js/phet-io/blackbody-spectrum-phet-io-elements-baseline.js b/js/phet-io/blackbody-spectrum-phet-io-elements-baseline.js index 725ac31..e9acf3a 100644 --- a/js/phet-io/blackbody-spectrum-phet-io-elements-baseline.js +++ b/js/phet-io/blackbody-spectrum-phet-io-elements-baseline.js @@ -1816,6 +1816,50 @@ window.phet.phetio.phetioElementsBaseline = "phetioStudioControl": true, "phetioTypeName": "PropertyIO." }, + "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.>" + }, + "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." + }, "blackbodySpectrum.blackbodySpectrumScreen.view.thermometerNode.opacityProperty": { "phetioDocumentation": "Opacity of the parent NodeIO, between 0 (invisible) and 1 (fully visible)", "phetioEventType": "model",