Skip to content

Commit

Permalink
constructor and function documentation, see #19
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarlow12 committed Nov 21, 2017
1 parent 3bf9ca5 commit 4dbe55c
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 10 deletions.
2 changes: 2 additions & 0 deletions js/model/ISLCModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ define( function( require ) {
// @public - emits an event when the model is updated in by step
this.stepEmitter = new Emitter();

// @public
// derived property that calculates the force based on changes to values and positions
// objects are never destroyed, so forceProperty does not require disposal
this.forceProperty = new DerivedProperty(
Expand All @@ -81,6 +82,7 @@ define( function( require ) {
return self.calculateForce( v1, v2, distance );
}
);

// when sim is reset, we only reset the position properties of each object to their initial values
// thus, there is no need ot dispose of the listeners below
this.object1.radiusProperty.link( function( radius ) {
Expand Down
1 change: 1 addition & 0 deletions js/model/ISLCObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ define( function( require ) {
// @public - flag to check whether object's radius was updated, used to determine positioning
this.radiusLastChanged = false;

// @public
this.valueRange = valueRange;
}

Expand Down
3 changes: 2 additions & 1 deletion js/view/ISLCForceArrowNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ define( function( require ) {
this.scientificNotationMode = options.defaultScientificNotationMode;
this.attractNegative = options.attractNegative;

// get a new higher min
// @private - get a new higher min
this.augmentedMin = ( ( arrowForceRange.max - arrowForceRange.min ) * 0.00003 ) + arrowForceRange.min;

// @private - maps the force value to the desired width of the arrow in view coordinates
this.forceToArrowWidthFunction = new LinearFunction( this.augmentedMin, arrowForceRange.max, 1.5, options.maxArrowWidth * 2, false );

Expand Down
4 changes: 2 additions & 2 deletions js/view/ISLCLegendNode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2017, University of Colorado Boulder

/**
* A legend graphic consisting of a double-ended arrow, two endpoint lines, and a label string.
* A legend graphic consisting of a double-ended arrow, two endpoint lines, and a label string. Intended to visually indicate a distance scale.
*
* @author Michael Barlow
*/
Expand All @@ -16,7 +16,7 @@ define( function( require ) {
var Text = require( 'SCENERY/nodes/Text' );

/**
* A graphic to visually indicate a distance scale.
* @constructor
* @param {ISLModel} model
* @param {ModelViewTransform2} modelViewTransform
* @param {int/float} width (in view coordinates)
Expand Down
4 changes: 3 additions & 1 deletion js/view/ISLCObjectControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ define( function( require ) {

// constants
var THUMB_SIZE = new Dimension2( 22, 42 );
var TITLE_MAX_WIDTH = 120;
var TITLE_MAX_WIDTH = 120; // max widths are set empirically to handle long strings
var VALUE_MAX_WIDTH = 120;

/**
* @param {string} titleString
* @param {string} unitString
* @param {Property.<number>} objectProperty
* @param {Range} valueRange
* @param {Tandem} tandem
* @param {Object} options
* @constructor
*/
function ISLCObjectControl( titleString, unitString, objectProperty, valueRange, tandem, options ) {
Expand Down
10 changes: 6 additions & 4 deletions js/view/ISLCPullerNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ define( function( require ) {
var PUSH_IMAGE_SCALE = 0.45;
var PULL_IMAGE_SCALE = 0.1125;

// for all images, the appended number corresponds to their 'level of effort', e.g. pullImage1 shows less pull than pullImage22
// this is important for mapping force values to the index of the corresponding pull effort
var pullImages = [ pullImage0, pullImage1, pullImage2, pullImage3, pullImage4, pullImage5, pullImage6, pullImage7,
pullImage8, pullImage9, pullImage10, pullImage11, pullImage12, pullImage13, pullImage14, pullImage15, pullImage16,
pullImage17, pullImage18, pullImage19, pullImage20, pullImage21, pullImage22, pullImage23, pullImage24, pullImage25,
Expand All @@ -115,7 +117,7 @@ define( function( require ) {
*/
function ISLCPullerNode( forceRange, tandem, options ) {

// REVIEW: This node doesn't pass options to Node, cannot
// REVIEW: This node doesn't pass options to Node
options = _.extend( {
ropeLength: 50,
shadowMinWidth: 32,
Expand All @@ -127,13 +129,12 @@ define( function( require ) {

Node.call( this );

// create property to hold puller/pusher images
// prevents extended chaining of
// @private
this.pullerPusherImages = pullImages;

// @private - if in coulomb's law sim, add pusher and zero force images in proper order
this.zeroForceIndex = null;

// if in coulomb's law sim, add pusher and zero force images in proper order
if (options.attractNegative) {
this.pullerPusherImages = pushImages.concat( zeroForceImage ).concat( pullImages );
this.zeroForceIndex = 31;
Expand All @@ -157,6 +158,7 @@ define( function( require ) {
tandem: tandem.createTandem( 'shadowNode' )
} );

// create the puller/pusher image nodes
var images = [];
var i;
for ( i = 0; i < this.pullerPusherImages.length; i++ ) {
Expand Down
2 changes: 1 addition & 1 deletion js/view/ISLCRulerNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ define( function( require ) {
);
this.addChild( ruler );

// ruler node is never destroyed, no listener disposal necessary
// @public - ruler node is never destroyed, no listener disposal necessary
model.rulerPositionProperty.link( function( value ) {
ruler.center = modelViewTransform.modelToViewPosition( value );
} );
Expand Down
2 changes: 1 addition & 1 deletion js/view/ISLCheckboxPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ define( function( require ) {
var TEXT_MAX_WIDTH = 100;

/**
* @constructor
* @param {items} list of item objects to attach
* @param {Tandem} tandem
* @param {Object} [options]
* @constructor
*/
function ISLCheckboxPanel( items, tandem, options ) {

Expand Down

0 comments on commit 4dbe55c

Please sign in to comment.