From 682cecc015ad6d94b92c4e8f6dbff2b38ff497a2 Mon Sep 17 00:00:00 2001 From: pixelzoom Date: Tue, 15 Jun 2021 16:31:35 -0600 Subject: [PATCH] move duplicated bamboo options to FMWConstants.js --- js/common/FMWConstants.js | 15 +++++++++- js/common/view/WaveformChartNode.js | 29 ++++--------------- js/wavepacket/view/ComponentsChartNode.js | 18 +++--------- .../view/WavePacketAmplitudesChartNode.js | 12 ++------ js/wavepacket/view/WavePacketSumChartNode.js | 18 +++--------- 5 files changed, 31 insertions(+), 61 deletions(-) diff --git a/js/common/FMWConstants.js b/js/common/FMWConstants.js index a23c53a1..c19ab9ba 100644 --- a/js/common/FMWConstants.js +++ b/js/common/FMWConstants.js @@ -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 diff --git a/js/common/view/WaveformChartNode.js b/js/common/view/WaveformChartNode.js index a937297b..43cea442 100644 --- a/js/common/view/WaveformChartNode.js +++ b/js/common/view/WaveformChartNode.js @@ -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 { /** @@ -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 ); @@ -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 ); diff --git a/js/wavepacket/view/ComponentsChartNode.js b/js/wavepacket/view/ComponentsChartNode.js index 9b24d3c3..618fa58b 100644 --- a/js/wavepacket/view/ComponentsChartNode.js +++ b/js/wavepacket/view/ComponentsChartNode.js @@ -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 { /** @@ -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, @@ -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 ); @@ -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, diff --git a/js/wavepacket/view/WavePacketAmplitudesChartNode.js b/js/wavepacket/view/WavePacketAmplitudesChartNode.js index 642cb021..15b853b3 100644 --- a/js/wavepacket/view/WavePacketAmplitudesChartNode.js +++ b/js/wavepacket/view/WavePacketAmplitudesChartNode.js @@ -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 { /** @@ -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, @@ -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, diff --git a/js/wavepacket/view/WavePacketSumChartNode.js b/js/wavepacket/view/WavePacketSumChartNode.js index 4dd9da6f..d8f5dc1a 100644 --- a/js/wavepacket/view/WavePacketSumChartNode.js +++ b/js/wavepacket/view/WavePacketSumChartNode.js @@ -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 { /** @@ -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, @@ -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 ); @@ -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,