From 679fe3b73c5085091416d49a7dbcf89cc3264517 Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Mon, 1 Nov 2021 16:11:25 -0600 Subject: [PATCH] Improve options, see https://github.com/phetsims/chipper/issues/1128 --- js/model/ACVoltage.ts | 12 +++++----- js/model/Battery.ts | 7 +++--- js/model/Capacitor.ts | 12 +++++----- js/model/Circuit.ts | 9 +++---- js/model/CircuitConstructionKitModel.ts | 12 +++++----- js/model/CircuitElement.ts | 24 +++++++++---------- js/model/Dog.ts | 6 ++--- js/model/DynamicCircuitElement.ts | 6 ++--- js/model/FixedCircuitElement.ts | 12 +++++----- js/model/Fuse.ts | 12 +++++----- js/model/Inductor.ts | 12 +++++----- js/model/Resistor.ts | 16 ++++++------- js/model/SeriesAmmeter.ts | 6 ++--- js/model/Switch.ts | 6 ++--- js/model/Vertex.ts | 28 +++++++++++----------- js/model/VoltageSource.ts | 15 ++++++------ js/model/Wire.ts | 12 +++++----- js/view/ACVoltageNode.ts | 8 +++---- js/view/AdvancedAccordionBox.ts | 14 ++++++----- js/view/AmmeterNode.ts | 32 ++++++++++++------------- js/view/BarkNode.ts | 6 ++--- js/view/BatteryNode.ts | 8 +++---- js/view/CCKCAccordionBox.ts | 10 ++++---- js/view/CCKCChartNode.ts | 18 +++++++------- js/view/CCKCCheckbox.ts | 8 +++---- js/view/CCKCLightBulbNode.ts | 6 ++--- js/view/CCKCPanel.ts | 10 ++++---- js/view/CCKCProbeNode.ts | 16 ++++++------- js/view/CapacitorCircuitElementNode.ts | 12 +++++----- 29 files changed, 180 insertions(+), 175 deletions(-) diff --git a/js/model/ACVoltage.ts b/js/model/ACVoltage.ts index 8f4e7600..a0823de3 100644 --- a/js/model/ACVoltage.ts +++ b/js/model/ACVoltage.ts @@ -37,11 +37,11 @@ class ACVoltage extends VoltageSource { * @param {Vertex} endVertex - the other battery vertex * @param {Property.} internalResistanceProperty - the resistance of the battery * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( startVertex: Vertex, endVertex: Vertex, internalResistanceProperty: Property, tandem: Tandem, options?: Partial ) { + constructor( startVertex: Vertex, endVertex: Vertex, internalResistanceProperty: Property, tandem: Tandem, providedOptions?: Partial ) { assert && assert( internalResistanceProperty, 'internalResistanceProperty should be defined' ); - const filledOptions = merge( { + const options = merge( { initialOrientation: 'right', voltage: 9.0, isFlammable: true, @@ -49,11 +49,11 @@ class ACVoltage extends VoltageSource { voltagePropertyOptions: { range: new Range( -MAX_VOLTAGE, MAX_VOLTAGE ) } - }, options ) as ACVoltageOptions; - super( startVertex, endVertex, internalResistanceProperty, CCKCConstants.BATTERY_LENGTH, tandem, filledOptions ); + }, providedOptions ) as ACVoltageOptions; + super( startVertex, endVertex, internalResistanceProperty, CCKCConstants.BATTERY_LENGTH, tandem, options ); // @public {NumberProperty} - the maximum voltage, which can be controlled by the CircuitElementNumberControl - this.maximumVoltageProperty = new NumberProperty( filledOptions.voltage, { + this.maximumVoltageProperty = new NumberProperty( options.voltage, { tandem: tandem.createTandem( 'maximumVoltageProperty' ), range: new Range( 0, MAX_VOLTAGE ) } ); diff --git a/js/model/Battery.ts b/js/model/Battery.ts index 5cbaafcc..bfed0a32 100644 --- a/js/model/Battery.ts +++ b/js/model/Battery.ts @@ -32,9 +32,10 @@ class Battery extends VoltageSource { * @param {Property.} internalResistanceProperty - the resistance of the battery * @param {BatteryType} batteryType * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( startVertex: Vertex, endVertex: Vertex, internalResistanceProperty: Property, batteryType: BatteryType, tandem: Tandem, options?: Partial ) { + constructor( startVertex: Vertex, endVertex: Vertex, internalResistanceProperty: Property, batteryType: BatteryType, + tandem: Tandem, providedOptions?: Partial ) { assert && assert( internalResistanceProperty, 'internalResistanceProperty should be defined' ); const filledOptions = merge( { initialOrientation: 'right', @@ -44,7 +45,7 @@ class Battery extends VoltageSource { voltagePropertyOptions: { range: batteryType === 'normal' ? new Range( 0, 120 ) : new Range( 100, 100000 ) } - }, options ) as BatteryOptions; + }, providedOptions ) as BatteryOptions; super( startVertex, endVertex, internalResistanceProperty, BATTERY_LENGTH, tandem, filledOptions ); // @public (read-only) {string} - track which way the battery "button" (plus side) was facing the initial state so diff --git a/js/model/Capacitor.ts b/js/model/Capacitor.ts index d7cb3c66..48b1f501 100644 --- a/js/model/Capacitor.ts +++ b/js/model/Capacitor.ts @@ -26,21 +26,21 @@ class Capacitor extends DynamicCircuitElement { * @param {Vertex} startVertex * @param {Vertex} endVertex * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( startVertex: Vertex, endVertex: Vertex, tandem: Tandem, options?: Partial ) { - const filledOptions = merge( { + constructor( startVertex: Vertex, endVertex: Vertex, tandem: Tandem, providedOptions?: Partial ) { + const options = merge( { capacitance: CCKCConstants.DEFAULT_CAPACITANCE, // The number of decimal places is only used in the view, but we define it in the model as a convenient way to // associate the value with the component numberOfDecimalPlaces: 2 - }, options ) as CapacitorOptions; + }, providedOptions ) as CapacitorOptions; - super( startVertex, endVertex, CCKCConstants.CAPACITOR_LENGTH, tandem, filledOptions ); + super( startVertex, endVertex, CCKCConstants.CAPACITOR_LENGTH, tandem, options ); // @public {Property.} the capacitance in farads - this.capacitanceProperty = new NumberProperty( filledOptions.capacitance, { + this.capacitanceProperty = new NumberProperty( options.capacitance, { range: new Range( 0.05, 0.20 ), tandem: tandem.createTandem( 'capacitanceProperty' ) } ); diff --git a/js/model/Circuit.ts b/js/model/Circuit.ts index c4b7e72e..72f70c6e 100644 --- a/js/model/Circuit.ts +++ b/js/model/Circuit.ts @@ -100,18 +100,19 @@ class Circuit { * @param {Property.} viewTypeProperty * @param {Property.} addRealBulbsProperty * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( viewTypeProperty: Property, addRealBulbsProperty: Property, tandem: Tandem, options?: Partial ) { + constructor( viewTypeProperty: Property, addRealBulbsProperty: Property, tandem: Tandem, + providedOptions?: Partial ) { // @public this.viewTypeProperty = viewTypeProperty; this.addRealBulbsProperty = addRealBulbsProperty; - const filledOptions = merge( { blackBoxStudy: false }, options ) as CircuitOptions; + const options = merge( { blackBoxStudy: false }, providedOptions ) as CircuitOptions; // @public {Object} - this.blackBoxStudy = filledOptions.blackBoxStudy; + this.blackBoxStudy = options.blackBoxStudy; // @public {NumberProperty} - All wires share the same resistivity, which is defined by // resistance = resistivity * length. On the Lab Screen, there is a wire resistivity control diff --git a/js/model/CircuitConstructionKitModel.ts b/js/model/CircuitConstructionKitModel.ts index 841b0596..196f640d 100644 --- a/js/model/CircuitConstructionKitModel.ts +++ b/js/model/CircuitConstructionKitModel.ts @@ -55,17 +55,17 @@ class CircuitConstructionKitModel { /** * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( tandem: Tandem, options?: Partial ) { + constructor( tandem: Tandem, providedOptions?: Partial ) { - const filledOptions = merge( { + const options = merge( { // Determines whether electrons can be shown. In black box, electrons can only be shown when the user reveals // the answer by pressing the reveal answer button. revealing: true, blackBoxStudy: false - }, options ) as CircuitConstructionKitModelOptions; + }, providedOptions ) as CircuitConstructionKitModelOptions; // @private {ZoomAnimation|null} - animation for the zoom level or null if not animating this.zoomAnimation = null; @@ -83,7 +83,7 @@ class CircuitConstructionKitModel { } ); // @public (read-only) {Circuit} - contains CircuitElements, Vertices, etc. - this.circuit = new Circuit( this.viewTypeProperty, this.addRealBulbsProperty, tandem.createTandem( 'circuit' ), { blackBoxStudy: filledOptions.blackBoxStudy } ); + this.circuit = new Circuit( this.viewTypeProperty, this.addRealBulbsProperty, tandem.createTandem( 'circuit' ), { blackBoxStudy: options.blackBoxStudy } ); // @public (read-only) {Voltmeter[]} - created statically and indexed starting at 1 for human-readability for PhET-iO this.voltmeters = [ @@ -209,7 +209,7 @@ class CircuitConstructionKitModel { } ); // @public - true when the user is holding down the reveal button and the answer (inside the black box) is showing - this.revealingProperty = new BooleanProperty( filledOptions.revealing, { + this.revealingProperty = new BooleanProperty( options.revealing, { tandem: tandem.createTandem( 'revealingProperty' ) } ); diff --git a/js/model/CircuitElement.ts b/js/model/CircuitElement.ts index 8de3a442..7c9afbcd 100644 --- a/js/model/CircuitElement.ts +++ b/js/model/CircuitElement.ts @@ -72,14 +72,14 @@ abstract class CircuitElement extends PhetioObject { * @param {Vertex} endVertex * @param {number} chargePathLength * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( startVertex: Vertex, endVertex: Vertex, chargePathLength: number, tandem: Tandem, options?: Partial ) { + constructor( startVertex: Vertex, endVertex: Vertex, chargePathLength: number, tandem: Tandem, providedOptions?: Partial ) { assert && assert( startVertex !== endVertex, 'startVertex cannot be the same as endVertex' ); assert && assert( typeof chargePathLength === 'number', 'charge path length should be a number' ); assert && assert( chargePathLength > 0, 'charge path length must be positive' ); - const filledOptions = merge( { + const options = merge( { canBeDroppedInToolbox: true, // In the CCK: Basics intro screen, CircuitElements can't be dropped into the toolbox interactive: true, // In CCK: Black Box Study, CircuitElements in the black box cannot be manipulated isSizeChangedOnViewChange: true, @@ -90,9 +90,9 @@ abstract class CircuitElement extends PhetioObject { isCurrentReentrant: false, phetioDynamicElement: true, phetioType: CircuitElement.CircuitElementIO - }, options ) as CircuitElementOptions; + }, providedOptions ) as CircuitElementOptions; - super( filledOptions ); + super( options ); // @public (read-only) {number} unique identifier for looking up corresponding views this.id = index++; @@ -102,19 +102,19 @@ abstract class CircuitElement extends PhetioObject { this.creationTime = phet.joist.elapsedTime; // @public (read-only) {boolean} flammable circuit elements can catch on fire - this.isFlammable = filledOptions.isFlammable; + this.isFlammable = options.isFlammable; // @public (read-only) {boolean} metallic circuit elements behave like exposed wires--sensor values can be read // directly on the resistor. For instance, coins and paper clips and wires are metallic and can have their values // read directly. - this.isMetallic = filledOptions.isMetallic; + this.isMetallic = options.isMetallic; // @public (read-only) {boolean} - whether the size changes when changing from lifelike/schematic, used to determine // whether the highlight region should be changed. True for everything except the switch. - this.isSizeChangedOnViewChange = filledOptions.isSizeChangedOnViewChange; + this.isSizeChangedOnViewChange = options.isSizeChangedOnViewChange; // @public (read-only) {number} - whether it is possible to drop the CircuitElement in the toolbox - this.canBeDroppedInToolbox = filledOptions.canBeDroppedInToolbox; + this.canBeDroppedInToolbox = options.canBeDroppedInToolbox; // @public {Property.} - the Vertex at the origin of the CircuitElement, may change when CircuitElements are // connected @@ -126,7 +126,7 @@ abstract class CircuitElement extends PhetioObject { // @public {NumberProperty} - the flowing current, in amps. this.currentProperty = new NumberProperty( 0, { - reentrant: filledOptions.isCurrentReentrant + reentrant: options.isCurrentReentrant } ); this.currentProperty.link( ( current: number ) => { assert && assert( !isNaN( current ) ); @@ -137,11 +137,11 @@ abstract class CircuitElement extends PhetioObject { this.currentSenseProperty = new Property( 'unspecified' ); // @public (read-only) {BooleanProperty} - true if the CircuitElement can be edited and dragged - this.interactiveProperty = new BooleanProperty( filledOptions.interactive ); + this.interactiveProperty = new BooleanProperty( options.interactive ); // @public {BooleanProperty} - whether the circuit element is inside the true black box, not inside the user-created // black box, on the interface or outside of the black box - this.insideTrueBlackBoxProperty = new BooleanProperty( filledOptions.insideTrueBlackBox ); + this.insideTrueBlackBoxProperty = new BooleanProperty( options.insideTrueBlackBox ); // @public {boolean} - true if the charge layout must be updated (each element is visited every frame to check this) this.chargeLayoutDirty = true; diff --git a/js/model/Dog.ts b/js/model/Dog.ts index 3143ba34..e3a1b690 100644 --- a/js/model/Dog.ts +++ b/js/model/Dog.ts @@ -22,10 +22,10 @@ class Dog extends Resistor { * @param {Vertex} startVertex * @param {Vertex} endVertex * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( startVertex: Vertex, endVertex: Vertex, tandem: Tandem, options?: ResistorOptions ) { - super( startVertex, endVertex, Resistor.ResistorType.DOG, tandem, options ); + constructor( startVertex: Vertex, endVertex: Vertex, tandem: Tandem, providedOptions?: ResistorOptions ) { + super( startVertex, endVertex, Resistor.ResistorType.DOG, tandem, providedOptions ); // @private - keep track of whether the dog is barking, so we can update the view accordingly this.isBarkingProperty = new BooleanProperty( false ); diff --git a/js/model/DynamicCircuitElement.ts b/js/model/DynamicCircuitElement.ts index fbbd86b6..e794170c 100644 --- a/js/model/DynamicCircuitElement.ts +++ b/js/model/DynamicCircuitElement.ts @@ -26,11 +26,11 @@ abstract class DynamicCircuitElement extends FixedCircuitElement { * @param {Vertex} endVertex * @param {number} length * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( startVertex: Vertex, endVertex: Vertex, length: number, tandem: Tandem, options?: Partial ) { - super( startVertex, endVertex, length, tandem, options ); + constructor( startVertex: Vertex, endVertex: Vertex, length: number, tandem: Tandem, providedOptions?: Partial ) { + super( startVertex, endVertex, length, tandem, providedOptions ); // @public {number} - value of the voltage drop set and read by the modified nodal analysis. This is in addition // to the typical voltage calculation which is based on vertices. diff --git a/js/model/FixedCircuitElement.ts b/js/model/FixedCircuitElement.ts index 8e86c593..f89f81b9 100644 --- a/js/model/FixedCircuitElement.ts +++ b/js/model/FixedCircuitElement.ts @@ -28,19 +28,19 @@ abstract class FixedCircuitElement extends CircuitElement { * @param {Vertex} endVertex * @param {number} chargePathLength - the distance the charges travel (in view coordinates), see CircuitElement.js * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( startVertex: Vertex, endVertex: Vertex, chargePathLength: number, tandem: Tandem, options?: Partial ) { + constructor( startVertex: Vertex, endVertex: Vertex, chargePathLength: number, tandem: Tandem, providedOptions?: Partial ) { - const filledOptions = merge( { + const options = merge( { numberOfDecimalPlaces: 1 - }, options ) as FixedCircuitElementOptions; + }, providedOptions ) as FixedCircuitElementOptions; // Super constructor - super( startVertex, endVertex, chargePathLength, tandem, filledOptions ); + super( startVertex, endVertex, chargePathLength, tandem, options ); // @public (read-only) {number} - the number of decimal places to show in readouts and controls - this.numberOfDecimalPlaces = filledOptions.numberOfDecimalPlaces; + this.numberOfDecimalPlaces = options.numberOfDecimalPlaces; // @public (read-only) {number} The distance from one vertex to another (as the crow flies), used for rotation // about a vertex diff --git a/js/model/Fuse.ts b/js/model/Fuse.ts index 36f15ca3..c9ab7797 100644 --- a/js/model/Fuse.ts +++ b/js/model/Fuse.ts @@ -33,21 +33,21 @@ class Fuse extends FixedCircuitElement { * @param {Vertex} startVertex * @param {Vertex} endVertex * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( startVertex: Vertex, endVertex: Vertex, tandem: Tandem, options?: Partial ) { - const filledOptions = merge( { + constructor( startVertex: Vertex, endVertex: Vertex, tandem: Tandem, providedOptions?: Partial ) { + const options = merge( { resistance: CCKCConstants.MINIMUM_RESISTANCE, fuseLength: CCKCConstants.RESISTOR_LENGTH, // Same length as a resistor currentRating: 4, // Amps isCurrentReentrant: true, // Changing the current can trip a fuse, which changes the current numberOfDecimalPlaces: 1 - }, options ) as FuseOptions; + }, providedOptions ) as FuseOptions; - super( startVertex, endVertex, filledOptions.fuseLength, tandem, filledOptions ); + super( startVertex, endVertex, options.fuseLength, tandem, options ); // @public {Property.} the current at which the fuse trips, in amps - this.currentRatingProperty = new NumberProperty( filledOptions.currentRating, { + this.currentRatingProperty = new NumberProperty( options.currentRating, { range: new Range( 0.5, 20 ) } ); diff --git a/js/model/Inductor.ts b/js/model/Inductor.ts index 54685613..a6e6dc73 100644 --- a/js/model/Inductor.ts +++ b/js/model/Inductor.ts @@ -30,18 +30,18 @@ class Inductor extends DynamicCircuitElement { * @param {Vertex} startVertex * @param {Vertex} endVertex * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( startVertex: Vertex, endVertex: Vertex, tandem: Tandem, options?: Partial ) { - const filledOptions = merge( { + constructor( startVertex: Vertex, endVertex: Vertex, tandem: Tandem, providedOptions?: Partial ) { + const options = merge( { inductance: CCKCQueryParameters.inductanceDefault, numberOfDecimalPlaces: CCKCQueryParameters.inductorNumberDecimalPlaces - }, options ) as InductorOptions; + }, providedOptions ) as InductorOptions; - super( startVertex, endVertex, INDUCTOR_LENGTH, tandem, filledOptions ); + super( startVertex, endVertex, INDUCTOR_LENGTH, tandem, options ); // @public {Property.} the inductance in Henries - this.inductanceProperty = new NumberProperty( filledOptions.inductance, { + this.inductanceProperty = new NumberProperty( options.inductance, { range: new Range( CCKCQueryParameters.inductanceMin, CCKCQueryParameters.inductanceMax ), tandem: tandem.createTandem( 'inductanceProperty' ) } ); diff --git a/js/model/Resistor.ts b/js/model/Resistor.ts index f83e57d9..f6963932 100644 --- a/js/model/Resistor.ts +++ b/js/model/Resistor.ts @@ -49,26 +49,26 @@ class Resistor extends FixedCircuitElement { * @param {Vertex} endVertex * @param {Resistor.ResistorType} resistorType * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( startVertex: Vertex, endVertex: Vertex, resistorType: any, tandem: Tandem, options?: Partial ) { - const filledOptions = merge( { + constructor( startVertex: Vertex, endVertex: Vertex, resistorType: any, tandem: Tandem, providedOptions?: Partial ) { + const options = merge( { isFlammable: true, // All resistors are flammable except for the dog, which automatically disconnects at high current. phetioType: Resistor.ResistorIO, numberOfDecimalPlaces: resistorType === Resistor.ResistorType.RESISTOR ? 1 : 0 - }, options ) as ResistorOptions; + }, providedOptions ) as ResistorOptions; - assert && assert( !filledOptions.hasOwnProperty( 'resistance' ), 'Resistance should be passed through resistorType' ); + assert && assert( !options.hasOwnProperty( 'resistance' ), 'Resistance should be passed through resistorType' ); // validate resistor type // @ts-ignore validate( resistorType, { valueType: Resistor.ResistorType } ); // @public (read-only) - assert && assert( !filledOptions.hasOwnProperty( 'isMetallic' ), 'isMetallic is given by the resistorType' ); - filledOptions.isMetallic = resistorType.isMetallic; + assert && assert( !options.hasOwnProperty( 'isMetallic' ), 'isMetallic is given by the resistorType' ); + options.isMetallic = resistorType.isMetallic; - super( startVertex, endVertex, resistorType.length, tandem, filledOptions ); + super( startVertex, endVertex, resistorType.length, tandem, options ); // @public (read-only) {Resistor.ResistorType} indicates one of ResistorType values this.resistorType = resistorType; diff --git a/js/model/SeriesAmmeter.ts b/js/model/SeriesAmmeter.ts index 6f1ba215..1f4ffbb6 100644 --- a/js/model/SeriesAmmeter.ts +++ b/js/model/SeriesAmmeter.ts @@ -20,10 +20,10 @@ class SeriesAmmeter extends FixedCircuitElement { * @param {Vertex} startVertex * @param {Vertex} endVertex * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( startVertex: Vertex, endVertex: Vertex, tandem: Tandem, options?: Partial ) { - super( startVertex, endVertex, CCKCConstants.SERIES_AMMETER_LENGTH, tandem, options ); + constructor( startVertex: Vertex, endVertex: Vertex, tandem: Tandem, providedOptions?: Partial ) { + super( startVertex, endVertex, CCKCConstants.SERIES_AMMETER_LENGTH, tandem, providedOptions ); // @public (read-only) {Property.} the resistance in ohms. A constant, but modeled as a property for // uniformity with other resistive elements. diff --git a/js/model/Switch.ts b/js/model/Switch.ts index 0e7df1e1..eb7aaf93 100644 --- a/js/model/Switch.ts +++ b/js/model/Switch.ts @@ -34,9 +34,9 @@ class Switch extends FixedCircuitElement { * @param {Vertex} startVertex * @param {Vertex} endVertex * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( startVertex: Vertex, endVertex: Vertex, tandem: Tandem, options?: Partial ) { + constructor( startVertex: Vertex, endVertex: Vertex, tandem: Tandem, providedOptions?: Partial ) { const filledOptions = merge( { closed: false, @@ -44,7 +44,7 @@ class Switch extends FixedCircuitElement { // Use the bounding box of the open lifelike switch to show bounds for all combinations of open/closed x lifelike/schematic // See https://github.com/phetsims/circuit-construction-kit-dc/issues/132 isSizeChangedOnViewChange: false - }, options ) as SwitchOptions; + }, providedOptions ) as SwitchOptions; super( startVertex, endVertex, SWITCH_LENGTH, tandem, filledOptions ); diff --git a/js/model/Vertex.ts b/js/model/Vertex.ts index 63f33c50..7c964324 100644 --- a/js/model/Vertex.ts +++ b/js/model/Vertex.ts @@ -48,11 +48,11 @@ class Vertex extends PhetioObject { /** * @param {Vector2} position - position in view coordinates - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( position: Vector2, options?: Partial ) { + constructor( position: Vector2, providedOptions?: Partial ) { - const filledOptions = merge( { + const options = merge( { draggable: true, // whether the vertex can be dragged, false for Black Box elements attachable: true, // Black box interior elements cannot be connected while the box is closed interactive: true, // Black box interface vertices can be interactive (tap to select) without being draggable @@ -61,20 +61,20 @@ class Vertex extends PhetioObject { tandem: Tandem.OPTIONAL, // Temporary vertices (for icons) should not be instrumented since they phetioDynamicElement: true // are more of an implementation detail rather than a feature - }, options ) as VertexOptions; + }, providedOptions ) as VertexOptions; - super( filledOptions ); + super( options ); // @public (readonly) {number} - Index counter for hashing in CircuitLayerNode. Also useful for debugging and can be shown // with ?vertexDisplay=index this.index = counter++; // @public (read-only) {Tandem} - this.vertexTandem = filledOptions.tandem; + this.vertexTandem = options.tandem; // @public - position of the vertex this.positionProperty = new Vector2Property( position, { - tandem: filledOptions.tandem && filledOptions.tandem.createTandem( 'positionProperty' ), + tandem: options.tandem && options.tandem.createTandem( 'positionProperty' ), useDeepEquality: true, isValidValue: ( position: Vector2 ) => position.isFinite() } ); @@ -86,7 +86,7 @@ class Vertex extends PhetioObject { // @public {NumberProperty} Relative voltage of the node, determined by Circuit.solve this.voltageProperty = new NumberProperty( 0, { - tandem: filledOptions.tandem && filledOptions.tandem.createTandem( 'voltageProperty' ), + tandem: options.tandem && options.tandem.createTandem( 'voltageProperty' ), units: 'V' } ); @@ -94,7 +94,7 @@ class Vertex extends PhetioObject { // 'cut' button. Multiple vertices can be selected on an iPad, unlike CircuitElements, which can only have one // vertex selected at a time. this.selectedProperty = new BooleanProperty( false, { - tandem: filledOptions.tandem && filledOptions.tandem.createTandem( 'selectedProperty' ) + tandem: options.tandem && options.tandem.createTandem( 'selectedProperty' ) } ); // Some of the following properties overlap. For example, if 'insideTrueBlackBox' is true, then the interactive @@ -102,23 +102,23 @@ class Vertex extends PhetioObject { // @public {BooleanProperty} - Vertices on the black box interface persist between build/investigate, and cannot be // moved/deleted - this.draggableProperty = new BooleanProperty( filledOptions.draggable ); + this.draggableProperty = new BooleanProperty( options.draggable ); // @public {BooleanProperty} - Black box interface vertices can be interactive (tap to select) without being // draggable - this.interactiveProperty = new BooleanProperty( filledOptions.interactive ); + this.interactiveProperty = new BooleanProperty( options.interactive ); // @public {BooleanProperty} - whether the Vertex can be dragged or moved by dragging another part of the circuit // must be observable. When two vertices are joined in Circuit.connect, non-interactivity propagates - this.attachableProperty = new BooleanProperty( filledOptions.attachable ); + this.attachableProperty = new BooleanProperty( options.attachable ); // @public (read-only) {BooleanProperty} - whether the vertex is on the edge of a black box. This means it cannot // be deleted, but it can be attached to - this.blackBoxInterfaceProperty = new BooleanProperty( filledOptions.blackBoxInterface ); + this.blackBoxInterfaceProperty = new BooleanProperty( options.blackBoxInterface ); // @public {BooleanProperty} - whether the vertex is inside the true black box, not inside the // user-created black box, on the interface or outside of the black box - this.insideTrueBlackBoxProperty = new BooleanProperty( filledOptions.insideTrueBlackBox ); + this.insideTrueBlackBoxProperty = new BooleanProperty( options.insideTrueBlackBox ); // @public {Emitter} - indicate when the vertex has been moved to the front in z-ordering and layering in the // view must be updated diff --git a/js/model/VoltageSource.ts b/js/model/VoltageSource.ts index 0efad41b..dbe144ea 100644 --- a/js/model/VoltageSource.ts +++ b/js/model/VoltageSource.ts @@ -33,11 +33,12 @@ abstract class VoltageSource extends FixedCircuitElement { * @param {Property.} internalResistanceProperty - the resistance of the battery * @param {number} length - the length of the battery in view coordinates * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( startVertex: Vertex, endVertex: Vertex, internalResistanceProperty: Property, length: number, tandem: Tandem, options?: Partial ) { + constructor( startVertex: Vertex, endVertex: Vertex, internalResistanceProperty: Property, length: number, tandem: Tandem, + providedOptions?: Partial ) { assert && assert( internalResistanceProperty, 'internalResistanceProperty should be defined' ); - const filledOptions = merge( { + const options = merge( { initialOrientation: 'right', voltage: 9.0, isFlammable: true, @@ -45,18 +46,18 @@ abstract class VoltageSource extends FixedCircuitElement { voltagePropertyOptions: { tandem: tandem.createTandem( 'voltageProperty' ) } - }, options ) as VoltageSourceOptions; - super( startVertex, endVertex, length, tandem, filledOptions ); + }, providedOptions ) as VoltageSourceOptions; + super( startVertex, endVertex, length, tandem, options ); // @public {NumberProperty} - the voltage of the battery in volts - this.voltageProperty = new NumberProperty( filledOptions.voltage, filledOptions.voltagePropertyOptions ); + this.voltageProperty = new NumberProperty( options.voltage, options.voltagePropertyOptions ); // @public {Property.} the internal resistance of the battery this.internalResistanceProperty = internalResistanceProperty; // @public (read-only) {string} - track which way the battery "button" (plus side) was facing the initial state so // the user can only create a certain number of "left" or "right" batteries from the toolbox. - this.initialOrientation = filledOptions.initialOrientation; + this.initialOrientation = options.initialOrientation; } /** diff --git a/js/model/Wire.ts b/js/model/Wire.ts index 537d6602..ba845ea1 100644 --- a/js/model/Wire.ts +++ b/js/model/Wire.ts @@ -39,21 +39,21 @@ class Wire extends CircuitElement { * @param {Vertex} endVertex * @param {Property.} resistivityProperty * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( startVertex: Vertex, endVertex: Vertex, resistivityProperty: NumberProperty, tandem: Tandem, options?: Partial ) { + constructor( startVertex: Vertex, endVertex: Vertex, resistivityProperty: NumberProperty, tandem: Tandem, providedOptions?: Partial ) { assert && assert( typeof resistivityProperty !== 'number', 'property should not be a number' ); assert && assert( !startVertex.isDisposed, 'vertex should not be disposed' ); assert && assert( !endVertex.isDisposed, 'vertex should not be disposed' ); - const filledOptions = merge( { + const options = merge( { wireStub: false, isMetallic: true - }, options ) as WireOptions; + }, providedOptions ) as WireOptions; const chargePathLength = startVertex.positionProperty.get().distance( endVertex.positionProperty.get() ); - super( startVertex, endVertex, chargePathLength, tandem, filledOptions ); + super( startVertex, endVertex, chargePathLength, tandem, options ); // @public (read-only) {boolean} - if the wire is a small stub attached to the black box - this.wireStub = filledOptions.wireStub; + this.wireStub = options.wireStub; // @public {NumberProperty} - the resistance of the Wire in ohms this.resistanceProperty = new NumberProperty( CCKCConstants.MINIMUM_WIRE_RESISTANCE ); diff --git a/js/view/ACVoltageNode.ts b/js/view/ACVoltageNode.ts index b4e946cc..eece6bd4 100644 --- a/js/view/ACVoltageNode.ts +++ b/js/view/ACVoltageNode.ts @@ -99,14 +99,14 @@ class ACVoltageNode extends FixedCircuitElementNode { * @param {ACVoltage} acSource * @param {Property.} viewTypeProperty * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ constructor( screenView: CCKCScreenView | null, circuitLayerNode: CircuitLayerNode | null, acSource: ACVoltage, - viewTypeProperty: Property, tandem: Tandem, options?: Partial ) { - options = merge( { + viewTypeProperty: Property, tandem: Tandem, providedOptions?: Partial ) { + const options = merge( { numberOfDecimalPlaces: 1, useHitTestForSensors: true - }, options ); + }, providedOptions ); assert && assert( acSource instanceof ACVoltage, 'should be AC voltage' ); // Center vertically to match the FixedCircuitElementNode assumption that origin is center left diff --git a/js/view/AdvancedAccordionBox.ts b/js/view/AdvancedAccordionBox.ts index 123251e6..1e0ef33a 100644 --- a/js/view/AdvancedAccordionBox.ts +++ b/js/view/AdvancedAccordionBox.ts @@ -22,9 +22,11 @@ import Circuit from '../model/Circuit.js'; import AlignGroup from '../../../scenery/js/nodes/AlignGroup.js'; import Tandem from '../../../tandem/js/Tandem.js'; -type AdvancedAccordionBoxOptions = { + +type AdvancedAccordionBoxImplementationOptions = { showRealBulbsCheckbox: boolean -} & CCKCAccordionBoxOptions; +}; +type AdvancedAccordionBoxOptions = AdvancedAccordionBoxImplementationOptions & CCKCAccordionBoxOptions; class AdvancedAccordionBox extends CCKCAccordionBox { @@ -33,13 +35,13 @@ class AdvancedAccordionBox extends CCKCAccordionBox { * @param {AlignGroup} alignGroup - to match the width of other panels * @param {string} batteryResistanceControlString * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( circuit: Circuit, alignGroup: AlignGroup, batteryResistanceControlString: string, tandem: Tandem, options?: Partial ) { + constructor( circuit: Circuit, alignGroup: AlignGroup, batteryResistanceControlString: string, tandem: Tandem, providedOptions?: Partial ) { - options = merge( { + const options = merge( { showRealBulbsCheckbox: true - }, options ); + }, providedOptions ) as Required; const titleConfig = { fontSize: CCKCConstants.FONT_SIZE, diff --git a/js/view/AmmeterNode.ts b/js/view/AmmeterNode.ts index 875bd664..50ff35e2 100644 --- a/js/view/AmmeterNode.ts +++ b/js/view/AmmeterNode.ts @@ -62,10 +62,10 @@ class AmmeterNode extends Node { /** * @param {Ammeter} ammeter * @param {CircuitLayerNode|null} circuitLayerNode - for getting the currents, or null if rendering an icon - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( ammeter: Ammeter, circuitLayerNode: CircuitLayerNode | null, options?: Partial ) { - const filledOptions = merge( { + constructor( ammeter: Ammeter, circuitLayerNode: CircuitLayerNode | null, providedOptions?: Partial ) { + const options = merge( { // true if it will be used as a toolbox icon isIcon: false, @@ -80,8 +80,8 @@ class AmmeterNode extends Node { blackBoxStudy: false, tandem: Tandem.REQUIRED - }, options ) as AmmeterNodeOptions; - const tandem = filledOptions.tandem; + }, providedOptions ) as AmmeterNodeOptions; + const tandem = options.tandem; const wireBodyPositionProperty = new Vector2Property( new Vector2( 0, 0 ) ); const wireProbePositionProperty = new Vector2Property( new Vector2( 0, 0 ) ); @@ -98,8 +98,8 @@ class AmmeterNode extends Node { const currentReadoutProperty = new DerivedProperty( [ ammeter.currentProperty ], ( ( current: number ) => { - const max = filledOptions.blackBoxStudy ? 1E3 : 1E10; - const maxString = filledOptions.blackBoxStudy ? '> 10^3' : '> 10^10'; + const max = options.blackBoxStudy ? 1E3 : 1E10; + const maxString = options.blackBoxStudy ? '> 10^3' : '> 10^10'; // Ammeters in this sim only show positive values, not direction (which is arbitrary anyways) return current === null ? MathSymbols.NO_VALUE : @@ -108,7 +108,7 @@ class AmmeterNode extends Node { } ) ); const probeTextNode = new ProbeTextNode( - currentReadoutProperty, filledOptions.showResultsProperty, currentString, tandem.createTandem( 'probeTextNode' ), { + currentReadoutProperty, options.showResultsProperty, currentString, tandem.createTandem( 'probeTextNode' ), { centerX: ammeterBodyImage.width / 2, centerY: ammeterBodyImage.height / 2 + 7 // adjust for the top notch design } ); @@ -137,11 +137,11 @@ class AmmeterNode extends Node { ] } ); - assert && assert( !filledOptions.hasOwnProperty( 'children' ), 'children will be supplied by AmmeterNode' ); + assert && assert( !options.hasOwnProperty( 'children' ), 'children will be supplied by AmmeterNode' ); - filledOptions.children = [ bodyNode, wireNode, probeNode ]; + options.children = [ bodyNode, wireNode, probeNode ]; - super( filledOptions ); + super( options ); // @public (read-only) {ProbeNode} this.probeNode = probeNode; @@ -152,8 +152,8 @@ class AmmeterNode extends Node { const alignProbeToBody = () => { if ( ammeter.draggingProbesWithBodyProperty.get() ) { - const constrain = ( pt: Vector2 ) => filledOptions.visibleBoundsProperty ? - filledOptions.visibleBoundsProperty.value.eroded( CCKCConstants.DRAG_BOUNDS_EROSION ).closestPointTo( pt ) : + const constrain = ( pt: Vector2 ) => options.visibleBoundsProperty ? + options.visibleBoundsProperty.value.eroded( CCKCConstants.DRAG_BOUNDS_EROSION ).closestPointTo( pt ) : pt; ammeter.probePositionProperty.set( constrain( ammeter.bodyPositionProperty.value.plusXY( 40, -80 ) ) ); @@ -173,7 +173,7 @@ class AmmeterNode extends Node { wireProbePositionProperty.value = this.probeNode.centerBottom; } ); - if ( !filledOptions.isIcon ) { + if ( !options.isIcon ) { // Show the ammeter in the play area when dragged from toolbox ammeter.visibleProperty.linkAttribute( this, 'visible' ); @@ -204,7 +204,7 @@ class AmmeterNode extends Node { targetNode: this } ); bodyNode.addInputListener( this.dragHandler ); - filledOptions.visibleBoundsProperty!.link( ( visibleBounds: Bounds2 ) => { + options.visibleBoundsProperty!.link( ( visibleBounds: Bounds2 ) => { const erodedDragBounds = visibleBounds.eroded( CCKCConstants.DRAG_BOUNDS_EROSION ); this.dragHandler!.dragBounds = erodedDragBounds; probeDragHandler.dragBounds = erodedDragBounds; @@ -232,7 +232,7 @@ class AmmeterNode extends Node { } // When rendered as an icon, the touch area should span the bounds (no gaps between probes and body) - if ( filledOptions.isIcon ) { + if ( options.isIcon ) { this.touchArea = this.bounds.copy(); this.mouseArea = this.bounds.copy(); this.cursor = 'pointer'; diff --git a/js/view/BarkNode.ts b/js/view/BarkNode.ts index 333a5414..174cd869 100644 --- a/js/view/BarkNode.ts +++ b/js/view/BarkNode.ts @@ -17,9 +17,9 @@ import Node from '../../../scenery/js/nodes/Node.js'; class BarkNode extends Node { /** - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( options?: Partial ) { + constructor( providedOptions?: Partial ) { super(); this.addChild( new Path( commentSolidShape, { fill: 'white', @@ -53,7 +53,7 @@ class BarkNode extends Node { center: this.center.plusXY( 0, -3 ) } ) ); - this.mutate( options ); + this.mutate( providedOptions ); } } diff --git a/js/view/BatteryNode.ts b/js/view/BatteryNode.ts index d79ed6cd..ee4a9e06 100644 --- a/js/view/BatteryNode.ts +++ b/js/view/BatteryNode.ts @@ -71,11 +71,11 @@ class BatteryNode extends FixedCircuitElementNode { * @param {Battery} battery * @param {Property.} viewTypeProperty * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( screenView: CCKCScreenView | null, circuitLayerNode: CircuitLayerNode | null, battery: Battery, viewTypeProperty: Property, tandem: Tandem, options?: Partial ) { + constructor( screenView: CCKCScreenView | null, circuitLayerNode: CircuitLayerNode | null, battery: Battery, viewTypeProperty: Property, tandem: Tandem, providedOptions?: Partial ) { - options = merge( { useHitTestForSensors: true }, options ); + providedOptions = merge( { useHitTestForSensors: true }, providedOptions ); const lifelikeNode = new Image( battery.batteryType === 'normal' ? batteryImage : batteryHighImage ) as unknown as Node; lifelikeNode.mutate( { @@ -93,7 +93,7 @@ class BatteryNode extends FixedCircuitElementNode { lifelikeNode, schematicNode, tandem, - options + providedOptions ); // @public (read-only) {Battery} - the Battery rendered by this Node diff --git a/js/view/CCKCAccordionBox.ts b/js/view/CCKCAccordionBox.ts index 93a4e96d..f9d2ce8e 100644 --- a/js/view/CCKCAccordionBox.ts +++ b/js/view/CCKCAccordionBox.ts @@ -31,11 +31,11 @@ class CCKCAccordionBox extends AccordionBox { * @param {Node} content - the content to display in the accordion box when it is expanded * @param {string} title - the text to display in the title bar * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( content: Node, title: string, tandem: Tandem, options?: Partial ) { + constructor( content: Node, title: string, tandem: Tandem, providedOptions?: Partial ) { - options = options || {}; + providedOptions = providedOptions || {}; super( content, merge( { fill: CCKCConstants.PANEL_COLOR, cornerRadius: CCKCConstants.CORNER_RADIUS, @@ -58,7 +58,7 @@ class CCKCAccordionBox extends AccordionBox { }, titleNode: new HBox( { children: [ - new HStrut( options.strutWidth || 10 ), + new HStrut( providedOptions.strutWidth || 10 ), new Text( title, { fontSize: CCKCConstants.FONT_SIZE, maxWidth: 175, @@ -67,7 +67,7 @@ class CCKCAccordionBox extends AccordionBox { ] } ), tandem: tandem - }, options ) ); + }, providedOptions ) ); } } diff --git a/js/view/CCKCChartNode.ts b/js/view/CCKCChartNode.ts index 6e027f54..8a5aa00c 100644 --- a/js/view/CCKCChartNode.ts +++ b/js/view/CCKCChartNode.ts @@ -81,24 +81,24 @@ class CCKCChartNode extends Node { * @param {Property.} visibleBoundsProperty * @param {ObservableArrayDef.} series * @param {string} verticalAxisLabel - * @param {Object} [options] + * @param {Object} [providedOptions] */ constructor( circuitLayerNode: CircuitLayerNode, timeProperty: Property, visibleBoundsProperty: Property, - series: ObservableArray, verticalAxisLabel: string, options?: Partial ) { - const filledOptions = merge( { + series: ObservableArray, verticalAxisLabel: string, providedOptions?: Partial ) { + const options = merge( { defaultZoomLevel: new Range( -2, 2 ), // Prevent adjustment of the control panel rendering while dragging, // see https://github.com/phetsims/wave-interference/issues/212 preventFit: true, tandem: Tandem.OPTIONAL - }, options ) as CCKCChartNodeOptions; + }, providedOptions ) as CCKCChartNodeOptions; const backgroundNode = new Node( { cursor: 'pointer' } ); super(); // @public {Meter} - this.meter = new Meter( filledOptions.tandem.createTandem( 'meter' ), 0 ); + this.meter = new Meter( options.tandem.createTandem( 'meter' ), 0 ); // @protected {ObservableArrayDef.} this.series = series; @@ -122,7 +122,7 @@ class CCKCChartNode extends Node { this.addChild( this.backgroundNode ); // Mutate after backgroundNode is added as a child - this.mutate( filledOptions ); + this.mutate( options ); // @public - emits when the probes should be put in standard relative position to the body this.alignProbesEmitter = new Emitter(); @@ -183,12 +183,12 @@ class CCKCChartNode extends Node { new Range( -2, 2 ), new Range( -0.4, 0.4 ) ]; - const initialZoomIndex = zoomRanges.findIndex( e => e.equals( filledOptions.defaultZoomLevel ) ); + const initialZoomIndex = zoomRanges.findIndex( e => e.equals( options.defaultZoomLevel ) ); // @private this.zoomLevelProperty = new NumberProperty( initialZoomIndex, { range: new Range( 0, zoomRanges.length - 1 ), - tandem: filledOptions.tandem.createTandem( 'zoomLevelProperty' ) + tandem: options.tandem.createTandem( 'zoomLevelProperty' ) } ); const gridLineOptions = { @@ -229,7 +229,7 @@ class CCKCChartNode extends Node { xMargin: 3, yMargin: 3 }, - tandem: filledOptions.tandem.createTandem( 'zoomButtonGroup' ) + tandem: options.tandem.createTandem( 'zoomButtonGroup' ) } ); this.zoomLevelProperty.link( ( zoomLevel: number ) => { chartTransform.setModelYRange( zoomRanges[ zoomLevel ] ); diff --git a/js/view/CCKCCheckbox.ts b/js/view/CCKCCheckbox.ts index 64c0114c..07460d7c 100644 --- a/js/view/CCKCCheckbox.ts +++ b/js/view/CCKCCheckbox.ts @@ -19,12 +19,12 @@ class CCKCCheckbox extends Checkbox { /** * @param {Node} content * @param {Property.} property - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( content: Node, property: Property, options?: Partial ) { + constructor( content: Node, property: Property, providedOptions?: Partial ) { - options = merge( { boxWidth: BOX_WIDTH }, options ); - super( content, property, options ); + providedOptions = merge( { boxWidth: BOX_WIDTH }, providedOptions ); + super( content, property, providedOptions ); } } diff --git a/js/view/CCKCLightBulbNode.ts b/js/view/CCKCLightBulbNode.ts index 190059bb..c85e2851 100644 --- a/js/view/CCKCLightBulbNode.ts +++ b/js/view/CCKCLightBulbNode.ts @@ -70,14 +70,14 @@ class CCKCLightBulbNode extends FixedCircuitElementNode { * @param {Property.} showResultsProperty - true if the sim can display values * @param {Property.} viewTypeProperty * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ constructor( screenView: CCKCScreenView | null, circuitLayerNode: CircuitLayerNode | null, lightBulb: LightBulb, - showResultsProperty: Property, viewTypeProperty: Property, tandem: Tandem, options?: Partial ) { + showResultsProperty: Property, viewTypeProperty: Property, tandem: Tandem, providedOptions?: Partial ) { let filledOptions = merge( { isIcon: false, useHitTestForSensors: true - }, options ) as FixedCircuitElementNodeOptions; + }, providedOptions ) as FixedCircuitElementNodeOptions; const brightnessProperty = new NumberProperty( 0 ); const updateBrightness = Property.multilink( [ lightBulb.currentProperty, showResultsProperty, lightBulb.resistanceProperty ], diff --git a/js/view/CCKCPanel.ts b/js/view/CCKCPanel.ts index e2697a83..8893c6ee 100644 --- a/js/view/CCKCPanel.ts +++ b/js/view/CCKCPanel.ts @@ -18,18 +18,18 @@ class CCKCPanel extends Panel { /** * @param {Node} content - what will appear in the panel * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( content: Node, tandem: Tandem, options?: Partial ) { - options = merge( { + constructor( content: Node, tandem: Tandem, providedOptions?: Partial ) { + providedOptions = merge( { fill: CCKCConstants.PANEL_COLOR, lineWidth: CCKCConstants.PANEL_LINE_WIDTH, xMargin: 15, yMargin: 15, tandem: tandem, cornerRadius: CCKCConstants.CORNER_RADIUS - }, options ); - super( content, options ); + }, providedOptions ); + super( content, providedOptions ); } } diff --git a/js/view/CCKCProbeNode.ts b/js/view/CCKCProbeNode.ts index c9ac9ba3..5702599e 100644 --- a/js/view/CCKCProbeNode.ts +++ b/js/view/CCKCProbeNode.ts @@ -22,23 +22,23 @@ class CCKCProbeNode extends ProbeNode { /** * @param {Node} node container node which should move to front on press * @param {Property.} visibleBoundsProperty - visible bounds of the ScreenView - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( node: Node, visibleBoundsProperty: Property, options?: any ) { + constructor( node: Node, visibleBoundsProperty: Property, providedOptions?: any ) { - options = merge( { + providedOptions = merge( { cursor: 'pointer', sensorTypeFunction: ProbeNode.crosshairs( { stroke: 'white' } ), scale: 0.4, drag: () => {}, tandem: Tandem.OPTIONAL - }, options ); + }, providedOptions ); - super( options ); + super( providedOptions ); // Wire position through PhET-iO so it can be recorded in the state const positionProperty = new Vector2Property( new Vector2( 0, 0 ), { - tandem: options.tandem.createTandem( 'positionProperty' ) + tandem: providedOptions.tandem.createTandem( 'positionProperty' ) } ); positionProperty.link( ( p: Vector2 ) => this.setTranslation( p ) ); @@ -49,8 +49,8 @@ class CCKCProbeNode extends ProbeNode { positionProperty: positionProperty, dragBoundsProperty: visibleBoundsProperty, press: () => node.moveToFront(), - drag: () => options.drag(), - tandem: options.tandem.createTandem( 'dragListener' ) + drag: () => providedOptions.drag(), + tandem: providedOptions.tandem.createTandem( 'dragListener' ) } ) ); } } diff --git a/js/view/CapacitorCircuitElementNode.ts b/js/view/CapacitorCircuitElementNode.ts index cb76561d..ec4f7f06 100644 --- a/js/view/CapacitorCircuitElementNode.ts +++ b/js/view/CapacitorCircuitElementNode.ts @@ -78,13 +78,13 @@ class CapacitorCircuitElementNode extends FixedCircuitElementNode { * @param {Capacitor} capacitor * @param {Property.} viewTypeProperty * @param {Tandem} tandem - * @param {Object} [options] + * @param {Object} [providedOptions] */ - constructor( screenView: CCKCScreenView | null, circuitLayerNode: CircuitLayerNode | null, capacitor: Capacitor, viewTypeProperty: Property, tandem: Tandem, options?: Partial ) { + constructor( screenView: CCKCScreenView | null, circuitLayerNode: CircuitLayerNode | null, capacitor: Capacitor, viewTypeProperty: Property, tandem: Tandem, providedOptions?: Partial ) { - options = merge( { + providedOptions = merge( { isIcon: false - }, options ); + }, providedOptions ); const wireStubOptions = { @@ -119,7 +119,7 @@ class CapacitorCircuitElementNode extends FixedCircuitElementNode { // @ts-ignore orientation: Orientation.HORIZONTAL, // so the "-" charges are upside-up in the default orientation - includeChargeNode: !options.isIcon, + includeChargeNode: !providedOptions.isIcon, scale: 0.45, rotation: -Math.PI / 2, centerX: capacitor.distanceBetweenVertices / 2, @@ -179,7 +179,7 @@ class CapacitorCircuitElementNode extends FixedCircuitElementNode { lifelikeNodeContainer, schematicNode, tandem, - options + providedOptions ); // @public (read-only) {Capacitor} - the Capacitor rendered by this Node