Skip to content

Commit

Permalink
Use TSoluteParticle in TShakerParticle, see #213
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Nov 9, 2017
1 parent ea38704 commit 3c23623
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
39 changes: 18 additions & 21 deletions js/concentration/model/TShakerParticle.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,43 @@ define( function( require ) {
var assertInstanceOf = require( 'ifphetio!PHET_IO/assertInstanceOf' );
var beersLawLab = require( 'BEERS_LAW_LAB/beersLawLab' );
var phetioInherit = require( 'ifphetio!PHET_IO/phetioInherit' );
var TNumber = require( 'ifphetio!PHET_IO/types/TNumber' );
var TObject = require( 'ifphetio!PHET_IO/types/TObject' );
var TSolute = require( 'BEERS_LAW_LAB/concentration/model/TSolute' );
var TSoluteParticle = require( 'BEERS_LAW_LAB/concentration/model/TSoluteParticle' );
var TVector2 = require( 'DOT/TVector2' );

/**
* @param instance
* @param phetioID
* @param {ShakerParticle} shakerParticle
* @param {string} phetioID
* @constructor
*/
function TShakerParticle( instance, phetioID ) {
assert && assertInstanceOf( instance, phet.beersLawLab.ShakerParticle );
TObject.call( this, instance, phetioID );
function TShakerParticle( shakerParticle, phetioID ) {
assert && assertInstanceOf( shakerParticle, phet.beersLawLab.ShakerParticle );
TSoluteParticle.call( this, shakerParticle, phetioID );
}

phetioInherit( TObject, 'TShakerParticle', TShakerParticle, {}, {
phetioInherit( TSoluteParticle, 'TShakerParticle', TShakerParticle, {}, {
documentation: 'A particle that comes from the shaker.',

fromStateObject: function( stateObject ) {
return {
var soluteParticle = TSoluteParticle.fromStateObject( stateObject );
return _.extend( soluteParticle, {
solute: TSolute.fromStateObject( stateObject.solute ),
location: TVector2.fromStateObject( stateObject.location ),
orientation: TNumber.fromStateObject( stateObject.orientation ),
velocity: TVector2.fromStateObject( stateObject.velocity ),
acceleration: TVector2.fromStateObject( stateObject.acceleration ),
};
} );
},

toStateObject: function( value ) {
return {
solute: TSolute.toStateObject( value.solute ),
location: TVector2.toStateObject( value.locationProperty.get() ),
orientation: TNumber.toStateObject( value.orientation ),
velocity: TVector2.toStateObject( value.velocity ),
acceleration: TVector2.toStateObject( value.acceleration )
};
toStateObject: function( shakerParticle ) {
var soluteParticle = TSoluteParticle.toStateObject( shakerParticle );
return _.extend( soluteParticle, {
solute: TSolute.toStateObject( shakerParticle.solute ),
velocity: TVector2.toStateObject( shakerParticle.velocity ),
acceleration: TVector2.toStateObject( shakerParticle.acceleration )
} );
}
} );

beersLawLab.register( 'TShakerParticle', TShakerParticle );
beersLawLab.register( 'TShakerParticle', TShakerParticle );

return TShakerParticle;
} );
Expand Down
11 changes: 5 additions & 6 deletions js/concentration/model/TSoluteParticle.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ define( function( require ) {
var TVector2 = require( 'DOT/TVector2' );

/**
*
* @param instance
* @param phetioID
* @param {SoluteParticle} soluteParticle
* @param {string} phetioID
* @constructor
*/
function TSoluteParticle( instance, phetioID ) {
assert && assertInstanceOf( instance, phet.beersLawLab.PrecipitateParticle );
TObject.call( this, instance, phetioID );
function TSoluteParticle( soluteParticle, phetioID ) {
assert && assertInstanceOf( soluteParticle, phet.beersLawLab.SoluteParticle );
TObject.call( this, soluteParticle, phetioID );
}

phetioInherit( TObject, 'TSoluteParticle', TSoluteParticle, {}, {
Expand Down

0 comments on commit 3c23623

Please sign in to comment.