Skip to content

Commit

Permalink
move duplicated bamboo options to FMWConstants.js
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jun 15, 2021
1 parent 13063c3 commit 682cecc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 61 deletions.
15 changes: 14 additions & 1 deletion js/common/FMWConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,20 @@ const FMWConstants = {
// Charts
ZOOM_BUTTON_GROUP_SCALE: 0.75,
X_AXIS_LABEL_SPACING: 10, // horizontal space between chart rectangle and x-axis label
Y_AXIS_LABEL_SPACING: 36 // horizontal space between chart rectangle and y-axis label
Y_AXIS_LABEL_SPACING: 36, // horizontal space between chart rectangle and y-axis label
AXIS_OPTIONS: {
fill: FMWColorProfile.axisStrokeProperty,
stroke: null,
tailWidth: 1
},
GRID_LINE_OPTIONS: {
stroke: FMWColorProfile.chartGridLinesStrokeProperty,
lineWidth: 0.5
},
TICK_MARK_OPTIONS: {
edge: 'min',
extent: 6
}
};

// Verify some of the above constants
Expand Down
29 changes: 6 additions & 23 deletions js/common/view/WaveformChartNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,6 @@ import FMWZoomButtonGroup from './FMWZoomButtonGroup.js';
import XTickLabelSet from './XTickLabelSet.js';
import YTickLabelSet from './YTickLabelSet.js';

// constants
const AXIS_OPTIONS = {
fill: FMWColorProfile.axisStrokeProperty,
stroke: null,
tailWidth: 1
};

const GRID_LINE_OPTIONS = {
stroke: FMWColorProfile.chartGridLinesStrokeProperty,
lineWidth: 0.5
};

const TICK_MARK_OPTIONS = {
edge: 'min',
extent: 6
};

