/** * @param {Object} [options] * @constructor */ function RightArrowNode( options ) { options = _.extend( { length: 70, tailWidth: 15, headWidth: 35, headHeight: 30 }, options ); ArrowNode.call( this, 0, 0, options.length, 0, options ); }
/** * @param {Property.<Equation>} equationProperty * @param {Object} [options] * @constructor */ function RightArrowNode( equationProperty, options ) { options = _.extend( { tailWidth: 15, headWidth: 35, headHeight: 30 }, options ); this.equationProperty = equationProperty; // @private this._highlightEnabled = true; // @private ArrowNode.call( this, 0, 0, ARROW_LENGTH, 0, options ); // Wire observer to current equation. var self = this; var balancedObserver = self.updateHighlight.bind( self ); equationProperty.link( function( newEquation, oldEquation ) { if ( oldEquation ) { oldEquation.balancedProperty.unlink( balancedObserver ); } newEquation.balancedProperty.link( balancedObserver ); } ); }
/** * Constructor for the labeled arrow in the spectrum window. * * @param {number} length - Length of the arrow * @param {string} orientation - options are 'left' or 'right'. Determines direction of the arrow. * @param {string} captionText - Description of what the arrow node represents. * @param {string} leftColor * @param {string} rightColor * @constructor */ function LabeledArrow( length, orientation, captionText, leftColor, rightColor ) { var Orientation = { POINTING_LEFT: 'left', POINTING_RIGHT: 'right' }; // Set arrow direction and fill based on desired orientation. var gradientPaint; // Point the node in the right direction. if ( orientation === Orientation.POINTING_LEFT ) { gradientPaint = new LinearGradient( 0, 0, -length, 0 ).addColorStop( 0, leftColor ).addColorStop( 1, rightColor ); length = -length; // Negate the x component of the arrow head so that it points left. } else { assert && assert( orientation === Orientation.POINTING_RIGHT ); gradientPaint = new LinearGradient( 0, 0, length, 0 ).addColorStop( 0, leftColor ).addColorStop( 1, rightColor ); } ArrowNode.call( this, 0, 0, length, 0, { headHeight: ARROW_HEAD_HEIGHT, headWidth: ARROW_HEAD_WIDTH, tailWidth: ARROW_TAIL_WIDTH, fill: gradientPaint, lineWidth: 2 } ); // Create and add the textual label. Scale it so that it can handle translations. Max label length is the arrow // length minus twice the head length. var label = new Text( captionText, { font: LABEL_FONT } ); if ( label.width > this.width - 2 * ARROW_HEAD_WIDTH ) { label.scale( ( this.width - 2 * ARROW_HEAD_WIDTH ) / label.width ); } label.center = this.center; this.addChild( label ); }