diff --git a/src/PamController/soundMedium/GlobalMedium.java b/src/PamController/soundMedium/GlobalMedium.java index 7aaacaf2..1c18c4cd 100644 --- a/src/PamController/soundMedium/GlobalMedium.java +++ b/src/PamController/soundMedium/GlobalMedium.java @@ -200,6 +200,50 @@ public class GlobalMedium { return zString; } + /** + * Get a string description of the dB reference for a power spectral density. + * @param currentMedium - the current medium. + * @return string of dB reference + */ + public static String getdBPSDString(SoundMedium currentMedium) { + String zString; + switch (currentMedium) { + case Air: + zString = "dB re 400\u00B5Pa\u00B2/Hz"; + break; + case Water: + zString = "dB re 1\u00B5Pa\u00B2/Hz"; + break; + default: + zString = "dB re 1\u00B5Pa\u00B2/Hz"; + break; + } + + return zString; + } + + /** + * Get a string description of the dB reference for a sound exposure level. + * @param currentMedium - the current medium. + * @return string of dB reference + */ + public static String getdBSELString(SoundMedium currentMedium) { + String zString; + switch (currentMedium) { + case Air: + zString = "dB re 400\u00B5Pa\u00B2s"; + break; + case Water: + zString = "dB re 1\u00B5Pa\u00B2s"; + break; + default: + zString = "dB re 1\u00B5Pa\u00B2s"; + break; + } + + return zString; + } + /** * Get the z coefficient value for displays. Height are always stored so * that +z points up (i.e. -g). In display height is input as depth as so must diff --git a/src/PamController/soundMedium/GlobalMediumManager.java b/src/PamController/soundMedium/GlobalMediumManager.java index 2fff40d5..267e10e1 100644 --- a/src/PamController/soundMedium/GlobalMediumManager.java +++ b/src/PamController/soundMedium/GlobalMediumManager.java @@ -136,6 +136,21 @@ public class GlobalMediumManager implements PamSettings { return GlobalMedium.getdBRefString(globalMediumParams.currentMedium); } + /** + * Get the string for the default dB reference unit for power spectral density e.g. dB re 1uPa^2/Hz. + * @return the string for dB values. + */ + public String getdBPSDString() { + return GlobalMedium.getdBPSDString(globalMediumParams.currentMedium); + } + + /** + * Get the string for the default dB reference unit for power spectral density e.g. dB re 1uPa^2/Hz. + * @return the string for dB values. + */ + public String getdBSELString() { + return GlobalMedium.getdBSELString(globalMediumParams.currentMedium); + } /** * Get the height coefficient value for displays. Heights are always stored so diff --git a/src/PamController/test/PamControllerTestHelper.java b/src/PamController/test/PamControllerTestHelper.java new file mode 100644 index 00000000..b1c20b71 --- /dev/null +++ b/src/PamController/test/PamControllerTestHelper.java @@ -0,0 +1,4 @@ +package PamController.test; + +public class PamControllerTestHelper { +} diff --git a/src/Spectrogram/SpectrogramDisplay.java b/src/Spectrogram/SpectrogramDisplay.java index ba6230b8..da718df8 100644 --- a/src/Spectrogram/SpectrogramDisplay.java +++ b/src/Spectrogram/SpectrogramDisplay.java @@ -809,7 +809,7 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett createColours(); timeAxis = new PamAxis(10, 0, imageWidth, 0, 0, - spectrogramParameters.displayLength, true, "seconds", "%3.1f"); + spectrogramParameters.displayLength, true, "Time (s)", "%3.1f"); spectrogramAxis.setNorthAxis(timeAxis); if (rangeSpinner != null) { @@ -817,13 +817,15 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett } double fScale = 1; + String westLabel = "Frequency (Hz)"; if (spectrogramParameters.frequencyLimits[1] > 2000) { fScale = 1000; + westLabel = "Frequency (kHz)"; } frequencyAxis = new PamAxis(0, 200, 0, 10, spectrogramParameters.frequencyLimits[0] / fScale, - spectrogramParameters.frequencyLimits[1] / fScale, true, "", + spectrogramParameters.frequencyLimits[1] / fScale, true, westLabel, null); frequencyAxis.setFractionalScale(true); frequencyAxis.setCrampLabels(true); @@ -1696,9 +1698,11 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett // setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 10)); setLayout(new BorderLayout()); add(new AmplitudeBar(), BorderLayout.CENTER); + + String label = String.format("PSD (%s)", PamController.getInstance().getGlobalMediumManager().getdBPSDString()); amplitudeAxis = new PamAxis(0, 200, 0, 10, spectrogramParameters.amplitudeLimits[0], - spectrogramParameters.amplitudeLimits[1], false, "", "%3.0f"); + spectrogramParameters.amplitudeLimits[1], false, label, "%3.0f"); setEastAxis(amplitudeAxis); } diff --git a/src/fftManager/FFTPluginPanelProvider.java b/src/fftManager/FFTPluginPanelProvider.java index f99b0f8b..2c0daa1b 100644 --- a/src/fftManager/FFTPluginPanelProvider.java +++ b/src/fftManager/FFTPluginPanelProvider.java @@ -136,7 +136,8 @@ public class FFTPluginPanelProvider implements DisplayPanelProvider { isViewer = PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW; setupPanel(); - westAxis = new PamAxis(0, 0, 1, 1, getScaleMin(), getScaleMax(), true, "PSD (dB re 1µPa²/Hz)", "%.0f"); + String label = String.format("PSD (%s)", PamController.getInstance().getGlobalMediumManager().getdBPSDString()); + westAxis = new PamAxis(0, 0, 1, 1, getScaleMin(), getScaleMax(), true, label, "%.0f"); westAxis.setInterval(20); //southAxis = new PamAxis(0, 0, 10, 10, 0, pamFFTProcess.getSampleRate()/2/1000, true, "kHz", "%.0f"); southAxis = new PamAxis(0, 0, 1, 1, 0, fftDataBlock.getSampleRate()/2/1000, false, "kHz", "%.0f"); diff --git a/src/noiseOneBand/OneBandControl.java b/src/noiseOneBand/OneBandControl.java index 0ef07104..2a7ec3e3 100644 --- a/src/noiseOneBand/OneBandControl.java +++ b/src/noiseOneBand/OneBandControl.java @@ -10,11 +10,8 @@ import javax.swing.JButton; import javax.swing.JMenuItem; import javax.swing.JPanel; -import PamController.PamControlledUnit; -import PamController.PamControlledUnitSettings; -import PamController.PamControllerInterface; -import PamController.PamSettingManager; -import PamController.PamSettings; +import PamController.*; +import PamController.soundMedium.GlobalMediumManager; import PamView.PamTabPanel; import noiseOneBand.offline.OneBandSummaryTask; import offlineProcessing.DataCopyTask; @@ -22,18 +19,16 @@ import offlineProcessing.OLProcessDialog; import offlineProcessing.OfflineTaskGroup; public class OneBandControl extends PamControlledUnit implements PamSettings { - + /** + * The number of measures taken by {@link OneBandControl}. + * See {@link OneBandControl#getMeasurementName(int)} for description and units of each measure. + */ public static final int NMEASURES = 4; - public static final String[] measureNames = { - "RMS (dB re 1µPa)", - "0-Peak (dB re 1µPa)", - "Peak-Peak (dB re 1µPa)", - "Integrated SEL (dB re 1µPa²s)" - }; - private OneBandProcess oneBandProcess; - private OneBandPulseProcess pulseProcess; + + private final OneBandProcess oneBandProcess; + private final OneBandPulseProcess pulseProcess; protected OneBandParameters oneBandParameters = new OneBandParameters(); - private OneBandTabPanel dBHtTabPanel; + private final OneBandTabPanel dBHtTabPanel; private OfflineTaskGroup offlineTaskGroup; private OLProcessDialog olProcessDialog; @@ -71,6 +66,32 @@ public class OneBandControl extends PamControlledUnit implements PamSettings { return dBHtTabPanel; } + /** + * Gets the measurement name for a given index (0 <= index < {@link OneBandControl#NMEASURES}). + * This requires access to the Global Medium Manager to report on the correct units. + * + * @param index The index of the measure. + * @return The text representation of the relevant measure, including units. + */ + public static String getMeasurementName(int index) { + GlobalMediumManager gmm = PamController.getInstance().getGlobalMediumManager(); + String dbRef = gmm.getdBRefString(); + String selDbRef = gmm.getdBSELString(); + + switch (index) { + case 0: + return String.format("RMS (%s)", dbRef); + case 1: + return String.format("0-Peak (%s)", dbRef); + case 2: + return String.format("Peak-Peak (%s)", dbRef); + case 3: + return String.format("Integrated SEL (%s)", selDbRef); + default: + throw new IllegalStateException("Unexpected value: " + index); + } + } + /* (non-Javadoc) * @see PamController.PamControlledUnit#createDetectionMenu(java.awt.Frame) */ diff --git a/src/noiseOneBand/OneBandDisplayDialog.java b/src/noiseOneBand/OneBandDisplayDialog.java index f561b5dd..7d972aa2 100644 --- a/src/noiseOneBand/OneBandDisplayDialog.java +++ b/src/noiseOneBand/OneBandDisplayDialog.java @@ -91,7 +91,7 @@ public class OneBandDisplayDialog extends PamDialog { for (int i = 0; i < OneBandControl.NMEASURES; i++) { c.gridx = 0; c.gridy++; - addComponent(symPanel, showMeasure[i] = new JCheckBox("Show " + OneBandControl.measureNames[i]), c); + addComponent(symPanel, showMeasure[i] = new JCheckBox("Show " + OneBandControl.getMeasurementName(i)), c); } tabPane.add(symPanel, "Symbols"); diff --git a/src/noiseOneBand/OneBandDisplayPanel.java b/src/noiseOneBand/OneBandDisplayPanel.java index 85441bdb..b4bab28d 100644 --- a/src/noiseOneBand/OneBandDisplayPanel.java +++ b/src/noiseOneBand/OneBandDisplayPanel.java @@ -508,7 +508,7 @@ public class OneBandDisplayPanel { OneBandDisplayParams params = getDisplayParams(panelType); for (int i = OneBandControl.NMEASURES-1; i >= 0; i--) { if ((params.showWhat & 1<