From 02f6744ea4ad37345c30e29860b7b3ed17c177b4 Mon Sep 17 00:00:00 2001 From: mbarlow12 Date: Fri, 21 Sep 2018 16:21:42 -0600 Subject: [PATCH] review items complete for Charge.js, see #63 --- js/common/model/Charge.js | 42 ++++++++++++--------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/js/common/model/Charge.js b/js/common/model/Charge.js index 38e9039..c1dc09b 100644 --- a/js/common/model/Charge.js +++ b/js/common/model/Charge.js @@ -17,11 +17,7 @@ define( function( require ) { var DerivedPropertyIO = require( 'AXON/DerivedPropertyIO' ); var inherit = require( 'PHET_CORE/inherit' ); var ISLCObject = require( 'INVERSE_SQUARE_LAW_COMMON/model/ISLCObject' ); - var Property = require( 'AXON/Property' ); - var PropertyIO = require( 'AXON/PropertyIO' ); - - // ifphetio - var BooleanIO = require( 'ifphetio!PHET_IO/types/BooleanIO' ); + var BooleanProperty = require( 'AXON/BooleanProperty' ); /** * @param {number} initialCharge @@ -37,10 +33,8 @@ define( function( require ) { constantRadius: 6.75E-3 // ensure this is in meters (0.675cm) }, options ); - // REVIEW: Consider using BooleanProperty - var constantRadiusProperty = new Property( true, { - tandem: tandem.createTandem( 'constantRadiusProperty' ), - phetioType: PropertyIO( BooleanIO ) + var constantRadiusProperty = new BooleanProperty( true, { + tandem: tandem.createTandem( 'constantRadiusProperty' ) } ); var negativeColor = new Color( '#00f' ); @@ -48,12 +42,9 @@ define( function( require ) { ISLCObject.call( this, initialCharge, initialPosition, valueRange, constantRadiusProperty, tandem, options ); - // @public - object node color is will change with value - // color property will be updated based on a boolean value (negative vs positive) - // brightness will be set according to the Mass/Charge magnitude - // REVIEW: Use Property instead of property in above comment - // REVIEW: Visibility annotation? Type Doc? - // REVIEW: Should this be @protected visibility annotation? I may be wrong here. + // @public {Property.} - object node color is will change with value (linked in ISLCObjectNode.js) + // - color Property will be updated based on a boolean value (negative vs positive) + // - brightness will be set according to the Mass/Charge magnitude this.baseColorProperty = new DerivedProperty( [ this.valueProperty ], function( value ) { var newBaseColor = value < 0 ? negativeColor : positiveColor; return newBaseColor.colorUtilsBrighter( 1 - Math.abs( value ) / valueRange.max ); @@ -66,21 +57,14 @@ define( function( require ) { return inherit( ISLCObject, Charge, { - // @override - // Returns the {number} radius of the charge object - // REVIEW: jsDoc should have @return {type}. Eliminates need for {number} in function description. - // REVIEW: Function description should be first in jsDoc. - // REVIEW: Remove unused parameter? - calculateRadius: function( charge ) { + /** + * Returns the radius of the charge object. + * + * @override + * @return {number} + */ + calculateRadius: function() { return this.radiusProperty.get(); - }, - - // @public - // TODO: reset should be implemented in the parent class ISLCObject - // REVIEW: Handle review - reset: function() { - this.valueProperty.reset(); - this.positionProperty.reset(); } } ); } ); \ No newline at end of file