Skip to content

Commit

Permalink
string tweaking, function and constructor comment cleaning, ChargeCon…
Browse files Browse the repository at this point in the history
…trol positions set from center of layoutBounds, see #33
  • Loading branch information
mbarlow12 committed Nov 10, 2017
1 parent 527e1f2 commit 38dbbc1
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 21 deletions.
6 changes: 3 additions & 3 deletions coulombs-law-strings_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"coulombs-law.title": {
"value": "Coulomb's Law"
},
"macro": {
"value": "Macro"
"screen.macro": {
"value": "Macro Scale"
},
"atomic": {
"screen.atomic": {
"value": "Atomic Scale"
},
"charge1": {
Expand Down
5 changes: 3 additions & 2 deletions js/atomic/CLAtomicScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@ define( function( require ) {
var Screen = require( 'JOIST/Screen' );

// strings
var atomicString = require( 'string!COULOMBS_LAW/atomic' );
var screenAtomicString = require( 'string!COULOMBS_LAW/screen.atomic' );

// images
var atomicScaleScreenIcon = require( 'image!COULOMBS_LAW/atomic_scale_screen_icon.png');

/**
* @param {Tandem} tandem
* @constructor
*/
function CLAtomicScreen( tandem ) {

var options = {
backgroundColorProperty: CoulombsLawColorProfile.backgroundProperty,
name: atomicString,
name: screenAtomicString,
homeScreenIcon: new Image( atomicScaleScreenIcon, { tandem: tandem.createTandem( 'icon' ) } )
};

Expand Down
1 change: 1 addition & 0 deletions js/atomic/model/CoulombsLawAtomicModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ define( function( require ) {
var ISLCConstants = require( 'INVERSE_SQUARE_LAW_COMMON/ISLCConstants' );

/**
* @param {Tandem} tandem
* @constructor
*/
function CoulombsLawAtomicModel( tandem ) {
Expand Down
3 changes: 2 additions & 1 deletion js/atomic/view/CoulombsLawAtomicView.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ define( function( require ) {
// constants
var CHARGE_NODE_Y_POSITION = 205;
var SCALE_FACTOR = 1 / ISLCConstants.coulombsPerAtomicUnit; // number of e in one C
var MODEL_VIEW_TRANSFORM_SCALE = 5E12;
var MODEL_VIEW_TRANSFORM_SCALE = 5E12; // scales the modelViewTransorm for accurate positioning on Macro and Atomic screens

/**
* @param {CoulombsLawModel} coulombsLawModel
* @param {Tandem} tandem
Expand Down
7 changes: 3 additions & 4 deletions js/common/model/Charge.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ define( function( require ) {

/**
* @param {number} initialCharge
* @param {number} initialPosition
* @param {number} initialPosition - only for the x coordinate
* @param {Tandem} tandem
* @param {Object} options
* @constructor
Expand Down Expand Up @@ -61,9 +61,8 @@ define( function( require ) {

return inherit( ISLCObject, Charge, {

/**
* @override
*/
// @override
// Returns the {number} radius of the charge object
calculateRadius: function( charge ) {
return this.radiusProperty.get();
},
Expand Down
4 changes: 4 additions & 0 deletions js/common/model/CoulombsLawCommonModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ define( function( require ) {
var TBoolean = require( 'ifphetio!PHET_IO/types/TBoolean' );

/**
* @param {Charge} charge1 - The left charge
* @param {Charge} charge2 - The right charge
* @param {number} leftBoundary
* @param {number} rightBoundary
* @constructor
*/
function CoulombsLawCommonModel( charge1, charge2, leftBoundary, rightBoundary, tandem, options ) {
Expand Down
9 changes: 6 additions & 3 deletions js/common/view/ChargeControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ define( function( require ) {

/**
* @param {string} titleString
* @param {Property.<number>} objectProperty
* @param {Range} valueRange
* @param {Color} thumbColor
* @param {string} unitString - for the NumberControl readout
* @param {Property.<number>} objectProperty - the number Property associated with the ISLCObject
* @param {Range} valueRange - max and min values for the object property, used for display and as NumberControl argument
* @param {number} scaleFactor - multiplicative constant for getting proper readouts/positions on Macro and Atomic screens
* @param {Tandem} tandem
* @param {Object} options
* @constructor
*/
function ChargeControl( titleString, unitString, objectProperty, valueRange, scaleFactor, tandem, options ) {
Expand Down Expand Up @@ -66,6 +68,7 @@ define( function( require ) {
coulombsLaw.register( 'ChargeControl', ChargeControl );

return inherit( ISLCObjectControl, ChargeControl, {
// @public
reset: function() {
this.chargeControlProperty.reset();
}
Expand Down
4 changes: 3 additions & 1 deletion js/common/view/ChargeControlSliderThumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ define( function( require ) {
var ZERO_FILL = new Color( 'gray' );

/**
* Constructor.
* @param {Property.<number>} objectProperty - the number Property associated with the ISLCObject
* @param {Object} options
* @constructor
*/
function ChargeControlSliderThumb( objectProperty, options ) {

Expand Down Expand Up @@ -61,7 +61,9 @@ define( function( require ) {

/**
* Set the thumb fill based on the linked property's value
*
* @param {number} propertyValue
* @returns {Color}
*/
getUpdatedFill: function( propertyValue ) {

Expand Down
14 changes: 11 additions & 3 deletions js/common/view/ChargeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ define( function( require ) {

/**
* @param {CoulombsLawbModel} model
* @param {ChargeModel} chargeModel
* @param {Charge} chargeObjectModel
* @param {Bounds2} layoutBounds
* @param {ModelViewTransform2} modelViewTransform
* @param {Tandem} tandem
* @param {Object} [options]
* @param {Object} options
* @constructor
*/
function ChargeNode( model, chargeObjectModel, layoutBounds, modelViewTransform, tandem, options ) {
Expand Down Expand Up @@ -82,6 +82,10 @@ define( function( require ) {

return inherit( ISLCObjectNode, ChargeNode, {

/**
* Alter the radial gradient based on the radius of the charge object
* @param {Color} baseColor
*/
updateGradient: function( baseColor ) {
var radius = this.modelViewTransform.modelToViewDeltaX( this.objectModel.radiusProperty.get() );
// if the radius = 1, radial gradient will throw an divide-by-zero error
Expand All @@ -91,7 +95,11 @@ define( function( require ) {
this.objectCircle.fill = new RadialGradient( -radius * 0.6, -radius * 0.6, 1, -radius * 0.6, -radius * 0.6, radius )
.addColorStop( 0, baseColor.colorUtilsBrighter( 0.5 ).toCSS() )
.addColorStop( 1, baseColor.toCSS() );
},
},

/**
* Updates the node's arrow length, force readout, and puller image.
*/
redrawForce: function () {
this.arrowNode.scientificNotationMode = this.model.scientificNotationProperty.get();
ISLCObjectNode.prototype.redrawForce.call( this );
Expand Down
10 changes: 8 additions & 2 deletions js/common/view/CoulombsLawCommonView.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@ define( function( require ) {

/**
* @param {CoulombsLawModel} coulombsLawModel
* @param {number} scaleFactor - multiplicative constant to distinguish between Macro and Atomic scales
* @param {string} unitString
* @param {number} modelViewTransformScale - allows for distinct layout scales between Macro and Atomic screens
* @param {Tandem} tandem
* @constructor
*/
function CoulombsLawCommonView( coulombsLawModel, scaleFactor, unitString, modelViewTransformScale, tandem ) {

ScreenView.call( this, { layoutBounds: new Bounds2( 0, 0, 768, 464 ) } );

var self = this;

var rightAlignment = this.layoutBounds.maxX - 10;
var bottomAlignment = this.layoutBounds.maxY - 10;

Expand Down Expand Up @@ -100,7 +106,7 @@ define( function( require ) {
scaleFactor,
tandem.createTandem( 'charge2Control' ),
{
right: rightAlignment - 387,
right: self.layoutBounds.centerX - 5,
top: coulombsLawParameterCheckbox.top
}
);
Expand All @@ -115,7 +121,7 @@ define( function( require ) {
scaleFactor,
tandem.createTandem( 'charge2Control' ),
{
right: rightAlignment - 193,
left: self.layoutBounds.centerX + 5,
top: coulombsLawParameterCheckbox.top
}
);
Expand Down
4 changes: 4 additions & 0 deletions js/common/view/CoulombsLawGlobalOptionsNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ define( function ( require ) {
// strings
var optionsProjectorModeString = require( 'string!COULOMBS_LAW/options.projectorMode' );


/**
* @param {Tandem} tandem
*/
function CoulombsLawGlobalOptionsNode( tandem ) {

var checkBoxText = new Text( optionsProjectorModeString, {
Expand Down
5 changes: 3 additions & 2 deletions js/macro/CLMacroScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ define( function( require ) {
var Screen = require( 'JOIST/Screen' );

// strings
var macroString = require( 'string!COULOMBS_LAW/macro' );
var screenMacroString = require( 'string!COULOMBS_LAW/screen.macro' );

// images
var macroScreenIcon = require( 'image!COULOMBS_LAW/macro_screen_icon.png' );

/**
* @param {Tandem} tandem
* @constructor
*/
function CLMacroScreen( tandem ) {

var options = {
backgroundColorProperty: CoulombsLawColorProfile.backgroundProperty,
name: macroString,
name: screenMacroString,
homeScreenIcon: new Image( macroScreenIcon, { tandem: tandem.createTandem( 'icon' ) } )
};

Expand Down
1 change: 1 addition & 0 deletions js/macro/model/CoulombsLawMacroModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ define( function( require ) {
var Vector2 = require( 'DOT/Vector2' );

/**
* @param {Tandem} tandem
* @constructor
*/
function CoulombsLawMacroModel( tandem ) {
Expand Down
1 change: 1 addition & 0 deletions js/macro/view/CoulombsLawMacroView.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ define( function( require ) {

/**
* @param {CoulombsLawModel} coulombsLawModel
* @param {Tandem} tandem
* @constructor
*/
function CoulombsLawMacroView( coulombsLawModel, tandem ) {
Expand Down

0 comments on commit 38dbbc1

Please sign in to comment.