Skip to content

Commit

Permalink
Made TNumber nonparametric and moved range/units to NumberProperty, see
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Sep 11, 2017
1 parent 10d459d commit 65e1bcf
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 98 deletions.
15 changes: 7 additions & 8 deletions js/motion/model/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
define( function( require ) {
'use strict';

var NumberProperty = require( 'AXON/NumberProperty' );
var Property = require( 'AXON/Property' );
var Range = require( 'DOT/Range' );
var TVector2 = require( 'DOT/TVector2' );
var Util = require( 'DOT/Util' );
var Range = require( 'DOT/Range' );
var Vector2 = require( 'DOT/Vector2' );
var forcesAndMotionBasics = require( 'FORCES_AND_MOTION_BASICS/forcesAndMotionBasics' );
var inherit = require( 'PHET_CORE/inherit' );

// phet-io modules
var TItem = require( 'FORCES_AND_MOTION_BASICS/motion/model/TItem' );
var TAnimationState = require( 'FORCES_AND_MOTION_BASICS/motion/model/TAnimationState' );
var TItem = require( 'FORCES_AND_MOTION_BASICS/motion/model/TItem' );
var TBoolean = require( 'ifphetio!PHET_IO/types/TBoolean' );
var TNumber = require( 'ifphetio!PHET_IO/types/TNumber' );
var TString = require( 'ifphetio!PHET_IO/types/TString' );

/**
Expand Down Expand Up @@ -97,16 +97,15 @@ define( function( require ) {
} );

// How much to increase/shrink the original image. Could all be set to 1.0 if images pre-scaled in an external program
this.imageScaleProperty = new Property( imageScale || 1.0, {
tandem: tandem.createTandem( 'imageScaleProperty' ),
phetioValueType: TNumber()
this.imageScaleProperty = new NumberProperty( imageScale || 1.0, {
tandem: tandem.createTandem( 'imageScaleProperty' )
} );

// How much the object grows or shrinks when interacting with it
var minValue = homeScale || 1.0;
this.interactionScaleProperty = new Property( homeScale || 1.0, {
this.interactionScaleProperty = new NumberProperty( homeScale || 1.0, {
tandem: tandem.createTandem( 'interactionScaleProperty' ),
phetioValueType: TNumber( { range: new Range( minValue, 1.3 ) } )
range: new Range( minValue, 1.3 )
} );

this.context.directionProperty.link( function( direction ) {
Expand Down
87 changes: 43 additions & 44 deletions js/motion/model/MotionModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,34 @@
define( function( require ) {
'use strict';

var Item = require( 'FORCES_AND_MOTION_BASICS/motion/model/Item' );
var Property = require( 'AXON/Property' );
var DerivedProperty = require( 'AXON/DerivedProperty' );
var Emitter = require( 'AXON/Emitter' );
var NumberProperty = require( 'AXON/NumberProperty' );
var ObservableArray = require( 'AXON/ObservableArray' );
var inherit = require( 'PHET_CORE/inherit' );
var MotionConstants = require( 'FORCES_AND_MOTION_BASICS/motion/MotionConstants' );
var Vector2 = require( 'DOT/Vector2' );
var Property = require( 'AXON/Property' );
var Range = require( 'DOT/Range' );
var Util = require( 'DOT/Util' );
var waterBucketImage = require( 'image!FORCES_AND_MOTION_BASICS/water-bucket.png' );
var fridgeImage = require( 'image!FORCES_AND_MOTION_BASICS/fridge.png' );
var Vector2 = require( 'DOT/Vector2' );
var forcesAndMotionBasics = require( 'FORCES_AND_MOTION_BASICS/forcesAndMotionBasics' );
var Item = require( 'FORCES_AND_MOTION_BASICS/motion/model/Item' );
var MotionConstants = require( 'FORCES_AND_MOTION_BASICS/motion/MotionConstants' );
var crateImage = require( 'image!FORCES_AND_MOTION_BASICS/crate.png' );
var girlStandingImage = require( 'mipmap!FORCES_AND_MOTION_BASICS/girl-standing.png' );
var manStandingImage = require( 'mipmap!FORCES_AND_MOTION_BASICS/man-standing.png' );
var girlSittingImage = require( 'mipmap!FORCES_AND_MOTION_BASICS/girl-sitting.png' );
var manSittingImage = require( 'mipmap!FORCES_AND_MOTION_BASICS/man-sitting.png' );
var fridgeImage = require( 'image!FORCES_AND_MOTION_BASICS/fridge.png' );
var mysteryObjectImage = require( 'image!FORCES_AND_MOTION_BASICS/mystery-object-01.png' );
var waterBucketImage = require( 'image!FORCES_AND_MOTION_BASICS/water-bucket.png' );
var girlHoldingImage = require( 'mipmap!FORCES_AND_MOTION_BASICS/girl-holding.png,level=1' );
var girlSittingImage = require( 'mipmap!FORCES_AND_MOTION_BASICS/girl-sitting.png' );
var girlStandingImage = require( 'mipmap!FORCES_AND_MOTION_BASICS/girl-standing.png' );
var manHoldingImage = require( 'mipmap!FORCES_AND_MOTION_BASICS/man-holding.png' );
var manSittingImage = require( 'mipmap!FORCES_AND_MOTION_BASICS/man-sitting.png' );
var manStandingImage = require( 'mipmap!FORCES_AND_MOTION_BASICS/man-standing.png' );
var trashCanImage = require( 'mipmap!FORCES_AND_MOTION_BASICS/trash-can.png' );
var mysteryObjectImage = require( 'image!FORCES_AND_MOTION_BASICS/mystery-object-01.png' );
var forcesAndMotionBasics = require( 'FORCES_AND_MOTION_BASICS/forcesAndMotionBasics' );
var Range = require( 'DOT/Range' );
var Emitter = require( 'AXON/Emitter' );
var DerivedProperty = require( 'AXON/DerivedProperty' );
var inherit = require( 'PHET_CORE/inherit' );

// phet-io modules
var TItem = require( 'FORCES_AND_MOTION_BASICS/motion/model/TItem' );
var TBoolean = require( 'ifphetio!PHET_IO/types/TBoolean' );
var TString = require( 'ifphetio!PHET_IO/types/TString' );
var TNumber = require( 'ifphetio!PHET_IO/types/TNumber' );
var TItem = require( 'FORCES_AND_MOTION_BASICS/motion/model/TItem' );

/**
* Constructor for the motion model
Expand Down Expand Up @@ -64,57 +64,57 @@ define( function( require ) {
} );

// @public - force applied to the stack of items by the pusher
this.appliedForceProperty = new Property( 0, {
this.appliedForceProperty = new NumberProperty( 0, {
tandem: tandem.createTandem( 'appliedForceProperty' ),
phetioValueType: TNumber( { units: 'newtons', range: new Range( -500, 500 ) } )
units: 'newtons',
range: new Range( -500, 500 )
} );

// @public - force applied to the stack of items by friction
this.frictionForceProperty = new Property( 0, {
this.frictionForceProperty = new NumberProperty( 0, {
tandem: tandem.createTandem( 'frictionForceProperty' ),
phetioValueType: TNumber( { units: 'newtons' } )
units: 'newtons'
} );

// @public - friction of the ground
this.frictionProperty = new Property( frictionValue, {
tandem: tandem.createTandem( 'frictionProperty' ),
phetioValueType: TNumber()
this.frictionProperty = new NumberProperty( frictionValue, {
tandem: tandem.createTandem( 'frictionProperty' )
} );

// @public - sum of all forces acting on the stack of items
this.sumOfForcesProperty = new Property( 0, {
this.sumOfForcesProperty = new NumberProperty( 0, {
tandem: tandem.createTandem( 'sumOfForcesProperty' ),
phetioValueType: TNumber( { units: 'newtons' } )
units: 'newtons'
} );

// @public - 1-D position of the stack of items
this.positionProperty = new Property( 0, {
this.positionProperty = new NumberProperty( 0, {
tandem: tandem.createTandem( 'positionProperty' ),
phetioValueType: TNumber( { units: 'meters' } )
units: 'meters'
} );

// @public - speed of the stack of items, in the x direction
this.speedProperty = new Property( 0, {
this.speedProperty = new NumberProperty( 0, {
tandem: tandem.createTandem( 'speedProperty' ),
phetioValueType: TNumber( { units: 'meters/second' } )
units: 'meters/second'
} );

// @public - elocity is a 1-d vector, where the direction (right or left) is indicated by the sign
this.velocityProperty = new Property( 0, {
this.velocityProperty = new NumberProperty( 0, {
tandem: tandem.createTandem( 'velocityProperty' ),
phetioValueType: TNumber( { units: 'meters/second' } )
units: 'meters/second'
} );

// @public - 1-d acceleration of the stack of items
this.accelerationProperty = new Property( 0, {
this.accelerationProperty = new NumberProperty( 0, {
tandem: tandem.createTandem( 'accelerationProperty' ),
phetioValueType: TNumber( { units: 'meters/second/second' } )
units: 'meters/second/second'
} );

// @public {number} - initially to the left of the box by this many meters
this.pusherPositionProperty = new Property( -16, {
this.pusherPositionProperty = new NumberProperty( -16, {
tandem: tandem.createTandem( 'pusherPositionProperty' ),
phetioValueType: TNumber( { units: 'meters' } )
units: 'meters'
} );

// @public {boolean} - whether or not forces are visible
Expand Down Expand Up @@ -182,8 +182,8 @@ define( function( require ) {
// @public {number} - time since pusher has fallen over, in seconds
// TODO: Should we this have a tandem? It spams the data stream.
// TODO: Why is default value 10?
this.timeSinceFallenProperty = new Property( 10, {
phetioValueType: TNumber( { units: 'seconds' } )
this.timeSinceFallenProperty = new NumberProperty( 10, {
units: 'seconds'
} );

// @public {boolean} - whether or not the pusher has fallen over
Expand All @@ -200,15 +200,14 @@ define( function( require ) {

// @public {number} - how long the simulation has been running
// TODO: Should we this have a tandem? It spams the data stream.
this.timeProperty = new Property( 0, {
phetioValueType: TNumber( { units: 'seconds' } )
this.timeProperty = new NumberProperty( 0, {
units: 'seconds'
} );

//stack.length is already a property, but mirror it here to easily multilink with it, see usage in MotionScreenView.js
//TODO: Perhaps a DerivedProperty would be more suitable instead of duplicating/synchronizing this value
this.stackSizeProperty = new Property( 1, {
tandem: tandem.createTandem( 'stackSizeProperty' ),
phetioValueType: TNumber()
this.stackSizeProperty = new NumberProperty( 1, {
tandem: tandem.createTandem( 'stackSizeProperty' )
} );

// @public {boolean} - is the sim running or paused?
Expand Down
8 changes: 3 additions & 5 deletions js/motion/view/MotionScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ define( function( require ) {
var AccelerometerNode = require( 'FORCES_AND_MOTION_BASICS/motion/view/AccelerometerNode' );
var Property = require( 'AXON/Property' );
var DerivedProperty = require( 'AXON/DerivedProperty' );
var NumberProperty = require( 'AXON/NumberProperty' );
var ArrowButton = require( 'SUN/buttons/ArrowButton' );
var Util = require( 'DOT/Util' );
var ItemToolboxNode = require( 'FORCES_AND_MOTION_BASICS/motion/view/ItemToolboxNode' );
Expand All @@ -44,9 +45,6 @@ define( function( require ) {
var Line = require( 'SCENERY/nodes/Line' );
var ForcesAndMotionBasicsQueryParameters = require( 'FORCES_AND_MOTION_BASICS/common/ForcesAndMotionBasicsQueryParameters' );

// phet-io modules
var TNumber = require( 'ifphetio!PHET_IO/types/TNumber' );

// constants
var DEBUG = false; // adds a line at the bottom of the items to assist with layout
var PLAY_PAUSE_BUFFER = 10; // separation between step and reset all button, usedful for i18n
Expand Down Expand Up @@ -509,9 +507,9 @@ define( function( require ) {
} );

//Only update the sum force arrow after both friction and applied force changed, so we don't get partial updates, see https://github.com/phetsims/forces-and-motion-basics/issues/83
var roundedSumProperty = new Property( roundedAppliedForceProperty.get() + roundedFrictionForceProperty.get(), {
var roundedSumProperty = new NumberProperty( roundedAppliedForceProperty.get() + roundedFrictionForceProperty.get(), {
tandem: tandem.createTandem( 'roundedSumProperty' ),
phetioValueType: TNumber( { units: 'newtons' } )
units: 'newtons'
} );

model.stepEmitter.addListener( function() {
Expand Down
20 changes: 9 additions & 11 deletions js/netforce/model/Cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
define( function( require ) {
'use strict';

var Property = require( 'AXON/Property' );
var inherit = require( 'PHET_CORE/inherit' );
var forcesAndMotionBasics = require( 'FORCES_AND_MOTION_BASICS/forcesAndMotionBasics' );
var NumberProperty = require( 'AXON/NumberProperty' );
var Range = require( 'DOT/Range' );

// phet-io modules
var TNumber = require( 'ifphetio!PHET_IO/types/TNumber' );
var forcesAndMotionBasics = require( 'FORCES_AND_MOTION_BASICS/forcesAndMotionBasics' );
var inherit = require( 'PHET_CORE/inherit' );

/**
* @param {Tandem} tandem
Expand All @@ -23,16 +20,17 @@ define( function( require ) {
function Cart( tandem ) {

// @public {number} - 1-D x location of the cart
this.xProperty = new Property( 0, {
this.xProperty = new NumberProperty( 0, {
tandem: tandem.createTandem( 'xProperty' ),
phetioValueType: TNumber( { units: 'meters', range: new Range( -403, 403 ) } )
units: 'meters',
range: new Range( -403, 403 )
} );


// @public {number} - 1-D velocity in MKS
this.vProperty = new Property( 0, {
this.vProperty = new NumberProperty( 0, {
tandem: tandem.createTandem( 'vProperty' ),
phetioValueType: TNumber( { units: 'meters/second', range: new Range( -6, 6 ) } )
units: 'meters/second',
range: new Range( -6, 6 )
} );

// @public (read-only) - width from the center of the cart to the wheels, used to determine when a wheel touches
Expand Down
13 changes: 7 additions & 6 deletions js/netforce/model/Knot.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
define( function( require ) {
'use strict';

var NumberProperty = require( 'AXON/NumberProperty' );
var Property = require( 'AXON/Property' );
var inherit = require( 'PHET_CORE/inherit' );
var Vector2 = require( 'DOT/Vector2' );
var Range = require( 'DOT/Range' );
var forcesAndMotionBasics = require( 'FORCES_AND_MOTION_BASICS/forcesAndMotionBasics' );
var inherit = require( 'PHET_CORE/inherit' );

// phet-io modules
var TNumber = require( 'ifphetio!PHET_IO/types/TNumber' );
var TBoolean = require( 'ifphetio!PHET_IO/types/TBoolean' );
var TKnot = require( 'FORCES_AND_MOTION_BASICS/netforce/model/TKnot' );
var TBoolean = require( 'ifphetio!PHET_IO/types/TBoolean' );

/**
* Constructor for the 8 knots that appear along the rope.
*
* @param {number} x the horizontal position (in meters) of the knot
* // TODO: Fix JSDoc
* @param {string} type whether the knot is for red or blue pullers
* @param {number} ropeLength - the length of the rope in model coordinates
* @param {Tandem} tandem
Expand All @@ -34,9 +34,10 @@ define( function( require ) {
this.type = type;

// @public {number} - the 1-D x location of the knot
this.xProperty = new Property( x, {
this.xProperty = new NumberProperty( x, {
tandem: tandem.createTandem( 'xProperty' ),
phetioValueType: TNumber( { units: 'meters', range: new Range( ropeStart, ropeLength + ropeStart ) } )
units: 'meters'
// TODO: Fix range, was buggy during https://github.com/phetsims/axon/issues/137 and hence removed
} );

// @public {boolean} - whether or not the know is visible
Expand Down
Loading

0 comments on commit 65e1bcf

Please sign in to comment.