class WaveformChartNode extends Node {

/**
Expand Down Expand Up @@ -105,13 +88,13 @@ class WaveformChartNode extends Node {

// x axis (space or time) ---------------------------------------------------------

const xAxis = new AxisNode( chartTransform, Orientation.HORIZONTAL, AXIS_OPTIONS );
const xAxis = new AxisNode( chartTransform, Orientation.HORIZONTAL, FMWConstants.AXIS_OPTIONS );

const xGridLines = new GridLineSet( chartTransform, Orientation.HORIZONTAL,
xAxisDescriptionProperty.value.gridLineSpacing, GRID_LINE_OPTIONS );
xAxisDescriptionProperty.value.gridLineSpacing, FMWConstants.GRID_LINE_OPTIONS );

const xTickMarks = new TickMarkSet( chartTransform, Orientation.HORIZONTAL,
xAxisDescriptionProperty.value.tickMarkSpacing, TICK_MARK_OPTIONS );
xAxisDescriptionProperty.value.tickMarkSpacing, FMWConstants.TICK_MARK_OPTIONS );

const xTickLabels = new XTickLabelSet( chartTransform, xAxisDescriptionProperty.value.tickLabelSpacing, domainProperty,
xAxisTickLabelFormatProperty, L, T );
Expand Down Expand Up @@ -167,13 +150,13 @@ class WaveformChartNode extends Node {

// y axis (amplitude ) ---------------------------------------------------------

const yAxis = new AxisNode( chartTransform, Orientation.VERTICAL, AXIS_OPTIONS );
const yAxis = new AxisNode( chartTransform, Orientation.VERTICAL, FMWConstants.AXIS_OPTIONS );

const yGridLines = new GridLineSet( chartTransform, Orientation.VERTICAL,
yAxisDescriptionProperty.value.gridLineSpacing, GRID_LINE_OPTIONS );
yAxisDescriptionProperty.value.gridLineSpacing, FMWConstants.GRID_LINE_OPTIONS );

const yTickMarks = new TickMarkSet( chartTransform, Orientation.VERTICAL,
yAxisDescriptionProperty.value.tickMarkSpacing, TICK_MARK_OPTIONS );
yAxisDescriptionProperty.value.tickMarkSpacing, FMWConstants.TICK_MARK_OPTIONS );

const yTickLabels = new YTickLabelSet( chartTransform, yAxisDescriptionProperty.value.tickLabelSpacing );

Expand Down
18 changes: 4 additions & 14 deletions js/wavepacket/view/ComponentsChartNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@ import fourierMakingWaves from '../../fourierMakingWaves.js';
import fourierMakingWavesStrings from '../../fourierMakingWavesStrings.js';
import ComponentsChart from '../model/ComponentsChart.js';

//TODO duplicated in WaveformChartNode
const TICK_MARK_OPTIONS = {
edge: 'min',
extent: 6
};

//TODO duplicated in WaveformChartNode
const GRID_LINE_OPTIONS = {
stroke: FMWColorProfile.chartGridLinesStrokeProperty,
lineWidth: 0.5
};

class ComponentsChartNode extends Node {

/**
Expand Down Expand Up @@ -87,6 +75,7 @@ class ComponentsChartNode extends Node {

// x axis ---------------------------------------------------------

//TODO use AxisNode
const xAxis = new Line( 0, 0, options.transformOptions.viewWidth, 0, {
stroke: FMWColorProfile.axisStrokeProperty,
lineWidth: 1,
Expand All @@ -100,10 +89,10 @@ class ComponentsChartNode extends Node {
} );

const xGridLines = new GridLineSet( chartTransform, Orientation.HORIZONTAL,
xAxisDescriptionProperty.value.gridLineSpacing, GRID_LINE_OPTIONS );
xAxisDescriptionProperty.value.gridLineSpacing, FMWConstants.GRID_LINE_OPTIONS );

const xTickMarks = new TickMarkSet( chartTransform, Orientation.HORIZONTAL,
xAxisDescriptionProperty.value.tickMarkSpacing, TICK_MARK_OPTIONS );
xAxisDescriptionProperty.value.tickMarkSpacing, FMWConstants.TICK_MARK_OPTIONS );

const xTickLabels = new XTickLabelSet( chartTransform, xAxisDescriptionProperty.value.tickLabelSpacing,
domainProperty, new EnumerationProperty( TickLabelFormat, TickLabelFormat.NUMERIC ), L, T );
Expand Down Expand Up @@ -134,6 +123,7 @@ class ComponentsChartNode extends Node {

// y axis ---------------------------------------------------------

//TODO use AxisNode
const yAxis = new Line( 0, 0, 0, options.transformOptions.viewHeight, {
stroke: FMWColorProfile.axisStrokeProperty,
lineWidth: 1,
Expand Down
12 changes: 3 additions & 9 deletions js/wavepacket/view/WavePacketAmplitudesChartNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ import fourierMakingWavesStrings from '../../fourierMakingWavesStrings.js';
import WavePacketAmplitudesChart from '../model/WavePacketAmplitudesChart.js';
import ContinuousWaveformCheckbox from './ContinuousWaveformCheckbox.js';

// constants
//TODO duplicated in WaveformChartNode
const TICK_MARK_OPTIONS = {
edge: 'min',
extent: 6
};

//TODO placeholder
class WavePacketAmplitudesChartNode extends Node {

/**
Expand Down Expand Up @@ -75,12 +67,13 @@ class WavePacketAmplitudesChartNode extends Node {

// x axis ---------------------------------------------------------

//TODO use AxisNode
const xAxis = new Line( 0, 0, options.transformOptions.viewWidth, 0, {
stroke: FMWColorProfile.axisStrokeProperty,
lineWidth: 1
} );

const xTickMarks = new TickMarkSet( chartTransform, Orientation.HORIZONTAL, Math.PI, TICK_MARK_OPTIONS );
const xTickMarks = new TickMarkSet( chartTransform, Orientation.HORIZONTAL, Math.PI, FMWConstants.TICK_MARK_OPTIONS );

const xTickLabels = new LabelSet( chartTransform, Orientation.HORIZONTAL, 2 * Math.PI, {
createLabel: createXTickLabel,
Expand All @@ -95,6 +88,7 @@ class WavePacketAmplitudesChartNode extends Node {

// y axis ---------------------------------------------------------

//TODO use AxisNode
const yAxis = new Line( 0, 0, 0, options.transformOptions.viewHeight, {
stroke: FMWColorProfile.axisStrokeProperty,
lineWidth: 1,
Expand Down
18 changes: 4 additions & 14 deletions js/wavepacket/view/WavePacketSumChartNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@ import fourierMakingWavesStrings from '../../fourierMakingWavesStrings.js';
import WavePacketSumChart from '../model/WavePacketSumChart.js';
import WaveformEnvelopeCheckbox from './WaveformEnvelopeCheckbox.js';

//TODO duplicated in WaveformChartNode
const TICK_MARK_OPTIONS = {
edge: 'min',
extent: 6
};

//TODO duplicated in WaveformChartNode
const GRID_LINE_OPTIONS = {
stroke: FMWColorProfile.chartGridLinesStrokeProperty,
lineWidth: 0.5
};

class WavePacketSumChartNode extends Node {

/**
Expand Down Expand Up @@ -87,6 +75,7 @@ class WavePacketSumChartNode extends Node {

// x axis ---------------------------------------------------------

//TODO use AxisNode
const xAxis = new Line( 0, 0, options.transformOptions.viewWidth, 0, {
stroke: FMWColorProfile.axisStrokeProperty,
lineWidth: 1,
Expand All @@ -100,10 +89,10 @@ class WavePacketSumChartNode extends Node {
} );

const xGridLines = new GridLineSet( chartTransform, Orientation.HORIZONTAL,
xAxisDescriptionProperty.value.gridLineSpacing, GRID_LINE_OPTIONS );
xAxisDescriptionProperty.value.gridLineSpacing, FMWConstants.GRID_LINE_OPTIONS );

const xTickMarks = new TickMarkSet( chartTransform, Orientation.HORIZONTAL,
xAxisDescriptionProperty.value.tickMarkSpacing, TICK_MARK_OPTIONS );
xAxisDescriptionProperty.value.tickMarkSpacing, FMWConstants.TICK_MARK_OPTIONS );

const xTickLabels = new XTickLabelSet( chartTransform, xAxisDescriptionProperty.value.tickLabelSpacing,
domainProperty, new EnumerationProperty( TickLabelFormat, TickLabelFormat.NUMERIC ), L, T );
Expand Down Expand Up @@ -134,6 +123,7 @@ class WavePacketSumChartNode extends Node {

// y axis ---------------------------------------------------------

//TODO use AxisNode
const yAxis = new Line( 0, 0, 0, options.transformOptions.viewHeight, {
stroke: FMWColorProfile.axisStrokeProperty,
lineWidth: 1,
Expand Down

0 comments on commit 682cecc

Please sign in to comment.