<commit_before>// Copyright 2019, University of Colorado Boulder

/**
 * A Scenery Node that portrays a thermometer and a triangular indicator of the precise location where the temperature
 * is being sensed. The triangular indicator can be filled with a color to make it more clear what exactly is being
 * measured.
 *
 * @author <NAME>
 * @author <NAME>
 */
define( require => {
  'use strict';

  // modules
  const Color = require( 'SCENERY/util/Color' );
  const merge = require( 'PHET_CORE/merge' );
  const Node = require( 'SCENERY/nodes/Node' );
  const Path = require( 'SCENERY/nodes/Path' );
  const sceneryPhet = require( 'SCENERY_PHET/sceneryPhet' );
  const Shape = require( 'KITE/Shape' );
  const ThermometerNode = require( 'SCENERY_PHET/ThermometerNode' );

  class TemperatureAndColorSensorNode extends Node {

    /**
     * @param {number} minTemperature
     * @param {number} maxTemperature
     * @param {Property.<number>} temperatureProperty
     * @param {Object} [options]
     */
    constructor( minTemperature, maxTemperature, temperatureProperty, options ) {
      super();

      options = merge( {
        horizontalSpace: 3, // horizontal spacing between color indicator and thermometer
        bottomOffset: 5, // vertical difference between bottom of color indicator and thermometer
        thermometerNodeOptions: {
          bulbDiameter: 30,
          tubeWidth: 18,
          lineWidth: 2,
          tickSpacingTemperature: 25,
          majorTickLength: 10,
          minorTickLength: 5,
          backgroundFill: new Color( 256, 256, 256, 0.67 )
        },
        colorIndicatorOptions: {
          fill: new Color( 0, 0, 0, 0 ),
          lineWidth: 2,
          stroke: 'black',
          lineJoin: 'round',
          sideLength: 18
        }
      }, options );

      // Add the triangle that will display the sensed color.  The leftmost point of this triangle will correspond to the
      // position of the sensor in the model.
      const triangleShape = new Shape();
      const s = options.colorIndicatorOptions.sideLength;
      triangleShape.moveTo( 0, 0 )
        .lineTo( Math.cos( Math.PI / 6 ) * s, -Math.sin( Math.PI / 6 ) * s )
        .lineTo( Math.cos( Math.PI / 6 ) * s, Math.sin( Math.PI / 6 ) * s )
        .close();

      // @private {Path}
      this.colorIndicatorNode = new Path( triangleShape, options.colorIndicatorOptions );
      this.addChild( this.colorIndicatorNode );

      // @private {ThermometerNode}
      this.thermometerNode = new ThermometerNode(
        minTemperature,
        maxTemperature,
        temperatureProperty,
        _.extend( options.thermometerNodeOptions, {
          left: this.colorIndicatorNode.right + options.horizontalSpace,
          bottom: this.colorIndicatorNode.bottom + options.bottomOffset
        } )
      );
      this.addChild( this.thermometerNode );

      this.mutate( options );
    }

    /**
     * Allows for the arrow node's fill color to be changed publicly
     * @public
     *
     * @param {Color} color
     */
    changeColor( color ) {
      this.colorIndicatorNode.fill = color;
    }

    /**
     * Returns bounds for thermomemeter node
     * @public
     *
     * @returns {Bounds2}
     */
    getThermometerBounds() {
      return this.thermometerNode.bounds;
    }

    get thermometerBounds() { return this.getThermometerBounds(); }

    /**
     * Returns bounds for color indicator arrow node
     * @public
     *
     * @returns {Bounds2}
     */
    getColorIndicatorBounds() {
      return this.colorIndicatorNode.bounds;
    }

    get colorIndicatorBounds() { return this.getColorIndicatorBounds(); }
  }

  return sceneryPhet.register( 'TemperatureAndColorSensorNode', TemperatureAndColorSensorNode );
} );<commit_msg>TemperatureAndColorSensorNode uses Range instead of min/max temp parameters, see https://github.com/phetsims/scenery-phet/issues/523<commit_after>// Copyright 2019, University of Colorado Boulder

