Skip to content

Commit

Permalink
Apply WebStorm formatting, see phetsims/phet-info#155
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Feb 26, 2021
1 parent 2db069d commit 71e57b6
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 158 deletions.
14 changes: 7 additions & 7 deletions js/common/view/AreaDisplayNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ class AreaDisplayNode extends Node {
.concat( partitionedAreas.map( partitionedArea => partitionedArea.visibleProperty ) );
accessiblePartialMultilink = Property.multilink( properties, () => {
const activePartitionedAreas = areaDisplay.partitionedAreasProperty.value.filter( partitionedArea => partitionedArea.visibleProperty.value &&
partitionedArea.areaProperty.value !== null &&
partitionedArea.partitions.vertical.sizeProperty.value !== null &&
partitionedArea.partitions.horizontal.sizeProperty.value !== null );
partitionedArea.areaProperty.value !== null &&
partitionedArea.partitions.vertical.sizeProperty.value !== null &&
partitionedArea.partitions.horizontal.sizeProperty.value !== null );
const fillObject = {};
let fillString;
if ( activePartitionedAreas.length > 2 ||
Expand Down Expand Up @@ -210,10 +210,10 @@ class AreaDisplayNode extends Node {
updatedCallback: invalidateProductLabels,
arrayProperty: areaDisplay.partitionedAreasProperty,
createNode: partitionedArea => new PartialProductLabelNode(
partialProductsChoiceProperty,
new Property( partitionedArea ),
options.allowExponents
),
partialProductsChoiceProperty,
new Property( partitionedArea ),
options.allowExponents
),
getItemProperty: productLabel => productLabel.partitionedAreaProperty
} ) );

Expand Down
12 changes: 6 additions & 6 deletions js/common/view/calculation/CalculationLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ class CalculationLine {

// @private {OrientationPair.<Property.<Color>>}
this.orientedColorProperties = OrientationPair.create( orientation => new DerivedProperty( [
this.isActiveProperty,
colorProperties.get( orientation ),
AreaModelCommonColorProfile.calculationInactiveProperty
], ( isActive, activeColor, inactiveColor ) => isActive ? activeColor : inactiveColor, {
useDeepEquality: true
} ) );
this.isActiveProperty,
colorProperties.get( orientation ),
AreaModelCommonColorProfile.calculationInactiveProperty
], ( isActive, activeColor, inactiveColor ) => isActive ? activeColor : inactiveColor, {
useDeepEquality: true
} ) );
}

