Skip to content

Commit

Permalink
add visibility annotations to fields, see #190
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsamuel137 committed Nov 11, 2015
1 parent 5043463 commit 0a1171d
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 43 deletions.
3 changes: 2 additions & 1 deletion js/common/model/BodyState.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ define( function( require ) {
var inherit = require( 'PHET_CORE/inherit' );

/**
*
* @param {Vector2} position
* @param {Vector2} velocity
* @param {Vector2} acceleration
Expand All @@ -22,6 +21,8 @@ define( function( require ) {
* @constructor
*/
function BodyState( position, velocity, acceleration, mass, exploded ) {

// all fields are @public
this.position = position;
this.velocity = velocity;
this.acceleration = acceleration;
Expand Down
3 changes: 2 additions & 1 deletion js/common/model/GravityAndOrbitsClock.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ define( function( require ) {
function GravityAndOrbitsClock( baseDTValue, stepping, timeSpeedScale ) {
var thisClock = this;

// all fields are @public
this.runningProperty = new Property( false );
this.simulationTimeProperty = new Property( 0 );
this.dt = baseDTValue * timeSpeedScale.get();

this.steppingProperty = stepping;

timeSpeedScale.link( function() {
thisClock.dt = baseDTValue * timeSpeedScale.get();
} );
Expand Down
2 changes: 2 additions & 0 deletions js/common/model/GravityAndOrbitsModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ define( function( require ) {
* @constructor
*/
function GravityAndOrbitsModel( clock, gravityEnabledProperty ) {

// @public
PropertySet.call( this, {
paused: true
} );
Expand Down
2 changes: 1 addition & 1 deletion js/common/model/ModelState.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ define( function( require ) {
* @constructor
*/
function ModelState( bodyStates ) {
this.bodyStates = bodyStates;
this.bodyStates = bodyStates; // @private
}

return inherit( Object, ModelState, {
Expand Down
2 changes: 2 additions & 0 deletions js/common/model/RewindableProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ define( function( require ) {
*/
function RewindableProperty( playButtonPressedProperty, isSteppingProperty, isRewindingProperty, value ) {
Property.call( this, value );

// all fields are @private
this.playButtonPressedProperty = playButtonPressedProperty;

// if the clock is paused and the user pressed 'step', do not store a rewind point
Expand Down
16 changes: 8 additions & 8 deletions js/common/module/BodyConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ define( function( require ) {
var Vector2 = require( 'DOT/Vector2' );

/**
* @param{number} mass
* @param{number} radius
* @param{number} x
* @param{number} y
* @param{number} vx
* @param{number} vy
* @param {number} mass
* @param {number} radius
* @param {number} x
* @param {number} y
* @param {number} vx
* @param {number} vy
* @constructor
*/
function BodyConfiguration( mass, radius, x, y, vx, vy ) {

// True if the object doesn't move when the clock ticks
this.fixed = false;
// all fields are @public
this.fixed = false; // True if the object doesn't move when the clock ticks
this.mass = mass;
this.radius = radius;
this.x = x;
Expand Down
1 change: 1 addition & 0 deletions js/common/module/GravityAndOrbitsModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ define( function( require ) {
function GravityAndOrbitsModule( showMeasuringTape, createModes, initialModeIndex, showMassCheckBox ) {

// Properties that are common to all "modes" should live here.
// @public
PropertySet.call( this, {
showGravityForce: false,
showPath: false,
Expand Down
10 changes: 4 additions & 6 deletions js/common/module/ModeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ define( function( require ) {
* @constructor
*/
function ModeConfig( zoom ) {
this.dt = DEFAULT_DT;
this.zoom = zoom;

// private members from java that weren't initialized in the constructor
this.forceScale = null;
this.initialMeasuringTapeLocation = null;
this.dt = DEFAULT_DT; // @public
this.zoom = zoom; // @public
this.initialMeasuringTapeLocation = null; // @public
this.forceScale = null; // @protected
}

return inherit( Object, ModeConfig, {
Expand Down
13 changes: 10 additions & 3 deletions js/common/module/ModeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ define( function( require ) {

// static class: SunEarthModeConfig
function SunEarthModeConfig() {

// all fields are @public
this.sun = new BodyConfiguration( SUN_MASS, SUN_RADIUS, 0, 0, 0, 0 );
this.earth = new BodyConfiguration(
EARTH_MASS, EARTH_RADIUS, EARTH_PERIHELION, 0, 0, EARTH_ORBITAL_SPEED_AT_PERIHELION );
Expand All @@ -112,6 +114,8 @@ define( function( require ) {

// static class: SunEarthMoonModeConfig
function SunEarthMoonModeConfig() {

// all fields are @public
this.sun = new BodyConfiguration( SUN_MASS, SUN_RADIUS, 0, 0, 0, 0 );
this.earth = new BodyConfiguration(
EARTH_MASS, EARTH_RADIUS, EARTH_PERIHELION, 0, 0, EARTH_ORBITAL_SPEED_AT_PERIHELION );
Expand All @@ -137,6 +141,8 @@ define( function( require ) {

// static class: EarthMoonModeConfig
function EarthMoonModeConfig() {

// all fields are @public
this.earth = new BodyConfiguration( EARTH_MASS, EARTH_RADIUS, EARTH_PERIHELION, 0, 0, 0 );
this.moon = new BodyConfiguration( MOON_MASS, MOON_RADIUS, MOON_X, MOON_Y, MOON_SPEED, 0 );
ModeConfig.call( this, 400 );
Expand All @@ -158,6 +164,8 @@ define( function( require ) {

// static class: EarthSpaceStationModeConfig
function EarthSpaceStationModeConfig() {

// all fields are @public
this.earth = new BodyConfiguration( EARTH_MASS, EARTH_RADIUS, 0, 0, 0, 0 );
this.spaceStation = new BodyConfiguration( SPACE_STATION_MASS, SPACE_STATION_RADIUS,
SPACE_STATION_PERIGEE + EARTH_RADIUS + SPACE_STATION_RADIUS, 0, 0, SPACE_STATION_SPEED );
Expand Down Expand Up @@ -373,9 +381,8 @@ define( function( require ) {

inherit( Body, Sun );

// @private
this.p = p;
this.modes = []; // in the java version this class extended ArrayList
this.p = p; // @private
this.modes = []; // @public - in the java version this class extended ArrayList, but here we have an array field

sunEarth.center();
sunEarthMoon.center();
Expand Down
2 changes: 2 additions & 0 deletions js/common/module/ModeListParameterList.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ define( function( require ) {
* @constructor
*/
function ModeListParameterList( playButtonPressed, gravityEnabled, stepping, rewinding, timeSpeedScale ) {

// all fields are @public
this.playButtonPressed = playButtonPressed;
this.gravityEnabled = gravityEnabled;

Expand Down
51 changes: 29 additions & 22 deletions js/common/view/BodyRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ define( function( require ) {
// images
var sunMipmap = require( 'mipmap!GRAVITY_AND_ORBITS/sun.png' );

// @abstract
function BodyRenderer( body ) {

Node.call( this );
Expand All @@ -35,20 +36,25 @@ define( function( require ) {
}

// this needs to be called before the static classes are defined, otherwise the inheritance doesn't work right
// this jshint warning notifies if a variable is used before it is defined
/* jshint -W003 */
var renderer = inherit( Node, BodyRenderer, {
getBody: function() {
return this.body;
},
setDiameter: function( viewDiameter ) {}

// @public
getBody: function() {
return this.body;
},
{
SwitchableBodyRenderer: SwitchableBodyRenderer,
ImageRenderer: ImageRenderer,
SunRenderer: SunRenderer
} );
/* jshint -W003 */

/**
* @public
* @abstract
*/
setDiameter: function( viewDiameter ) {
throw new Error( 'must be implemented by subtype' );
}
}, {
SwitchableBodyRenderer: SwitchableBodyRenderer,
ImageRenderer: ImageRenderer,
SunRenderer: SunRenderer
} );

/**
* This SwitchableBodyRenderer displays one representation when the object is at a specific mass, and a different
Expand All @@ -66,10 +72,8 @@ define( function( require ) {
BodyRenderer.call( this, body );
var thisRenderer = this;

this.targetBodyRenderer = targetBodyRenderer;

// @private
this.defaultBodyRenderer = defaultBodyRenderer;
this.targetBodyRenderer = targetBodyRenderer; // @private
this.defaultBodyRenderer = defaultBodyRenderer; // @private

body.massProperty.link( function() {
thisRenderer.removeAllChildren();
Expand All @@ -78,6 +82,8 @@ define( function( require ) {
}

inherit( BodyRenderer, SwitchableBodyRenderer, {

// @public
setDiameter: function( viewDiameter ) {
this.targetBodyRenderer.setDiameter( viewDiameter );
this.defaultBodyRenderer.setDiameter( viewDiameter );
Expand All @@ -91,14 +97,16 @@ define( function( require ) {

BodyRenderer.call( this, body );

this.imageNode = new Image( imageName );
this.viewDiameter = viewDiameter;
this.imageNode = new Image( imageName ); // @private
this.viewDiameter = viewDiameter; // @private
this.addChild( this.imageNode );

this.updateViewDiameter();
}

inherit( BodyRenderer, ImageRenderer, {

// @public
setDiameter: function( viewDiameter ) {
this.viewDiameter = viewDiameter;
this.updateViewDiameter();
Expand Down Expand Up @@ -126,12 +134,11 @@ define( function( require ) {
*/
function SunRenderer( body, viewDiameter, numSegments, twinkleRadius ) {

// @private
this.twinkles = new Path( null, { fill: 'yellow' } );
this.twinkles = new Path( null, { fill: 'yellow' } ); // @private
this.numSegments = numSegments; // @private
this.twinkleRadius = twinkleRadius; // @private

ImageRenderer.call( this, body, viewDiameter, sunMipmap );
this.numSegments = numSegments;
this.twinkleRadius = twinkleRadius;
this.addChild( this.twinkles );
this.twinkles.moveToBack();
this.setDiameter( viewDiameter );
Expand Down
2 changes: 1 addition & 1 deletion js/common/view/MassReadoutNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ define( function( require ) {
function MassReadoutNode( bodyNode, visibleProperty ) {
Node.call( this );
var thisNode = this;
this.bodyNode = bodyNode;
this.bodyNode = bodyNode; // @protected

var readoutText = new Text( this.createText(), {
pickable: false,
Expand Down

0 comments on commit 0a1171d

Please sign in to comment.