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 918953e commit cd4fdbb
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 42 deletions.
2 changes: 1 addition & 1 deletion js/AtomIdentifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ define( function( require ) {
},

getNumNeutronsInMostCommonIsotope: function( atomicNumber ) {
return numNeutronsInMostStableIsotope[ atomicNumber ];
return numNeutronsInMostStableIsotope[ atomicNumber ] || 0;
},

getStandardAtomicMass: function( numProtons ) {
Expand Down
27 changes: 15 additions & 12 deletions js/model/NumberAtom.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ define( function( require ) {
'use strict';

// modules
var AtomIdentifier = require( 'SHRED/AtomIdentifier' );
var DerivedProperty = require( 'AXON/DerivedProperty' );
var Emitter = require( 'AXON/Emitter' );
var NumberProperty = require( 'AXON/NumberProperty' );
var inherit = require( 'PHET_CORE/inherit' );
var Property = require( 'AXON/Property' );
var AtomIdentifier = require( 'SHRED/AtomIdentifier' );
var shred = require( 'SHRED/shred' );
var Tandem = require( 'TANDEM/Tandem' );

Expand All @@ -36,19 +36,19 @@ define( function( require ) {
}, options );

// @public
this.protonCountProperty = new Property( options.protonCount, {
this.protonCountProperty = new NumberProperty( options.protonCount, {
tandem: options.tandem.createTandem( 'protonCountProperty' ),
phetioValueType: TNumber( { type: 'Integer' } ),
documentation: 'this property is updated by the model and should not be set by users'
documentation: 'this property is updated by the model and should not be set by users',
valueType: 'Integer'
} );
this.neutronCountProperty = new Property( options.neutronCount, {
this.neutronCountProperty = new NumberProperty( options.neutronCount, {
tandem: options.tandem.createTandem( 'neutronCountProperty' ),
phetioValueType: TNumber( { type: 'Integer' } ),
valueType: 'Integer',
documentation: 'this property is updated by the model and should not be set by users'
} );
this.electronCountProperty = new Property( options.electronCount, {
this.electronCountProperty = new NumberProperty( options.electronCount, {
tandem: options.tandem.createTandem( 'electronCountProperty' ),
phetioValueType: TNumber( { type: 'Integer' } ),
valueType: 'Integer',
documentation: 'this property is updated by the model and should not be set by users'
} );

Expand All @@ -57,7 +57,8 @@ define( function( require ) {
return protonCount - electronCount;
}, {
tandem: options.tandem.createTandem( 'chargeProperty' ),
phetioValueType: TNumber( { type: 'Integer' } )
valueType: 'Integer',
phetioValueType: TNumber
}
);

Expand All @@ -66,7 +67,8 @@ define( function( require ) {
return protonCount + neutronCount;
}, {
tandem: options.tandem.createTandem( 'massNumberProperty' ),
phetioValueType: TNumber( { type: 'Integer' } )
valueType: 'Integer',
phetioValueType: TNumber
}
);

Expand All @@ -75,7 +77,8 @@ define( function( require ) {
return protonCount + neutronCount + electronCount;
}, {
tandem: options.tandem.createTandem( 'particleCountProperty' ),
phetioValueType: TNumber( { type: 'Integer' } )
valueType: 'Integer',
phetioValueType: TNumber
}
);

Expand Down
39 changes: 16 additions & 23 deletions js/model/Particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ define( function( require ) {
'use strict';

// modules
var inherit = require( 'PHET_CORE/inherit' );
var NumberProperty = require( 'AXON/NumberProperty' );
var Property = require( 'AXON/Property' );
var Range = require( 'DOT/Range' );
var ShredConstants = require( 'SHRED/ShredConstants' );
var shred = require( 'SHRED/shred' );
var Tandem = require( 'TANDEM/Tandem' );
var Vector2 = require( 'DOT/Vector2' );
var TVector2 = require( 'DOT/TVector2' );
var Vector2 = require( 'DOT/Vector2' );
var inherit = require( 'PHET_CORE/inherit' );
var TParticle = require( 'SHRED/model/TParticle' );
var shred = require( 'SHRED/shred' );
var ShredConstants = require( 'SHRED/ShredConstants' );
var Tandem = require( 'TANDEM/Tandem' );

// phet-io modules
var TBoolean = require( 'ifphetio!PHET_IO/types/TBoolean' );
Expand Down Expand Up @@ -52,21 +53,14 @@ define( function( require ) {
tandem: options.tandem && options.tandem.createTandem( 'destinationProperty' ),
phetioValueType: TVector2
} );
this.radiusProperty = new Property(
type === 'electron' ? ShredConstants.ELECTRON_RADIUS : ShredConstants.NUCLEON_RADIUS,
{
tandem: options.tandem && options.tandem.createTandem( 'radiusProperty' ),
phetioValueType: TNumber( { type: 'FloatingPoint' } ),
phetioInstanceDocumentation: 'changes to radius may not be reflected in view'
}
);
this.animationVelocityProperty = new Property( DEFAULT_PARTICLE_VELOCITY, {
this.radiusProperty = new NumberProperty( type === 'electron' ? ShredConstants.ELECTRON_RADIUS : ShredConstants.NUCLEON_RADIUS, {
tandem: options.tandem && options.tandem.createTandem( 'radiusProperty' ),
phetioInstanceDocumentation: 'changes to radius may not be reflected in view'
} );
this.animationVelocityProperty = new NumberProperty( DEFAULT_PARTICLE_VELOCITY, {
tandem: options.tandem && options.tandem.createTandem( 'animationVelocityProperty' ),
phetioValueType: TNumber( {
type: 'FloatingPoint',
range: new Range( 0, 10 * DEFAULT_PARTICLE_VELOCITY ), // limited for instance proxies, code can handle any value
units: 'view-coordinates/second'
} )
range: new Range( 0, 10 * DEFAULT_PARTICLE_VELOCITY ), // limited for instance proxies, code can handle any value
units: 'view-coordinates/second'
} );
this.userControlledProperty = new Property( false, {
tandem: options.tandem && options.tandem.createTandem( 'userControlledProperty' ),
Expand All @@ -77,10 +71,9 @@ define( function( require ) {
return value >= 0 && value <= options.maxZLayer;
},
tandem: options.tandem && options.tandem.createTandem( 'zLayerProperty' ),
phetioValueType: TNumber( {
type: 'Integer',
range: new Range( 0, options.maxZLayer )
} )
valueType: 'Integer',
range: new Range( 0, options.maxZLayer ),
phetioValueType: TNumber
} ); // Used in view, integer value, higher means further back.

options.tandem.addInstance( this, TParticle );
Expand Down
18 changes: 12 additions & 6 deletions js/model/ParticleAtom.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ define( function( require ) {
},
{
tandem: options.tandem.createTandem( 'protonCountProperty' ),
phetioValueType: TNumber( { type: 'Integer' } )
valueType: 'Integer',
phetioValueType: TNumber
}
);
this.neutronCountProperty = new DerivedProperty(
Expand All @@ -95,7 +96,8 @@ define( function( require ) {
},
{
tandem: options.tandem.createTandem( 'neutronCountProperty' ),
phetioValueType: TNumber( { type: 'Integer' } )
valueType: 'Integer',
phetioValueType: TNumber
}
);
this.electronCountProperty = new DerivedProperty(
Expand All @@ -105,7 +107,8 @@ define( function( require ) {
},
{
tandem: options.tandem.createTandem( 'electronCountProperty' ),
phetioValueType: TNumber( { type: 'Integer' } )
valueType: 'Integer',
phetioValueType: TNumber
}
);
this.chargeProperty = new DerivedProperty(
Expand All @@ -115,7 +118,8 @@ define( function( require ) {
},
{
tandem: options.tandem.createTandem( 'chargeProperty' ),
phetioValueType: TNumber( { type: 'Integer' } )
valueType: 'Integer',
phetioValueType: TNumber
}
);
this.massNumberProperty = new DerivedProperty(
Expand All @@ -125,7 +129,8 @@ define( function( require ) {
},
{
tandem: options.tandem.createTandem( 'massNumberProperty' ),
phetioValueType: TNumber( { type: 'Integer' } )
valueType: 'Integer',
phetioValueType: TNumber
}
);
this.particleCountProperty = new DerivedProperty(
Expand All @@ -135,7 +140,8 @@ define( function( require ) {
},
{
tandem: options.tandem.createTandem( 'particleCountProperty' ),
phetioValueType: TNumber( { type: 'Integer' } )
valueType: 'Integer',
phetioValueType: TNumber
}
);

Expand Down

0 comments on commit cd4fdbb

Please sign in to comment.