/**
Expand Down
36 changes: 18 additions & 18 deletions js/common/view/calculation/DistributionLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ class DistributionLine extends CalculationLine {
super( CalculationLine.DISTRIBUTION_LINE_INDEX, area.colorProperties, activeIndexProperty, allowExponents, isProportional );

this.node = this.sumGroup( _.flatten( verticalTerms.map( verticalTerm => horizontalTerms.map( horizontalTerm => {
const horizontalText = this.orientedTermText( Orientation.HORIZONTAL, horizontalTerm );
const verticalText = this.orientedTermText( Orientation.VERTICAL, verticalTerm );

// Proportional uses X-multiplication, see https://github.com/phetsims/area-model-common/issues/71
if ( isProportional ) {
return this.parentheses( this.multiplyX( verticalText, horizontalText ) );
}
else if ( allowExponents ) {
return this.group( [
this.parentheses( verticalText ),
this.parentheses( horizontalText )
], AreaModelCommonConstants.CALCULATION_PAREN_PAREN_PADDING );
}
// Generic Screen (non-proportional, no exponents) uses dot, see https://github.com/phetsims/area-model-common/issues/72
else {
return this.parentheses( this.multiplyX( verticalText, horizontalText ) );
}
} ) ) ) );
const horizontalText = this.orientedTermText( Orientation.HORIZONTAL, horizontalTerm );
const verticalText = this.orientedTermText( Orientation.VERTICAL, verticalTerm );

// Proportional uses X-multiplication, see https://github.com/phetsims/area-model-common/issues/71
if ( isProportional ) {
return this.parentheses( this.multiplyX( verticalText, horizontalText ) );
}
else if ( allowExponents ) {
return this.group( [
this.parentheses( verticalText ),
this.parentheses( horizontalText )
], AreaModelCommonConstants.CALCULATION_PAREN_PAREN_PADDING );
}
// Generic Screen (non-proportional, no exponents) uses dot, see https://github.com/phetsims/area-model-common/issues/72
else {
return this.parentheses( this.multiplyX( verticalText, horizontalText ) );
}
} ) ) ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion js/common/view/calculation/TotalsLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TotalsLine extends CalculationLine {
super( CalculationLine.TOTALS_LINE_INDEX, area.colorProperties, activeIndexProperty, allowExponents, isProportional );

const totalTexts = area.displayProperties.map( ( orientationTotal, orientation ) => orientationTotal.value ? this.orientedTermText( orientation, orientationTotal.value )
: this.orientedPlaceholderBox( orientation ) );
: this.orientedPlaceholderBox( orientation ) );

if ( allowExponents ) {
this.node = this.group( [
Expand Down
22 changes: 11 additions & 11 deletions js/game/model/GameAreaDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@ class GameAreaDisplay extends GenericAreaDisplay {
// hidden.
// NOTE: Overridden from the AreaDisplay version.
this.totalProperties = OrientationPair.create( orientation => new DynamicProperty( this.areaChallengeProperty, {
derive: areaChallenge => areaChallenge.totalProperties.get( orientation )
} ) );
derive: areaChallenge => areaChallenge.totalProperties.get( orientation )
} ) );

// @public {OrientationPair.<Property.<Array.<Entry>>>}
// Partition sizes. Inner values may be changed by the view client.

this.partitionSizeEntriesProperties = OrientationPair.create( orientation => new DerivedProperty( [ this.areaChallengeProperty ], areaChallenge => {
// If there's only one value on a side (and it's a given), there is no use showing a size here.
if ( areaChallenge.partitionSizeEntries.get( orientation ).length === 1 &&
areaChallenge.description.partitionTypes.get( orientation )[ 0 ] === EntryType.GIVEN ) {
return [ new Entry( null ) ];
}
else {
return areaChallenge.partitionSizeEntries.get( orientation );
}
} ) );
// If there's only one value on a side (and it's a given), there is no use showing a size here.
if ( areaChallenge.partitionSizeEntries.get( orientation ).length === 1 &&
areaChallenge.description.partitionTypes.get( orientation )[ 0 ] === EntryType.GIVEN ) {
return [ new Entry( null ) ];
}
else {
return areaChallenge.partitionSizeEntries.get( orientation );
}
} ) );

// @public {Property.<Array.<Array.<Entry>>} - Reference to a 2D array for the grid of partial products.
// First index is vertical (for the row), second is horizontal (for the column)
Expand Down
4 changes: 2 additions & 2 deletions js/game/view/GameAreaDisplayNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ class GameAreaDisplayNode extends Node {
_.range( 0, MAX_PARTITIONS ).forEach( horizontalIndex => {
_.range( 0, MAX_PARTITIONS ).forEach( verticalIndex => {
const entryProperty = new DerivedProperty( [ areaDisplay.partialProductEntriesProperty ], values => ( values[ verticalIndex ] && values[ verticalIndex ][ horizontalIndex ] )
? values[ verticalIndex ][ horizontalIndex ]
: new Entry( null ) );
? values[ verticalIndex ][ horizontalIndex ]
: new Entry( null ) );

const colorProperty = new DerivedProperty( [
entryProperty,
Expand Down
26 changes: 13 additions & 13 deletions js/game/view/GameAreaScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,22 @@ class GameAreaScreenView extends ScreenView {

const buttonSpacing = 30;
const levelButtons = model.levels.map( ( level, index ) => new LevelSelectionButton( levelIcons[ index ], level.scoreProperty, {
scoreDisplayConstructor: ScoreDisplayStars,
scoreDisplayOptions: {
numberOfStars: AreaModelCommonConstants.NUM_CHALLENGES,
perfectScore: AreaModelCommonConstants.PERFECT_SCORE
},
listener: () => {
model.selectLevel( level );
},
baseColor: level.colorProperty
} ) );
scoreDisplayConstructor: ScoreDisplayStars,
scoreDisplayOptions: {
numberOfStars: AreaModelCommonConstants.NUM_CHALLENGES,
perfectScore: AreaModelCommonConstants.PERFECT_SCORE
},
listener: () => {
model.selectLevel( level );
},
baseColor: level.colorProperty
} ) );

this.levelSelectionLayer.addChild( new VBox( {
children: _.chunk( levelButtons, 3 ).map( children => new HBox( {
children: children,
spacing: buttonSpacing
} ) ),
children: children,
spacing: buttonSpacing
} ) ),
spacing: buttonSpacing,
center: this.layoutBounds.center
} ) );
Expand Down
10 changes: 5 additions & 5 deletions js/generic/view/GenericAreaDisplayNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ class GenericAreaDisplayNode extends AreaDisplayNode {
this.labelLayer.addChild( new PoolableLayerNode( {
arrayProperty: areaDisplay.allPartitionsProperty,
createNode: partition => new PartitionSizeEditNode(
areaDisplay.activePartitionProperty,
new Property( partition ),
this.modelViewTransformProperty,
allowExponents
),
areaDisplay.activePartitionProperty,
new Property( partition ),
this.modelViewTransformProperty,
allowExponents
),
getItemProperty: editNode => editNode.partitionProperty
} ) );

Expand Down
112 changes: 56 additions & 56 deletions js/generic/view/GenericLayoutSelectionNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ class GenericLayoutSelectionNode extends Node {
width -= 1;

const comboBoxItems = GenericLayout.VALUES.map( layout => ( {
node: new HBox( {
children: [
createLayoutIcon( layout.size, 0.7 ),
new Text( layout.size.height + 'x' + layout.size.width, {
font: AreaModelCommonConstants.LAYOUT_FONT
} )
],
spacing: 14
} ),
value: layout
} ) );
node: new HBox( {
children: [
createLayoutIcon( layout.size, 0.7 ),
new Text( layout.size.height + 'x' + layout.size.width, {
font: AreaModelCommonConstants.LAYOUT_FONT
} )
],
spacing: 14
} ),
value: layout
} ) );

const maxItemHeight = Math.max.apply( Math, _.map( _.map( comboBoxItems, 'node' ), 'height' ) );
const itemMargin = 6;
Expand Down Expand Up @@ -110,54 +110,54 @@ class GenericLayoutSelectionNode extends Node {
const buttonSpacing = 12;
const buttonsNode = new VBox( {
children: [ 1, 2, 3 ].map( numVertical => new HBox( {
children: [ 1, 2, 3 ].map( numHorizontal => {
const layout = GenericLayout.fromValues( numHorizontal, numVertical );
// NOTE: Yes, it's weird this constant is here. We used to scale most things down by this amount. Now we
// want the same appearance (but without the scaling, because it was bad practice), so to get the icon to
// have the same appearance, a scale factor is needed.
const oldScale = 0.7;
const icon = createLayoutIcon( layout.size, oldScale * oldScale );
icon.scale( 1 / oldScale );
icon.pickable = false;
const cornerRadius = 3;
const background = Rectangle.roundedBounds( icon.bounds.dilated( cornerRadius ), cornerRadius, cornerRadius, {
cursor: 'pointer'
} );
background.touchArea = background.localBounds.dilated( buttonSpacing / 2 );
const listener = new FireListener( {
fire: () => {
genericLayoutProperty.value = layout;
visibleProperty.value = false; // hide
children: [ 1, 2, 3 ].map( numHorizontal => {
const layout = GenericLayout.fromValues( numHorizontal, numVertical );
// NOTE: Yes, it's weird this constant is here. We used to scale most things down by this amount. Now we
// want the same appearance (but without the scaling, because it was bad practice), so to get the icon to
// have the same appearance, a scale factor is needed.
const oldScale = 0.7;
const icon = createLayoutIcon( layout.size, oldScale * oldScale );
icon.scale( 1 / oldScale );
icon.pickable = false;
const cornerRadius = 3;
const background = Rectangle.roundedBounds( icon.bounds.dilated( cornerRadius ), cornerRadius, cornerRadius, {
cursor: 'pointer'
} );
background.touchArea = background.localBounds.dilated( buttonSpacing / 2 );
const listener = new FireListener( {
fire: () => {
genericLayoutProperty.value = layout;
visibleProperty.value = false; // hide
}
} );
background.stroke = new DerivedProperty(
[ genericLayoutProperty, AreaModelCommonColorProfile.radioBorderProperty ],
( currentLayout, highlightColor ) => {
if ( currentLayout === layout ) {
return highlightColor;
}
else {
return 'transparent';
}
} );
background.stroke = new DerivedProperty(
[ genericLayoutProperty, AreaModelCommonColorProfile.radioBorderProperty ],
( currentLayout, highlightColor ) => {
if ( currentLayout === layout ) {
return highlightColor;
}
else {
return 'transparent';
}
} );
background.fill = new DerivedProperty(
[ listener.isHoveringProperty, AreaModelCommonColorProfile.layoutHoverProperty ],
( isHovering, hoverColor ) => {
if ( isHovering ) {
return hoverColor;
}
else {
return 'transparent';
}
} );

return new Node( {
children: [ background, icon ],
inputListeners: [ listener ]
background.fill = new DerivedProperty(
[ listener.isHoveringProperty, AreaModelCommonColorProfile.layoutHoverProperty ],
( isHovering, hoverColor ) => {
if ( isHovering ) {
return hoverColor;
}
else {
return 'transparent';
}
} );
} ),
spacing: buttonSpacing
} ) ),

return new Node( {
children: [ background, icon ],
inputListeners: [ listener ]
} );
} ),
spacing: buttonSpacing
} ) ),
spacing: buttonSpacing
} );
const panelMargin = 20;
Expand Down
14 changes: 7 additions & 7 deletions js/generic/view/GenericPartitionedAreaNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ class GenericPartitionedAreaNode extends Rectangle {
rangeMultilinks = null;
if ( partitionedArea ) {
rangeMultilinks = partitionedArea.partitions.map( ( partition, orientation ) => Property.multilink(
[ partition.coordinateRangeProperty, modelViewTransformProperty ],
( range, modelViewTransform ) => {
if ( range !== null ) {
this[ orientation.rectCoordinate ] = modelViewTransform.modelToViewX( range.min );
this[ orientation.rectSize ] = modelViewTransform.modelToViewX( range.getLength() );
}
} ) );
[ partition.coordinateRangeProperty, modelViewTransformProperty ],
( range, modelViewTransform ) => {
if ( range !== null ) {
this[ orientation.rectCoordinate ] = modelViewTransform.modelToViewX( range.min );
this[ orientation.rectSize ] = modelViewTransform.modelToViewX( range.getLength() );
}
} ) );
}
} );
}
Expand Down
26 changes: 13 additions & 13 deletions js/generic/view/TermAccumulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ class TermAccumulator extends AbstractKeyAccumulator {

// @public {Property.<string>} - For display
this.richStringProperty = new DerivedProperty( [ this.accumulatedKeysProperty ], accumulatedKeys => accumulatedKeys.map( key => {
if ( key === KeyID.PLUS_MINUS ) {
return MathSymbols.UNARY_MINUS;
}
else if ( key === KeyID.X ) {
return AreaModelCommonConstants.X_VARIABLE_RICH_STRING;
}
else if ( key === KeyID.X_SQUARED ) {
return AreaModelCommonConstants.X_VARIABLE_RICH_STRING + '<sup>2</sup>';
}
else {
return key;
}
} ).join( '' ) );
if ( key === KeyID.PLUS_MINUS ) {
return MathSymbols.UNARY_MINUS;
}
else if ( key === KeyID.X ) {
return AreaModelCommonConstants.X_VARIABLE_RICH_STRING;
}
else if ( key === KeyID.X_SQUARED ) {
return AreaModelCommonConstants.X_VARIABLE_RICH_STRING + '<sup>2</sup>';
}
else {
return key;
}
} ).join( '' ) );

// @public {Property.<Term|null>} - The term used if 'enter' is pressed
this.termProperty = new DerivedProperty( [ this.accumulatedKeysProperty ], accumulatedKeys => {
Expand Down
Loading

0 comments on commit 71e57b6

Please sign in to comment.