Skip to content

Commit

Permalink
Rename all instances of 'highVoltage' and 'highResistance' to 'extrem…
Browse files Browse the repository at this point in the history
…e' - #936
  • Loading branch information
UniverseAndMore committed Jan 19, 2023
1 parent 4f186a4 commit 6c608ff
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 51 deletions.
20 changes: 10 additions & 10 deletions js/model/Circuit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ export default class Circuit {
private readonly stepActions: ( () => void )[];
public readonly wireGroup: PhetioGroup<Wire, [ Vertex, Vertex ]>;
public readonly batteryGroup: PhetioGroup<Battery, [ Vertex, Vertex ]>;
public readonly highVoltageBatteryGroup: PhetioGroup<Battery, [ Vertex, Vertex ]>;
public readonly extremeBatteryGroup: PhetioGroup<Battery, [ Vertex, Vertex ]>;
public readonly acVoltageGroup: PhetioGroup<ACVoltage, [ Vertex, Vertex ]>;
public readonly resistorGroup: PhetioGroup<Resistor, [ Vertex, Vertex, ResistorType ]>;
public readonly fuseGroup: PhetioGroup<Fuse, [ Vertex, Vertex ]>;
public readonly seriesAmmeterGroup: PhetioGroup<SeriesAmmeter, [ Vertex, Vertex ]>;
public readonly highResistanceLightBulbGroup: PhetioGroup<LightBulb, [ Vertex, Vertex ]>;
public readonly extremeLightBulbGroup: PhetioGroup<LightBulb, [ Vertex, Vertex ]>;
public readonly capacitorGroup: PhetioGroup<Capacitor, [ Vertex, Vertex ]>;
public readonly inductorGroup: PhetioGroup<Inductor, [ Vertex, Vertex ]>;
public readonly switchGroup: PhetioGroup<Switch, [ Vertex, Vertex ]>;
Expand Down Expand Up @@ -347,16 +347,16 @@ export default class Circuit {
tandem: tandem.createTandem( 'batteryGroup' )
} );