/**
 * A Scenery Node that portrays a thermometer and a triangular indicator of the precise location where the temperature
 * is being sensed. The triangular indicator can be filled with a color to make it more clear what exactly is being
 * measured.
 *
 * @author <NAME>
 * @author <NAME>
 */
define( require => {
  'use strict';

  // modules
  const Color = require( 'SCENERY/util/Color' );
  const merge = require( 'PHET_CORE/merge' );
  const Node = require( 'SCENERY/nodes/Node' );
  const Path = require( 'SCENERY/nodes/Path' );
  const sceneryPhet = require( 'SCENERY_PHET/sceneryPhet' );
  const Shape = require( 'KITE/Shape' );
  const ThermometerNode = require( 'SCENERY_PHET/ThermometerNode' );

  class TemperatureAndColorSensorNode extends Node {

    /**
     * @param {Range} minTemperature
     * @param {Property.<number>} temperatureProperty
     * @param {Object} [options]
     */
    constructor( temperatureRange, temperatureProperty, options ) {
      super();

      options = merge( {
        horizontalSpace: 3, // horizontal spacing between color indicator and thermometer
        bottomOffset: 5, // vertical difference between bottom of color indicator and thermometer
        thermometerNodeOptions: {
          bulbDiameter: 30,
          tubeWidth: 18,
          lineWidth: 2,
          tickSpacingTemperature: 25,
          majorTickLength: 10,
          minorTickLength: 5,
          backgroundFill: new Color( 256, 256, 256, 0.67 )
        },
        colorIndicatorOptions: {
          fill: new Color( 0, 0, 0, 0 ),
          lineWidth: 2,
          stroke: 'black',
          lineJoin: 'round',
          sideLength: 18
        }
      }, options );

      // Add the triangle that will display the sensed color.  The leftmost point of this triangle will correspond to the
      // position of the sensor in the model.
      const triangleShape = new Shape();
      const s = options.colorIndicatorOptions.sideLength;
      triangleShape.moveTo( 0, 0 )
        .lineTo( Math.cos( Math.PI / 6 ) * s, -Math.sin( Math.PI / 6 ) * s )
        .lineTo( Math.cos( Math.PI / 6 ) * s, Math.sin( Math.PI / 6 ) * s )
        .close();

      // @private {Path}
      this.colorIndicatorNode = new Path( triangleShape, options.colorIndicatorOptions );
      this.addChild( this.colorIndicatorNode );

      // @private {ThermometerNode}
      this.thermometerNode = new ThermometerNode(
        temperatureRange.min,
        temperatureRange.max,
        temperatureProperty,
        _.extend( options.thermometerNodeOptions, {
          left: this.colorIndicatorNode.right + options.horizontalSpace,
          bottom: this.colorIndicatorNode.bottom + options.bottomOffset
        } )
      );
      this.addChild( this.thermometerNode );

      this.mutate( options );
    }

    /**
     * Allows for the arrow node's fill color to be changed publicly
     * @public
     *
     * @param {Color} color
     */
    changeColor( color ) {
      this.colorIndicatorNode.fill = color;
    }

    /**
     * Returns bounds for thermomemeter node
     * @public
     *
     * @returns {Bounds2}
     */
    getThermometerBounds() {
      return this.thermometerNode.bounds;
    }

    get thermometerBounds() { return this.getThermometerBounds(); }

    /**
     * Returns bounds for color indicator arrow node
     * @public
     *
     * @returns {Bounds2}
     */
    getColorIndicatorBounds() {
      return this.colorIndicatorNode.bounds;
    }

    get colorIndicatorBounds() { return this.getColorIndicatorBounds(); }
  }

  return sceneryPhet.register( 'TemperatureAndColorSensorNode', TemperatureAndColorSensorNode );
} );
{'fraction_non_alphanumeric': 0.1015215110178384, 'fraction_numerical': 0.011673662119622246, 'mean_word_length': 2.5382830626450117, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '347445', 'n_tokens_mistral': 2268, 'n_tokens_neox': 2141, 'n_words': 613}