-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Convert ElectricPotentialLineIO to use PhetioObject.createIOT…
…ype, see phetsims/tandem#188" This reverts commit 27fded7
- Loading branch information
Showing
3 changed files
with
49 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2017-2020, University of Colorado Boulder | ||
|
||
/** | ||
* IO type for ElectricPotentialLine | ||
* | ||
* @author Sam Reid (PhET Interactive Simulations) | ||
*/ | ||
|
||
import validate from '../../../../axon/js/validate.js'; | ||
import Vector2IO from '../../../../dot/js/Vector2IO.js'; | ||
import ObjectIO from '../../../../tandem/js/types/ObjectIO.js'; | ||
import chargesAndFields from '../../chargesAndFields.js'; | ||
import ModelElement from './ModelElement.js'; | ||
|
||
class ElectricPotentialLineIO extends ModelElement.ModelElementIO { | ||
|
||
/** | ||
* @public | ||
* @param {ElectricPotentialLine} electricPotentialLine | ||
* @returns {Object} | ||
* @override | ||
*/ | ||
static toStateObject( electricPotentialLine ) { | ||
validate( electricPotentialLine, this.validator ); | ||
return { position: Vector2IO.toStateObject( electricPotentialLine.position ) }; | ||
} | ||
|
||
/** | ||
* @public | ||
* @override | ||
* @param {Object} stateObject | ||
* @returns {Array.<*>} | ||
*/ | ||
static stateToArgsForConstructor( stateObject ) { | ||
return [ Vector2IO.fromStateObject( stateObject.position ) ]; | ||
} | ||
} | ||
|
||
ElectricPotentialLineIO.documentation = 'The vector that shows the charge strength and direction.'; | ||
ElectricPotentialLineIO.validator = { isValidValue: v => v instanceof phet.chargesAndFields.ElectricPotentialLine }; | ||
ElectricPotentialLineIO.typeName = 'ElectricPotentialLineIO'; | ||
ObjectIO.validateSubtype( ElectricPotentialLineIO ); | ||
|
||
chargesAndFields.register( 'ElectricPotentialLineIO', ElectricPotentialLineIO ); | ||
export default ElectricPotentialLineIO; |