this.highVoltageBatteryGroup = new PhetioGroup( ( tandem, startVertex, endVertex ) => {
this.extremeBatteryGroup = new PhetioGroup( ( tandem, startVertex, endVertex ) => {
return new Battery( startVertex, endVertex, this.sourceResistanceProperty, 'high-voltage',
tandem, {
voltage: 1000,
numberOfDecimalPlaces: Battery.HIGH_VOLTAGE_DECIMAL_PLACES
} );
}, () => createVertices( BATTERY_LENGTH ), {
phetioType: PhetioGroup.PhetioGroupIO( CircuitElement.CircuitElementIO ),
tandem: this.includeLabElements ? tandem.createTandem( 'highVoltageBatteryGroup' ) : Tandem.OPT_OUT,
phetioDynamicElementName: 'highVoltageBattery'
tandem: this.includeLabElements ? tandem.createTandem( 'extremeBatteryGroup' ) : Tandem.OPT_OUT,
phetioDynamicElementName: 'extremeBattery'
} );

this.acVoltageGroup = new PhetioGroup( ( tandem, startVertex, endVertex ) => {
Expand Down Expand Up @@ -392,15 +392,15 @@ export default class Circuit {
tandem: this.includeLabElements ? tandem.createTandem( 'seriesAmmeterGroup' ) : Tandem.OPT_OUT
} );

this.highResistanceLightBulbGroup = new PhetioGroup(
this.extremeLightBulbGroup = new PhetioGroup(
( tandem, startVertex, endVertex ) => {
return LightBulb.createAtPosition( startVertex, endVertex, this, CCKCConstants.HIGH_RESISTANCE,
this.viewTypeProperty, tandem, {
highResistance: true
extreme: true
} );
}, () => createVertices( 100 ), {
phetioType: PhetioGroup.PhetioGroupIO( CircuitElement.CircuitElementIO ),
tandem: this.includeLabElements ? tandem.createTandem( 'highResistanceLightBulbGroup' ) : Tandem.OPT_OUT
tandem: this.includeLabElements ? tandem.createTandem( 'extremeLightBulbGroup' ) : Tandem.OPT_OUT
} );

this.capacitorGroup = new PhetioGroup(
Expand Down Expand Up @@ -444,7 +444,7 @@ export default class Circuit {
this.groups = [
this.wireGroup,
this.batteryGroup,
this.highVoltageBatteryGroup,
this.extremeBatteryGroup,
this.acVoltageGroup,
this.resistorGroup,
this.fuseGroup,
Expand All @@ -453,7 +453,7 @@ export default class Circuit {
this.switchGroup,
this.lightBulbGroup,
this.realLightBulbGroup,
this.highResistanceLightBulbGroup,
this.extremeLightBulbGroup,
this.seriesAmmeterGroup
];
this.dirty = false;
Expand Down
12 changes: 6 additions & 6 deletions js/model/LightBulb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const SCHEMATIC_SAMPLE_POINTS = [
];

type SelfOptions = {
highResistance?: boolean;
extreme?: boolean;
real?: boolean;
};

Expand All @@ -66,7 +66,7 @@ export default class LightBulb extends FixedCircuitElement {
public readonly real: boolean;

// true if the light bulb is a high resistance light bulb
public readonly highResistance: boolean;
public readonly extreme: boolean;

// the resistance of the light bulb which can be edited with the UI
public readonly resistanceProperty: NumberProperty;
Expand Down Expand Up @@ -114,20 +114,20 @@ export default class LightBulb extends FixedCircuitElement {
tandem: Tandem,
providedOptions?: LightBulbOptions ) {
const options = optionize<LightBulbOptions, SelfOptions, FixedCircuitElementOptions>()( {
highResistance: false,
extreme: false,
real: false
}, providedOptions );
assert && assert( !options.hasOwnProperty( 'numberOfDecimalPlaces' ), 'supplied by LightBulb' );
options.numberOfDecimalPlaces = options.highResistance ? 0 : 1;
options.numberOfDecimalPlaces = options.extreme ? 0 : 1;

// getPathLength not available yet, so use a nonzero charge path length then override.
super( startVertex, endVertex, 1, tandem, options );

this.real = options.real;
this.highResistance = options.highResistance;
this.extreme = options.extreme;
this.resistanceProperty = new NumberProperty( resistance, {
tandem: tandem.createTandem( 'resistanceProperty' ),
range: options.highResistance ? new Range( 100, 10000 ) :
range: options.extreme ? new Range( 100, 10000 ) :
options.real ? new Range( 0, Number.MAX_VALUE ) : // The non-ohmic bulb has its resistance computed in LinearTransientAnalysis.js
new Range( 0, 120 )
} );
Expand Down
2 changes: 1 addition & 1 deletion js/view/CCKCLightBulbNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class CCKCLightBulbNode extends FixedCircuitElementNode {

// The isIcon must show the socket as well
if ( filledOptions.isIcon ) {
lightBulbNode = new Image( lightBulb.highResistance ? lightBulbMiddleHigh_png :
lightBulbNode = new Image( lightBulb.extreme ? lightBulbMiddleHigh_png :
lightBulb.real ? lightBulbMiddleReal_png :
lightBulbMiddle_png, { scale: 0.37 } );

Expand Down
24 changes: 12 additions & 12 deletions js/view/CircuitElementEditContainerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export default class CircuitElementEditContainerNode extends Node {
StringUtils.fillIn( resistanceOhmsValuePatternStringProperty, { resistance: SunConstants.VALUE_NAMED_PLACEHOLDER } ),
createSingletonAdapterProperty( ResistorType.RESISTOR.defaultResistance, CircuitElementType, circuit, ( c: LightBulb | Resistor ) => c.resistanceProperty,
( c: LightBulb | Resistor ) =>
( c instanceof LightBulb && !c.highResistance ) ||
( c instanceof LightBulb && !c.extreme ) ||
( c instanceof Resistor && c.resistorType !== ResistorType.HIGH_RESISTANCE_RESISTOR )
),
ResistorType.RESISTOR.range, circuit, Resistor.RESISTANCE_DECIMAL_PLACES, {
Expand All @@ -209,11 +209,11 @@ export default class CircuitElementEditContainerNode extends Node {
},
numberDisplayOptions: { decimalPlaces: Resistor.RESISTANCE_DECIMAL_PLACES }
} );
const createHighResistanceNumberControl = ( tandemName: string, CircuitElementType: GConstructor<LightBulb | Resistor> ) => new CircuitElementNumberControl( resistanceStringProperty,
const createExtremeResistanceNumberControl = ( tandemName: string, CircuitElementType: GConstructor<LightBulb | Resistor> ) => new CircuitElementNumberControl( resistanceStringProperty,
StringUtils.fillIn( resistanceOhmsValuePatternStringProperty, { resistance: SunConstants.VALUE_NAMED_PLACEHOLDER } ),
createSingletonAdapterProperty( ResistorType.HIGH_RESISTANCE_RESISTOR.defaultResistance, CircuitElementType, circuit, ( c: LightBulb | Resistor ) => c.resistanceProperty,
( c: LightBulb | Resistor ) =>
( c instanceof LightBulb && c.highResistance ) ||
( c instanceof LightBulb && c.extreme ) ||
( c instanceof Resistor && c.resistorType === ResistorType.HIGH_RESISTANCE_RESISTOR )
),
ResistorType.HIGH_RESISTANCE_RESISTOR.range, circuit, Resistor.HIGH_RESISTANCE_DECIMAL_PLACES, {
Expand All @@ -225,10 +225,10 @@ export default class CircuitElementEditContainerNode extends Node {
numberDisplayOptions: { decimalPlaces: Resistor.HIGH_RESISTANCE_DECIMAL_PLACES }
} );

const resistanceNumberControl = createResistanceNumberControl( 'resistanceNumberControl', Resistor );
const resistorResistanceNumberControl = createResistanceNumberControl( 'resistorResistanceNumberControl', Resistor );
const lightBulbResistanceNumberControl = createResistanceNumberControl( 'lightBulbResistanceNumberControl', LightBulb );
const highResistanceNumberControl = createHighResistanceNumberControl( 'highResistanceNumberControl', Resistor );
const lightBulbHighResistanceNumberControl = createHighResistanceNumberControl( 'lightBulbHighResistanceNumberControl', LightBulb );
const extremeResistorResistanceNumberControl = createExtremeResistanceNumberControl( 'extremeResistorResistanceNumberControl', Resistor );
const extremeLightBulbResistanceNumberControl = createExtremeResistanceNumberControl( 'extremeLightBulbResistanceNumberControl', LightBulb );

const voltageNumberControl = new CircuitElementNumberControl( voltageStringProperty,
StringUtils.fillIn( voltageVoltsValuePatternStringProperty, { voltage: SunConstants.VALUE_NAMED_PLACEHOLDER } ),
Expand All @@ -243,13 +243,13 @@ export default class CircuitElementEditContainerNode extends Node {
},
numberDisplayOptions: { decimalPlaces: Battery.VOLTAGE_DECIMAL_PLACES }
} );
const highVoltageNumberControl = new CircuitElementNumberControl( voltageStringProperty,
const extremeBatteryVoltageNumberControl = new CircuitElementNumberControl( voltageStringProperty,
StringUtils.fillIn( voltageVoltsValuePatternStringProperty, { voltage: SunConstants.VALUE_NAMED_PLACEHOLDER } ),
createSingletonAdapterProperty( Battery.HIGH_VOLTAGE_DEFAULT, Battery, circuit, ( c: Battery ) => c.voltageProperty, ( c: Battery ) => c.batteryType === 'high-voltage' ),
Battery.HIGH_VOLTAGE_RANGE,
circuit,
Battery.HIGH_VOLTAGE_DECIMAL_PLACES, {
tandem: circuit.includeLabElements ? tandem.createTandem( 'highVoltageNumberControl' ) : Tandem.OPT_OUT,
tandem: circuit.includeLabElements ? tandem.createTandem( 'extremeBatteryVoltageNumberControl' ) : Tandem.OPT_OUT,
delta: HIGH_TWEAKER_DELTA,
sliderOptions: { // For dragging the slider knob
constrainValue: ( value: number ) => Utils.roundToInterval( value, HIGH_SLIDER_KNOB_DELTA )
Expand Down Expand Up @@ -343,17 +343,17 @@ export default class CircuitElementEditContainerNode extends Node {
if ( selectedCircuitElement ) {

if ( selectedCircuitElement instanceof Resistor && selectedCircuitElement.isResistanceEditable() ) {
const isHighResistance = selectedCircuitElement.resistorType === ResistorType.HIGH_RESISTANCE_RESISTOR;
const isExtreme = selectedCircuitElement.resistorType === ResistorType.HIGH_RESISTANCE_RESISTOR;
editNode = new EditPanel( [
isHighResistance ? highResistanceNumberControl : resistanceNumberControl,
isExtreme ? extremeResistorResistanceNumberControl : resistorResistanceNumberControl,
trashButtonContainer
] );
}

// Real bulb has no resistance control
else if ( selectedCircuitElement instanceof LightBulb && !selectedCircuitElement.real ) {
editNode = new EditPanel( [
selectedCircuitElement.highResistance ? lightBulbHighResistanceNumberControl : lightBulbResistanceNumberControl,
selectedCircuitElement.extreme ? extremeLightBulbResistanceNumberControl : lightBulbResistanceNumberControl,
trashButtonContainer
]
);
Expand All @@ -366,7 +366,7 @@ export default class CircuitElementEditContainerNode extends Node {
else if ( selectedCircuitElement instanceof Battery ) {
editNode = new EditPanel( [
reverseBatteryButton, // Batteries can be reversed
selectedCircuitElement.batteryType === 'high-voltage' ? highVoltageNumberControl : voltageNumberControl,
selectedCircuitElement.batteryType === 'high-voltage' ? extremeBatteryVoltageNumberControl : voltageNumberControl,
trashButtonContainer
]
);
Expand Down
28 changes: 14 additions & 14 deletions js/view/CircuitElementToolFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ export default class CircuitElementToolFactory {
CCKCConstants.DEFAULT_RESISTANCE,
this.viewTypeProperty,
Tandem.OPTIONAL, {
highResistance: false,
extreme: false,
real: real
} );
return this.createCircuitElementToolNode( string, 10,
( tandem, viewTypeProperty ) => new CCKCLightBulbNode( null, null,
lightBulbModel,
new BooleanProperty( true ), viewTypeProperty, Tandem.OPT_OUT, { isIcon: true, scale: 0.85 } ),
circuitElement => circuitElement instanceof LightBulb && !circuitElement.highResistance,
circuitElement => circuitElement instanceof LightBulb && !circuitElement.extreme,
( position: Vector2 ) => {
const vertexPair = LightBulb.createVertexPair( position, this.circuit );
return lightBulbGroup.createNextElement( vertexPair.startVertex, vertexPair.endVertex );
Expand Down Expand Up @@ -470,16 +470,16 @@ export default class CircuitElementToolFactory {
}

// Same docs as for createPaperClipToolNode
public createHighResistanceResistorToolNode(): CircuitElementToolNode {
public createExtremeResistorToolNode(): CircuitElementToolNode {
return this.createResistorToolNode( {
count: 4,
resistorType: ResistorType.HIGH_RESISTANCE_RESISTOR,
tandemName: 'highResistanceResistorToolNode',
tandemName: 'extremeResistorToolNode',
labelStringProperty: resistorStringProperty
} );
}

public createHighVoltageBatteryToolNode(): CircuitElementToolNode {
public createExtremeBatteryToolNode(): CircuitElementToolNode {
return this.createCircuitElementToolNode( batteryStringProperty, 4,
( tandem, viewTypeProperty ) => new BatteryNode( null, null,
new Battery(
Expand All @@ -491,18 +491,18 @@ export default class CircuitElementToolFactory {
voltage: 1000,
numberOfDecimalPlaces: Battery.HIGH_VOLTAGE_DECIMAL_PLACES
}
), viewTypeProperty, tandem.createTandem( 'highVoltageBatteryToolNode' ), { isIcon: true } ),
), viewTypeProperty, tandem.createTandem( 'extremeBatteryToolNode' ), { isIcon: true } ),
circuitElement => circuitElement instanceof Battery &&
circuitElement.initialOrientation === 'right' &&
circuitElement.batteryType === 'high-voltage', ( position: Vector2 ) => {
return this.circuit.highVoltageBatteryGroup.createNextElement( ...this.circuit.createVertexPairArray( position, SWITCH_LENGTH ) );
return this.circuit.extremeBatteryGroup.createNextElement( ...this.circuit.createVertexPairArray( position, SWITCH_LENGTH ) );
}, {
tandem: this.parentTandem.createTandem( 'highVoltageBatteryToolNode' ),
tandem: this.parentTandem.createTandem( 'extremeBatteryToolNode' ),
lifelikeIconHeight: 15
} );
}

public createHighResistanceBulbToolNode(): CircuitElementToolNode {
public createExtremeBulbToolNode(): CircuitElementToolNode {
const vertexPair = LightBulb.createVertexPair( Vector2.ZERO, this.circuit, true );
return this.createCircuitElementToolNode( lightBulbStringProperty, 4,
( tandem, viewTypeProperty ) => new CCKCLightBulbNode(
Expand All @@ -515,19 +515,19 @@ export default class CircuitElementToolFactory {
1000,
this.viewTypeProperty,
Tandem.OPTIONAL, {
highResistance: true
extreme: true
} ),
new BooleanProperty( true ),
viewTypeProperty,
tandem.createTandem( 'highResistanceLightBulbToolNode' ), {
tandem.createTandem( 'extremeLightBulbToolNode' ), {
isIcon: true
} ),
circuitElement => circuitElement instanceof LightBulb && circuitElement.highResistance,
circuitElement => circuitElement instanceof LightBulb && circuitElement.extreme,
( position: Vector2 ) => {
const vertexPair = LightBulb.createVertexPair( position, this.circuit, false );
return this.circuit.highResistanceLightBulbGroup.createNextElement( vertexPair.startVertex, vertexPair.endVertex );
return this.circuit.extremeLightBulbGroup.createNextElement( vertexPair.startVertex, vertexPair.endVertex );
}, {
tandem: this.parentTandem.createTandem( 'highResistanceBulbToolNode' )
tandem: this.parentTandem.createTandem( 'extremeBulbToolNode' )
} );
}
}
Expand Down
8 changes: 4 additions & 4 deletions js/view/CircuitLayerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,21 +353,21 @@ export default class CircuitLayerNode extends Node {
new PhetioGroup<CircuitElementNode, [ CircuitElement ]>( ( tandem: Tandem, circuitElement: CircuitElement ) => new BatteryNode( screenView, this, circuitElement as Battery, this.model.viewTypeProperty, tandem ),
() => [ this.circuit.batteryGroup.archetype ], {
phetioType: PhetioGroup.PhetioGroupIO( Node.NodeIO ),
tandem: circuit.includeLabElements ? tandem.createTandem( 'highVoltageBatteryNodeGroup' ) : Tandem.OPT_OUT,
tandem: circuit.includeLabElements ? tandem.createTandem( 'extremeBatteryNodeGroup' ) : Tandem.OPT_OUT,
supportsDynamicState: false
} ) );
initializeCircuitElementType( ( e: CircuitElement ) => e instanceof LightBulb && !e.highResistance, this.fixedCircuitElementLayer,
initializeCircuitElementType( ( e: CircuitElement ) => e instanceof LightBulb && !e.extreme, this.fixedCircuitElementLayer,
new PhetioGroup<CircuitElementNode, [ CircuitElement ]>( ( tandem: Tandem, circuitElement: CircuitElement ) => new CCKCLightBulbNode( screenView, this, circuitElement as LightBulb, this.model.isValueDepictionEnabledProperty, this.model.viewTypeProperty, tandem ),
() => [ this.circuit.lightBulbGroup.archetype ], {
phetioType: PhetioGroup.PhetioGroupIO( Node.NodeIO ),
tandem: tandem.createTandem( 'lightBulbNodeGroup' ),
supportsDynamicState: false
} ) );
initializeCircuitElementType( ( e: CircuitElement ) => e instanceof LightBulb && e.highResistance, this.fixedCircuitElementLayer,
initializeCircuitElementType( ( e: CircuitElement ) => e instanceof LightBulb && e.extreme, this.fixedCircuitElementLayer,
new PhetioGroup<CircuitElementNode, [ CircuitElement ]>( ( tandem: Tandem, circuitElement: CircuitElement ) => new CCKCLightBulbNode( screenView, this, circuitElement as LightBulb, this.model.isValueDepictionEnabledProperty, this.model.viewTypeProperty, tandem ),
() => [ this.circuit.lightBulbGroup.archetype ], {
phetioType: PhetioGroup.PhetioGroupIO( Node.NodeIO ),
tandem: circuit.includeLabElements ? tandem.createTandem( 'highResistanceLightBulbNodeGroup' ) : Tandem.OPT_OUT,
tandem: circuit.includeLabElements ? tandem.createTandem( 'extremeLightBulbNodeGroup' ) : Tandem.OPT_OUT,
supportsDynamicState: false
} ) );
initializeCircuitElementType( ( e: CircuitElement ) => e instanceof Resistor, this.fixedCircuitElementLayer,
Expand Down
6 changes: 3 additions & 3 deletions js/view/CustomLightBulbNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const BULB_IMAGE_SCALE = 0.125;

type SelfOptions = {
baseOnly?: boolean;
highResistance?: boolean;
extreme?: boolean;
real?: boolean;
scale?: number; // Note this differs from NodeOptions['scale']
};
Expand Down Expand Up @@ -57,14 +57,14 @@ export default class CustomLightBulbNode extends Node {

const options = optionize<CustomLightBulbNodeOptions, SelfOptions, NodeOptions>()( {
baseOnly: false,
highResistance: true,
extreme: true,
scale: CCKCConstants.BULB_SCALE,
real: false
}, providedOptions );

const baseOnly = options.baseOnly;

const selectedSocketImage = options.highResistance ? lightBulbFrontHigh_png :
const selectedSocketImage = options.extreme ? lightBulbFrontHigh_png :
options.real ? lightBulbFrontReal_png :
lightBulbFront_png;

Expand Down
Loading

0 comments on commit 6c608ff

Please sign in to comment.