Skip to content

Commit

Permalink
Added TSoluteParticle, see #213
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Nov 9, 2017
1 parent 0d0b0d9 commit ea38704
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 17 deletions.
25 changes: 8 additions & 17 deletions js/concentration/model/TPrecipitateParticle.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,34 @@ 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 TVector2 = require( 'DOT/TVector2' );
var TSoluteParticle = require( 'BEERS_LAW_LAB/concentration/model/TSoluteParticle' );

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

phetioInherit( TObject, 'TPrecipitateParticle', TPrecipitateParticle, {}, {
phetioInherit( TSoluteParticle, 'TPrecipitateParticle', TPrecipitateParticle, {}, {

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

toStateObject: function( value ) {
return {
solute: TSolute.toStateObject( value.solute ),
location: TVector2.toStateObject( value.locationProperty.get() ),
orientation: TNumber.toStateObject( value.orientation )
};
var soluteParticle = TSoluteParticle.toStateObject( value );
return _.extend( soluteParticle, { solute: TSolute.toStateObject( value.solute ) } );
},
documentation: 'A particle that shows at the bottom of a saturated solution.'
} );

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

return TPrecipitateParticle;
} );
Expand Down
51 changes: 51 additions & 0 deletions js/concentration/model/TSoluteParticle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2017, University of Colorado Boulder

/**
*
* @author Sam Reid (PhET Interactive Simulations)
* @author Andrew Adare (PhET Interactive Simulations)
*/
define( function( require ) {
'use strict';

// modules
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 TVector2 = require( 'DOT/TVector2' );

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

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

fromStateObject: function( stateObject ) {
return {
location: TVector2.fromStateObject( stateObject.location ),
orientation: TNumber.fromStateObject( stateObject.orientation )
};
},

toStateObject: function( value ) {
return {
location: TVector2.toStateObject( value.locationProperty.get() ),
orientation: TNumber.toStateObject( value.orientation )
};
},
documentation: 'A particle that shows at the bottom of a saturated solution.'
} );

beersLawLab.register( 'TSoluteParticle', TSoluteParticle );

return TSoluteParticle;
} );

0 comments on commit ea38704

Please sign in to comment.