Skip to content

Commit

Permalink
remove some more usages of Tandem.OPTIONAL, phetsims/tandem#289
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Jun 26, 2023
1 parent 4d0ad7d commit 951b861
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 65 deletions.
6 changes: 1 addition & 5 deletions js/ArrowNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { Shape } from '../../kite/js/imports.js';
import InstanceRegistry from '../../phet-core/js/documentation/InstanceRegistry.js';
import optionize from '../../phet-core/js/optionize.js';
import { Path, PathOptions } from '../../scenery/js/imports.js';
import Tandem from '../../tandem/js/Tandem.js';
import ArrowShape from './ArrowShape.js';
import sceneryPhet from './sceneryPhet.js';

Expand Down Expand Up @@ -52,10 +51,7 @@ export default class ArrowNode extends Path {
// Path options
fill: 'black',
stroke: 'black',
lineWidth: 1,

// phet-io
tandem: Tandem.OPTIONAL
lineWidth: 1
}, providedOptions );

// things you're likely to mess up, add more as needed
Expand Down
3 changes: 1 addition & 2 deletions js/BarrierRectangle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default class BarrierRectangle extends Plane {
const options = optionize<BarrierRectangleOptions, SelfOptions, PlaneOptions>()( {
fill: 'rgba( 0, 0, 0, 0.3 )',
pickable: true,
tandem: Tandem.OPTIONAL,
phetioReadOnly: true, // Disable controls in the PhET-iO Studio wrapper
phetioEventType: EventType.USER,
visiblePropertyOptions: {
Expand All @@ -45,7 +44,7 @@ export default class BarrierRectangle extends Plane {
modalNodeStack.lengthProperty.link( lengthListener );

this.addInputListener( new FireListener( {
tandem: options.tandem.createTandem( 'fireListener' ),
tandem: Tandem.OPT_OUT,
phetioReadOnly: options.phetioReadOnly,
fire() {
assert && assert( modalNodeStack.length > 0, 'There must be a Node in the stack to hide.' );
Expand Down
4 changes: 1 addition & 3 deletions js/LightRaysNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Utils from '../../dot/js/Utils.js';
import { Shape } from '../../kite/js/imports.js';
import optionize from '../../phet-core/js/optionize.js';
import { Path, PathOptions } from '../../scenery/js/imports.js';
import Tandem from '../../tandem/js/Tandem.js';
import sceneryPhet from './sceneryPhet.js';

// constants, these are specific to bulb images
Expand Down Expand Up @@ -56,8 +55,7 @@ export default class LightRaysNode extends Path {
shortRayLineWidth: 0.5, // for short rays

// PathOptions
stroke: 'yellow',
tandem: Tandem.OPTIONAL
stroke: 'yellow'
}, provideOptions );

super( null );
Expand Down
16 changes: 7 additions & 9 deletions js/MeasuringTapeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import StrictOmit from '../../phet-core/js/types/StrictOmit.js';
import StringUtils from '../../phetcommon/js/util/StringUtils.js';
import ModelViewTransform2 from '../../phetcommon/js/view/ModelViewTransform2.js';
import { Circle, DragListener, Font, Image, InteractiveHighlightingNode, KeyboardDragListener, Line, Node, NodeOptions, NodeTranslationOptions, Path, PressListenerEvent, Rectangle, TColor, Text } from '../../scenery/js/imports.js';
import Tandem from '../../tandem/js/Tandem.js';
import NumberIO from '../../tandem/js/types/NumberIO.js';
import measuringTape_png from '../images/measuringTape_png.js';
import PhetFont from './PhetFont.js';
Expand Down Expand Up @@ -158,8 +157,7 @@ class MeasuringTapeNode extends Node {
isTipDragBounded: true, // is the tip subject to dragBounds
interactive: true, // specifies whether the node adds its own input listeners. Setting this to false may be helpful in creating an icon.
baseDragStarted: _.noop, // called when the base drag starts
baseDragEnded: _.noop, // called when the base drag ends, for testing whether it has dropped into the toolbox
tandem: Tandem.OPTIONAL
baseDragEnded: _.noop // called when the base drag ends, for testing whether it has dropped into the toolbox
}, providedOptions );

super();
Expand Down Expand Up @@ -188,7 +186,7 @@ class MeasuringTapeNode extends Node {
this.measuredDistanceProperty = new DerivedProperty(
[ this.basePositionProperty, this.tipPositionProperty ],
( basePosition, tipPosition ) => basePosition.distance( tipPosition ), {
tandem: options.tandem.createTandem( 'measuredDistanceProperty' ),
tandem: options.tandem?.createTandem( 'measuredDistanceProperty' ),
phetioDocumentation: 'The distance measured by the measuring tape',
phetioValueType: NumberIO,
units: this.basePositionProperty.units
Expand Down Expand Up @@ -262,7 +260,7 @@ class MeasuringTapeNode extends Node {
units: units.name
} );
}, {
tandem: options.tandem.createTandem( 'readoutStringProperty' ),
tandem: options.tandem?.createTandem( 'readoutStringProperty' ),
phetioDocumentation: 'The text content of the readout on the measuring tape'
} );

Expand Down Expand Up @@ -341,7 +339,7 @@ class MeasuringTapeNode extends Node {

// Drag listener for base
this.baseDragListener = new DragListener( {
tandem: options.tandem.createTandem( 'baseDragListener' ),
tandem: options.tandem?.createTandem( 'baseDragListener' ),
start: event => {
baseStart();
const position = this.modelViewTransformProperty.value.modelToViewPosition( this.basePositionProperty.value );
Expand All @@ -366,7 +364,7 @@ class MeasuringTapeNode extends Node {

// Drag listener for base
const baseKeyboardDragListener = new KeyboardDragListener( {
tandem: options.tandem.createTandem( 'baseKeyboardDragListener' ),
tandem: options.tandem?.createTandem( 'baseKeyboardDragListener' ),
positionProperty: this.basePositionProperty,
transform: this.modelViewTransformProperty,
dragBoundsProperty: this.dragBoundsProperty,
Expand All @@ -387,7 +385,7 @@ class MeasuringTapeNode extends Node {

// Drag listener for tip
const tipDragListener = new DragListener( {
tandem: options.tandem.createTandem( 'tipDragListener' ),
tandem: options.tandem?.createTandem( 'tipDragListener' ),

start: event => {
this.moveToFront();
Expand All @@ -414,7 +412,7 @@ class MeasuringTapeNode extends Node {
tip.addInputListener( tipDragListener );

const tipKeyboardDragListener = new KeyboardDragListener( {
tandem: options.tandem.createTandem( 'tipKeyboardDragListener' ),
tandem: options.tandem?.createTandem( 'tipKeyboardDragListener' ),
positionProperty: this.tipPositionProperty,
dragBoundsProperty: options.isTipDragBounded ? this.dragBoundsProperty : null,
dragVelocity: KEYBOARD_DRAG_VELOCITY,
Expand Down
6 changes: 2 additions & 4 deletions js/NumberDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import StrictOmit from '../../phet-core/js/types/StrictOmit.js';
import StringUtils from '../../phetcommon/js/util/StringUtils.js';
import { Font, ManualConstraint, Node, NodeOptions, Rectangle, RichText, RichTextOptions, Text, TextOptions, TPaint } from '../../scenery/js/imports.js';
import SunConstants from '../../sun/js/SunConstants.js';
import Tandem from '../../tandem/js/Tandem.js';
import IOType from '../../tandem/js/types/IOType.js';
import MathSymbols from './MathSymbols.js';
import PhetFont from './PhetFont.js';
Expand Down Expand Up @@ -122,7 +121,6 @@ export default class NumberDisplay extends Node {
noValuePattern: null,

// phet-io
tandem: Tandem.OPTIONAL,
phetioType: NumberDisplay.NumberDisplayIO
}, providedOptions );

Expand Down Expand Up @@ -206,7 +204,7 @@ export default class NumberDisplay extends Node {

// value
const Constructor = options.useRichText ? RichText : Text;
const valueTextTandem = options.tandem.createTandem( 'valueText' );
const valueTextTandem = options.tandem?.createTandem( 'valueText' );
const valueStringProperty = new DerivedStringProperty( [
numberProperty,
noValuePatternProperty,
Expand All @@ -220,7 +218,7 @@ export default class NumberDisplay extends Node {
value: stringValue
} );
}, {
tandem: valueTextTandem.createTandem( Text.STRING_PROPERTY_TANDEM_NAME )
tandem: valueTextTandem?.createTandem( Text.STRING_PROPERTY_TANDEM_NAME )
} );

const valueTextOptions = combineOptions<TextOptions | RichTextOptions>( {}, options.textOptions, {
Expand Down
4 changes: 1 addition & 3 deletions js/OopsDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import optionize, { EmptySelfOptions } from '../../phet-core/js/optionize.js';
import StrictOmit from '../../phet-core/js/types/StrictOmit.js';
import { HBox, Image, Node, RichText, RichTextOptions } from '../../scenery/js/imports.js';
import Dialog, { DialogOptions } from '../../sun/js/Dialog.js';
import Tandem from '../../tandem/js/Tandem.js';
import IOType from '../../tandem/js/types/IOType.js';
import phetGirlWaggingFinger_png from '../images/phetGirlWaggingFinger_png.js';
import PhetFont from './PhetFont.js';
Expand Down Expand Up @@ -49,15 +48,14 @@ export default class OopsDialog extends Dialog {
bottomMargin: 20,

// phet-io
tandem: Tandem.OPTIONAL,
phetioType: OopsDialog.OopsDialogIO
}, providedOptions );

const text = new RichText( messageString, optionize<RichTextOptions, EmptySelfOptions, RichTextOptions>()( {
font: new PhetFont( 20 ),
maxWidth: 600,
maxHeight: 400,
tandem: options.tandem.createTandem( 'text' )
tandem: options.tandem?.createTandem( 'text' )
}, options.richTextOptions ) );

const iconNode = options.iconNode || new Image( phetGirlWaggingFinger_png, {
Expand Down
28 changes: 12 additions & 16 deletions js/ParametricSpringNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import Range from '../../dot/js/Range.js';
import Vector2 from '../../dot/js/Vector2.js';
import { Shape } from '../../kite/js/imports.js';
import InstanceRegistry from '../../phet-core/js/documentation/InstanceRegistry.js';
import { Circle, TColor, LinearGradient, Node, NodeOptions, Path, PathOptions } from '../../scenery/js/imports.js';
import Tandem from '../../tandem/js/Tandem.js';
import { Circle, LinearGradient, Node, NodeOptions, Path, PathOptions, TColor } from '../../scenery/js/imports.js';
import sceneryPhet from './sceneryPhet.js';
import optionize, { combineOptions } from '../../phet-core/js/optionize.js';
import PickOptional from '../../phet-core/js/types/PickOptional.js';
Expand Down Expand Up @@ -102,53 +101,50 @@ export default class ParametricSpringNode extends Node {
phase: Math.PI,
deltaPhase: Math.PI / 2,
xScale: 2.5,
boundsMethod: 'accurate', // method used to compute bounds for phet.scenery.Path components, see Path.boundsMethod

// phet-io
tandem: Tandem.OPTIONAL
boundsMethod: 'accurate' // method used to compute bounds for phet.scenery.Path components, see Path.boundsMethod
}, providedOptions );

super();

this.loopsProperty = new NumberProperty( options.loops, {
tandem: options.tandem.createTandem( 'loopsProperty' ),
tandem: options.tandem?.createTandem( 'loopsProperty' ),
numberType: 'Integer',
range: new Range( 1, Number.POSITIVE_INFINITY )
} );

this.radiusProperty = new NumberProperty( options.radius, {
tandem: options.tandem.createTandem( 'radiusProperty' ),
tandem: options.tandem?.createTandem( 'radiusProperty' ),
range: new Range( 0, Number.POSITIVE_INFINITY )
} );

this.aspectRatioProperty = new NumberProperty( options.aspectRatio, {
tandem: options.tandem.createTandem( 'aspectRatioProperty' ),
tandem: options.tandem?.createTandem( 'aspectRatioProperty' ),
range: new Range( 0, Number.POSITIVE_INFINITY )
} );

this.pointsPerLoopProperty = new NumberProperty( options.pointsPerLoop, {
tandem: options.tandem.createTandem( 'pointsPerLoopProperty' ),
tandem: options.tandem?.createTandem( 'pointsPerLoopProperty' ),
numberType: 'Integer',
range: new Range( 0, Number.POSITIVE_INFINITY )
} );

this.lineWidthProperty = new NumberProperty( options.lineWidth, {
tandem: options.tandem.createTandem( 'lineWidthProperty' ),
tandem: options.tandem?.createTandem( 'lineWidthProperty' ),
range: new Range( 0, Number.POSITIVE_INFINITY )
} );

this.phaseProperty = new NumberProperty( options.phase, {
tandem: options.tandem.createTandem( 'phaseProperty' ),
tandem: options.tandem?.createTandem( 'phaseProperty' ),
range: new Range( Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY )
} );

this.deltaPhaseProperty = new NumberProperty( options.deltaPhase, {
tandem: options.tandem.createTandem( 'deltaPhaseProperty' ),
tandem: options.tandem?.createTandem( 'deltaPhaseProperty' ),
range: new Range( Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY )
} );

this.xScaleProperty = new NumberProperty( options.xScale, {
tandem: options.tandem.createTandem( 'xScaleProperty' ),
tandem: options.tandem?.createTandem( 'xScaleProperty' ),
range: new Range( Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY )
} );

Expand All @@ -159,10 +155,10 @@ export default class ParametricSpringNode extends Node {
lineJoin: 'round'
};
const frontPath = new Path( null, combineOptions<PathOptions>( {
tandem: options.tandem.createTandem( 'frontPath' )
tandem: options.tandem?.createTandem( 'frontPath' )
}, pathOptions ) );
const backPath = new Path( null, combineOptions<PathOptions>( {
tandem: options.tandem.createTandem( 'backPath' )
tandem: options.tandem?.createTandem( 'backPath' )
}, pathOptions ) );

// Update the line width
Expand Down
4 changes: 1 addition & 3 deletions js/QuestionBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import StatusBar, { StatusBarOptions } from '../../scenery-phet/js/StatusBar.js'
import { Text, TextOptions } from '../../scenery/js/imports.js';
import Bounds2 from '../../dot/js/Bounds2.js';
import PhetFont from '../../scenery-phet/js/PhetFont.js';
import Tandem from '../../tandem/js/Tandem.js';
import TReadOnlyProperty from '../../axon/js/TReadOnlyProperty.js';
import Multilink from '../../axon/js/Multilink.js';

Expand All @@ -36,7 +35,6 @@ export default class QuestionBar extends StatusBar {
const options = optionize<QuestionBarOptions, SelfOptions, StatusBarOptions>()( {
floatToTop: true,
barHeight: 70,
tandem: Tandem.OPTIONAL,
textOptions: {
font: new PhetFont( {
weight: 'bold',
Expand All @@ -49,7 +47,7 @@ export default class QuestionBar extends StatusBar {
super( layoutBounds, visibleBoundsProperty, options );

const questionText = new Text( options.questionString, combineOptions<TextOptions>( {
tandem: options.tandem.createTandem( 'questionText' )
tandem: options.tandem?.createTandem( 'questionText' )
}, options.textOptions ) );

this.addChild( questionText );
Expand Down
6 changes: 2 additions & 4 deletions js/ThermometerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { Shape } from '../../kite/js/imports.js';
import InstanceRegistry from '../../phet-core/js/documentation/InstanceRegistry.js';
import optionize from '../../phet-core/js/optionize.js';
import { LinearGradient, Node, NodeOptions, Path, Rectangle, TColor } from '../../scenery/js/imports.js';
import Tandem from '../../tandem/js/Tandem.js';
import NullableIO from '../../tandem/js/types/NullableIO.js';
import NumberIO from '../../tandem/js/types/NumberIO.js';
import sceneryPhet from './sceneryPhet.js';
Expand Down Expand Up @@ -95,8 +94,7 @@ export default class ThermometerNode extends Node {
// all the default colors are shades of red
fluidMainColor: '#850e0e',
fluidHighlightColor: '#ff7575',
fluidRightSideColor: '#c41515',
tandem: Tandem.OPTIONAL
fluidRightSideColor: '#c41515'
}, providedOptions );

super();
Expand Down Expand Up @@ -243,7 +241,7 @@ export default class ThermometerNode extends Node {
return temp === null ? 0 :
thermometerRange.getNormalizedValue( Utils.clamp( temp, thermometerRange.min, thermometerRange.max ) ) * 100;
}, {
tandem: options.tandem.createTandem( 'percentProperty' ),
tandem: options.tandem?.createTandem( 'percentProperty' ),
phetioDocumentation: 'the percentage of the thermometer that is filled by the current temperature. If temperature is null, then percent will be 0',
phetioValueType: NullableIO( NumberIO )
} );
Expand Down
4 changes: 1 addition & 3 deletions js/WavelengthSpectrumNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import optionize from '../../phet-core/js/optionize.js';
import StrictOmit from '../../phet-core/js/types/StrictOmit.js';
import Tandem from '../../tandem/js/Tandem.js';
import sceneryPhet from './sceneryPhet.js';
import SpectrumNode, { SpectrumNodeOptions } from './SpectrumNode.js';
import VisibleColor from './VisibleColor.js';
Expand All @@ -28,8 +27,7 @@ export default class WavelengthSpectrumNode extends SpectrumNode {
const options = optionize<WavelengthSpectrumNodeOptions, SelfOptions, SpectrumNodeOptions>()( {
valueToColor: ( value: number ) => VisibleColor.wavelengthToColor( value ),
minWavelength: VisibleColor.MIN_WAVELENGTH,
maxWavelength: VisibleColor.MAX_WAVELENGTH,
tandem: Tandem.OPTIONAL
maxWavelength: VisibleColor.MAX_WAVELENGTH
}, providedOptions );

// validation
Expand Down
2 changes: 1 addition & 1 deletion js/demo/components/demoCapacitorNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function demoCapacitorNode( layoutBounds: Bounds2 ): Node {
const electricFieldVisibleProperty = new BooleanProperty( true );

const capacitorNode = new CapacitorNode( circuit, modelViewTransform, plateChargeVisibleProperty, electricFieldVisibleProperty, {
tandem: Tandem.OPTIONAL
tandem: Tandem.OPT_OUT
} );

const controls = new VBox( {
Expand Down
18 changes: 6 additions & 12 deletions js/demo/spinners/demoFineCoarseSpinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,30 @@ import NumberProperty from '../../../../axon/js/NumberProperty.js';
import Checkbox from '../../../../sun/js/Checkbox.js';
import Bounds2 from '../../../../dot/js/Bounds2.js';
import Range from '../../../../dot/js/Range.js';
import optionize, { EmptySelfOptions } from '../../../../phet-core/js/optionize.js';
import { Node, NodeOptions, Text, VBox } from '../../../../scenery/js/imports.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import { Node, Text, VBox } from '../../../../scenery/js/imports.js';
import FineCoarseSpinner from '../../FineCoarseSpinner.js';
import PhetFont from '../../PhetFont.js';
import { SunDemoOptions } from '../../../../sun/js/demo/DemosScreenView.js';

export default function demoFineCoarseSpinner( layoutBounds: Bounds2, providedOptions?: SunDemoOptions ): Node {

const options = optionize<NodeOptions, EmptySelfOptions, NodeOptions>()( {
tandem: Tandem.OPTIONAL
}, providedOptions );
export default function demoFineCoarseSpinner( layoutBounds: Bounds2, options?: SunDemoOptions ): Node {

const numberProperty = new NumberProperty( 0, {
range: new Range( 0, 100 ),
tandem: options.tandem.createTandem( 'numberProperty' )
tandem: options?.tandem?.createTandem( 'numberProperty' )
} );

const enabledProperty = new BooleanProperty( true, {
tandem: options.tandem.createTandem( 'enabledProperty' )
tandem: options?.tandem?.createTandem( 'enabledProperty' )
} );

const spinner = new FineCoarseSpinner( numberProperty, {
enabledProperty: enabledProperty,
tandem: options.tandem.createTandem( 'spinner' )
tandem: options?.tandem?.createTandem( 'spinner' )
} );

const checkbox = new Checkbox( enabledProperty, new Text( 'enabled', {
font: new PhetFont( 20 ),
tandem: options.tandem.createTandem( 'checkbox' )
tandem: options?.tandem?.createTandem( 'checkbox' )
} ) );

return new VBox( {
Expand Down

0 comments on commit 951b861

Please sign in to comment.