This commit is contained in:
Douglas Gillespie 2024-11-02 17:31:54 +00:00
commit 4ec3b42d2b
30 changed files with 251 additions and 62 deletions

5
.gitignore vendored
View File

@ -19,6 +19,7 @@
*.nar *.nar
*.ear *.ear
*.zip *.zip
!src/test/**/*.zip
*.tar.gz *.tar.gz
*.rar *.rar
*.dll *.dll
@ -37,6 +38,10 @@ bin/
.classpath .classpath
target/WMM.COF target/WMM.COF
# IntellIJ
.idea
# Eclipse
settings.xml settings.xml
.classpath .classpath
.classpath .classpath

45
pom.xml
View File

@ -182,7 +182,15 @@
--> -->
</executions> </executions>
</plugin> </plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
<!-- Plugin which creates a .dmg file for MacOS. <!-- Plugin which creates a .dmg file for MacOS.
<plugin> <plugin>
@ -228,7 +236,6 @@
</execution> </execution>
</executions> </executions>
</plugin> --> </plugin> -->
</plugins> </plugins>
@ -325,16 +332,6 @@
<url>https://nexus.bedatadriven.com/content/groups/public/</url> <url>https://nexus.bedatadriven.com/content/groups/public/</url>
</repository> </repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>talan</id>
<name>talan</name>
<url>https://nexus.talanlabs.com/content/repositories/releases/</url>
</repository>
<repository> <repository>
<id>central</id> <id>central</id>
<url>https://repo1.maven.org/maven2</url> <url>https://repo1.maven.org/maven2</url>
@ -344,6 +341,17 @@
<!-- ************************* Dependencies ************************************* --> <!-- ************************* Dependencies ************************************* -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.11.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies> <dependencies>
<!--jpam project - utilities --> <!--jpam project - utilities -->
@ -351,6 +359,13 @@
<groupId>io.github.macster110</groupId> <groupId>io.github.macster110</groupId>
<artifactId>jpamutils</artifactId> <artifactId>jpamutils</artifactId>
<version>0.0.59d</version> <version>0.0.59d</version>
<exclusions>
<exclusion>
<!-- com.github.psambit9791:wavfile:jar:0.1 pulls in various junit dependencies which breaks our own testing -->
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<!--jpam project - Deep learning java library --> <!--jpam project - Deep learning java library -->
@ -1049,5 +1064,11 @@
<!-- Test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -200,6 +200,50 @@ public class GlobalMedium {
return zString; 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 * 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 * that +z points up (i.e. -g). In display height is input as depth as so must

View File

@ -136,6 +136,21 @@ public class GlobalMediumManager implements PamSettings {
return GlobalMedium.getdBRefString(globalMediumParams.currentMedium); 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 * Get the height coefficient value for displays. Heights are always stored so

View File

@ -809,7 +809,7 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett
createColours(); createColours();
timeAxis = new PamAxis(10, 0, imageWidth, 0, 0, timeAxis = new PamAxis(10, 0, imageWidth, 0, 0,
spectrogramParameters.displayLength, true, "seconds", "%3.1f"); spectrogramParameters.displayLength, true, "Time (s)", "%3.1f");
spectrogramAxis.setNorthAxis(timeAxis); spectrogramAxis.setNorthAxis(timeAxis);
if (rangeSpinner != null) { if (rangeSpinner != null) {
@ -817,13 +817,15 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett
} }
double fScale = 1; double fScale = 1;
String westLabel = "Frequency (Hz)";
if (spectrogramParameters.frequencyLimits[1] > 2000) { if (spectrogramParameters.frequencyLimits[1] > 2000) {
fScale = 1000; fScale = 1000;
westLabel = "Frequency (kHz)";
} }
frequencyAxis = new PamAxis(0, 200, 0, 10, frequencyAxis = new PamAxis(0, 200, 0, 10,
spectrogramParameters.frequencyLimits[0] / fScale, spectrogramParameters.frequencyLimits[0] / fScale,
spectrogramParameters.frequencyLimits[1] / fScale, true, "", spectrogramParameters.frequencyLimits[1] / fScale, true, westLabel,
null); null);
frequencyAxis.setFractionalScale(true); frequencyAxis.setFractionalScale(true);
frequencyAxis.setCrampLabels(true); frequencyAxis.setCrampLabels(true);
@ -1696,9 +1698,11 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett
// setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 10)); // setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 10));
setLayout(new BorderLayout()); setLayout(new BorderLayout());
add(new AmplitudeBar(), BorderLayout.CENTER); add(new AmplitudeBar(), BorderLayout.CENTER);
String label = String.format("PSD (%s)", PamController.getInstance().getGlobalMediumManager().getdBPSDString());
amplitudeAxis = new PamAxis(0, 200, 0, 10, amplitudeAxis = new PamAxis(0, 200, 0, 10,
spectrogramParameters.amplitudeLimits[0], spectrogramParameters.amplitudeLimits[0],
spectrogramParameters.amplitudeLimits[1], false, "", "%3.0f"); spectrogramParameters.amplitudeLimits[1], false, label, "%3.0f");
setEastAxis(amplitudeAxis); setEastAxis(amplitudeAxis);
} }

View File

@ -21,7 +21,7 @@ import generalDatabase.SQLLoggingAddon;
* @see SoloAnnotationType * @see SoloAnnotationType
* *
*/ */
public abstract class DataAnnotationType<TDataAnnotation extends DataAnnotation> { public abstract class DataAnnotationType<TDataAnnotation extends DataAnnotation<?>> {
public abstract String getAnnotationName(); public abstract String getAnnotationName();

View File

@ -5,7 +5,7 @@ import PamguardMVC.dataSelector.DataSelectorCreator;
import annotation.DataAnnotation; import annotation.DataAnnotation;
import annotation.DataAnnotationType; import annotation.DataAnnotationType;
public abstract class AnnotationDataSelCreator<TDataAnnotation extends DataAnnotation> extends DataSelectorCreator { public abstract class AnnotationDataSelCreator<TDataAnnotation extends DataAnnotation<?>> extends DataSelectorCreator {
private DataAnnotationType<TDataAnnotation> dataAnnotationType; private DataAnnotationType<TDataAnnotation> dataAnnotationType;

View File

@ -7,7 +7,7 @@ import PamguardMVC.dataSelector.DataSelector;
import annotation.DataAnnotation; import annotation.DataAnnotation;
import annotation.DataAnnotationType; import annotation.DataAnnotationType;
public abstract class AnnotationDataSelector<TDataAnnotation extends DataAnnotation> extends DataSelector { public abstract class AnnotationDataSelector<TDataAnnotation extends DataAnnotation<?>> extends DataSelector {
private DataAnnotationType<TDataAnnotation> annotationType; private DataAnnotationType<TDataAnnotation> annotationType;

View File

@ -8,7 +8,7 @@ import annotation.DataAnnotation;
import annotation.DataAnnotationType; import annotation.DataAnnotationType;
import pamViewFX.fxSettingsPanes.DynamicSettingsPane; import pamViewFX.fxSettingsPanes.DynamicSettingsPane;
public abstract class ScalarDataSelector<TDataAnnotation extends DataAnnotation> extends AnnotationDataSelector<TDataAnnotation> { public abstract class ScalarDataSelector<TDataAnnotation extends DataAnnotation<?>> extends AnnotationDataSelector<TDataAnnotation> {
/** /**
* @return the scalarDataParams * @return the scalarDataParams

View File

@ -3,11 +3,11 @@ package annotation.string;
import annotation.DataAnnotation; import annotation.DataAnnotation;
import annotation.DataAnnotationType; import annotation.DataAnnotationType;
public class StringAnnotation extends DataAnnotation { public class StringAnnotation<T extends DataAnnotationType<?>> extends DataAnnotation<T> {
private String string; private String string;
public StringAnnotation(DataAnnotationType dataAnnotationType) { public StringAnnotation(T dataAnnotationType) {
super(dataAnnotationType); super(dataAnnotationType);
} }

View File

@ -13,7 +13,7 @@ import annotation.handler.AnnotationOptions;
* @author Doug Gillespie * @author Doug Gillespie
* *
*/ */
public class StringAnnotationType extends DataAnnotationType<StringAnnotation> { public class StringAnnotationType extends DataAnnotationType<StringAnnotation<?>> {
private String annotationName; private String annotationName;
private StringSQLLogging sqlAddon; private StringSQLLogging sqlAddon;

View File

@ -4,11 +4,11 @@ import PamUtils.PamCalendar;
import annotation.DataAnnotation; import annotation.DataAnnotation;
import annotation.DataAnnotationType; import annotation.DataAnnotationType;
public class TimestampAnnotation extends DataAnnotation { public class TimestampAnnotation<T extends DataAnnotationType<?>> extends DataAnnotation<T> {
private long timestamp; private long timestamp;
public TimestampAnnotation(DataAnnotationType dataAnnotationType) { public TimestampAnnotation(T dataAnnotationType) {
super(dataAnnotationType); super(dataAnnotationType);
} }

View File

@ -12,7 +12,7 @@ import annotation.DataAnnotationType;
* @author Doug Gillespie * @author Doug Gillespie
* *
*/ */
public class TimestampAnnotationType extends DataAnnotationType<TimestampAnnotation> { public class TimestampAnnotationType extends DataAnnotationType<TimestampAnnotation<?>> {
private String annotationName; private String annotationName;
private TimestampSQLLogging sqlAddon; private TimestampSQLLogging sqlAddon;

View File

@ -3,14 +3,14 @@ package annotation.userforms;
import annotation.DataAnnotation; import annotation.DataAnnotation;
import annotation.DataAnnotationType; import annotation.DataAnnotationType;
public class UserFormAnnotation extends DataAnnotation { public class UserFormAnnotation<T extends DataAnnotationType<?>> extends DataAnnotation<T> {
/** /**
* Data extracted from the logger form. * Data extracted from the logger form.
*/ */
private Object[] loggerFormData; private Object[] loggerFormData;
public UserFormAnnotation(DataAnnotationType dataAnnotationType, Object[] loggerFormData) { public UserFormAnnotation(T dataAnnotationType, Object[] loggerFormData) {
super(dataAnnotationType); super(dataAnnotationType);
this.setLoggerFormData(loggerFormData); this.setLoggerFormData(loggerFormData);
} }

View File

@ -17,7 +17,7 @@ import loggerForms.FormDescription;
import loggerForms.FormsControl; import loggerForms.FormsControl;
import loggerForms.LoggerForm; import loggerForms.LoggerForm;
public class UserFormAnnotationType extends DataAnnotationType<UserFormAnnotation> { public class UserFormAnnotationType extends DataAnnotationType<UserFormAnnotation<?>> {
private UserFormAnnotationOptions userFormAnnotationOptions; private UserFormAnnotationOptions userFormAnnotationOptions;
@ -201,7 +201,7 @@ public class UserFormAnnotationType extends DataAnnotationType<UserFormAnnotatio
} }
@Override @Override
public AnnotationBinaryHandler<UserFormAnnotation> getBinaryHandler() { public AnnotationBinaryHandler<UserFormAnnotation<?>> getBinaryHandler() {
if (userFormBinaryHandler == null) { if (userFormBinaryHandler == null) {
synchronized (this) { synchronized (this) {
if (userFormBinaryHandler == null) { if (userFormBinaryHandler == null) {

View File

@ -42,7 +42,7 @@ public class DbHtDisplayDialog extends PamDialog {
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
JPanel scalePanel = new JPanel(new GridBagLayout()); JPanel scalePanel = new JPanel(new GridBagLayout());
scalePanel.setBorder(new TitledBorder("Amlitude Scale")); scalePanel.setBorder(new TitledBorder("Amplitude Scale"));
GridBagConstraints c = new PamGridBagContraints(); GridBagConstraints c = new PamGridBagContraints();
c.gridwidth = 3; c.gridwidth = 3;
addComponent(scalePanel, showGrid = new JCheckBox("Show Grid"), c); addComponent(scalePanel, showGrid = new JCheckBox("Show Grid"), c);

View File

@ -16,7 +16,7 @@ import us.hebi.matlab.mat.types.Struct;
* @author Jamie Macaulay * @author Jamie Macaulay
* *
*/ */
public class MLCPODExport extends MLDataUnitExport<PamDataUnit>{ public class MLCPODExport extends MLDataUnitExport<PamDataUnit<?, ?>>{
@Override @Override
public Struct addDetectionSpecificFields(Struct mlStruct, int index, PamDataUnit dataUnit) { public Struct addDetectionSpecificFields(Struct mlStruct, int index, PamDataUnit dataUnit) {

View File

@ -14,7 +14,7 @@ import us.hebi.matlab.mat.types.Struct;
* @author Jamie Macaulay * @author Jamie Macaulay
* *
*/ */
public class MLRawExport extends MLDataUnitExport<PamDataUnit>{ public class MLRawExport extends MLDataUnitExport<PamDataUnit<?,?>>{
@Override @Override
public Struct addDetectionSpecificFields(Struct mlStruct, int index, PamDataUnit dataUnit) { public Struct addDetectionSpecificFields(Struct mlStruct, int index, PamDataUnit dataUnit) {

View File

@ -10,7 +10,7 @@ import cpod.CPODClick;
import export.MLExport.MLCPODExport; import export.MLExport.MLCPODExport;
public class RCPODExport extends RDataUnitExport<PamDataUnit> { public class RCPODExport extends RDataUnitExport<PamDataUnit<?, ?>> {
@Override @Override
public NamedBuilder addDetectionSpecificFields(NamedBuilder rData, PamDataUnit dataUnit, int index) { public NamedBuilder addDetectionSpecificFields(NamedBuilder rData, PamDataUnit dataUnit, int index) {

View File

@ -10,7 +10,7 @@ import org.renjin.sexp.ListVector.NamedBuilder;
import clickDetector.ClickDetection; import clickDetector.ClickDetection;
public class RRawExport extends RDataUnitExport<PamDataUnit> { public class RRawExport extends RDataUnitExport<PamDataUnit<?,?>> {
@Override @Override
public NamedBuilder addDetectionSpecificFields(NamedBuilder rData, PamDataUnit dataUnit, int index) { public NamedBuilder addDetectionSpecificFields(NamedBuilder rData, PamDataUnit dataUnit, int index) {

View File

@ -9,7 +9,7 @@ import clickDetector.ClickDetection;
* @author Jamie Macaulay * @author Jamie Macaulay
* *
*/ */
public class RawHolderWavExport extends WavDataUnitExport<PamDataUnit> { public class RawHolderWavExport extends WavDataUnitExport<PamDataUnit<?,?>> {
@Override @Override
public double[][] getWavClip(PamDataUnit dataUnit) { public double[][] getWavClip(PamDataUnit dataUnit) {

View File

@ -136,7 +136,8 @@ public class FFTPluginPanelProvider implements DisplayPanelProvider {
isViewer = PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW; isViewer = PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW;
setupPanel(); setupPanel();
westAxis = new PamAxis(0, 0, 1, 1, getScaleMin(), getScaleMax(), true, "dB", "%.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); westAxis.setInterval(20);
//southAxis = new PamAxis(0, 0, 10, 10, 0, pamFFTProcess.getSampleRate()/2/1000, true, "kHz", "%.0f"); //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"); southAxis = new PamAxis(0, 0, 1, 1, 0, fftDataBlock.getSampleRate()/2/1000, false, "kHz", "%.0f");

View File

@ -10,11 +10,8 @@ import javax.swing.JButton;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import javax.swing.JPanel; import javax.swing.JPanel;
import PamController.PamControlledUnit; import PamController.*;
import PamController.PamControlledUnitSettings; import PamController.soundMedium.GlobalMediumManager;
import PamController.PamControllerInterface;
import PamController.PamSettingManager;
import PamController.PamSettings;
import PamView.PamTabPanel; import PamView.PamTabPanel;
import noiseOneBand.offline.OneBandSummaryTask; import noiseOneBand.offline.OneBandSummaryTask;
import offlineProcessing.DataCopyTask; import offlineProcessing.DataCopyTask;
@ -22,13 +19,16 @@ import offlineProcessing.OLProcessDialog;
import offlineProcessing.OfflineTaskGroup; import offlineProcessing.OfflineTaskGroup;
public class OneBandControl extends PamControlledUnit implements PamSettings { 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 int NMEASURES = 4;
public static final String[] measureNames = {"RMS", "0-Peak", "Peak-Peak", "Integrated SEL"};
private OneBandProcess oneBandProcess; private final OneBandProcess oneBandProcess;
private OneBandPulseProcess pulseProcess; private final OneBandPulseProcess pulseProcess;
protected OneBandParameters oneBandParameters = new OneBandParameters(); protected OneBandParameters oneBandParameters = new OneBandParameters();
private OneBandTabPanel dBHtTabPanel; private final OneBandTabPanel dBHtTabPanel;
private OfflineTaskGroup offlineTaskGroup; private OfflineTaskGroup offlineTaskGroup;
private OLProcessDialog olProcessDialog; private OLProcessDialog olProcessDialog;
@ -66,6 +66,32 @@ public class OneBandControl extends PamControlledUnit implements PamSettings {
return dBHtTabPanel; 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) /* (non-Javadoc)
* @see PamController.PamControlledUnit#createDetectionMenu(java.awt.Frame) * @see PamController.PamControlledUnit#createDetectionMenu(java.awt.Frame)
*/ */

View File

@ -48,7 +48,7 @@ public class OneBandDisplayDialog extends PamDialog {
mainPanel.add(tabPane); mainPanel.add(tabPane);
JPanel scalePanel = new JPanel(new GridBagLayout()); JPanel scalePanel = new JPanel(new GridBagLayout());
scalePanel.setBorder(new TitledBorder("Amlitude Scale")); scalePanel.setBorder(new TitledBorder("Amplitude Scale"));
GridBagConstraints c = new PamGridBagContraints(); GridBagConstraints c = new PamGridBagContraints();
c.gridwidth = 3; c.gridwidth = 3;
addComponent(scalePanel, showGrid = new JCheckBox("Show Grid"), c); addComponent(scalePanel, showGrid = new JCheckBox("Show Grid"), c);
@ -62,14 +62,14 @@ public class OneBandDisplayDialog extends PamDialog {
c.gridx++; c.gridx++;
addComponent(scalePanel, minAmp = new JTextField(5), c); addComponent(scalePanel, minAmp = new JTextField(5), c);
c.gridx++; c.gridx++;
addComponent(scalePanel, new JLabel(" dB re 1\u03BCPa ", SwingConstants.LEFT), c); addComponent(scalePanel, new JLabel(" dB", SwingConstants.LEFT), c);
c.gridx = 0; c.gridx = 0;
c.gridy++; c.gridy++;
addComponent(scalePanel, new JLabel("Max ", SwingConstants.RIGHT), c); addComponent(scalePanel, new JLabel("Max ", SwingConstants.RIGHT), c);
c.gridx++; c.gridx++;
addComponent(scalePanel, maxAmp = new JTextField(5), c); addComponent(scalePanel, maxAmp = new JTextField(5), c);
c.gridx++; c.gridx++;
addComponent(scalePanel, new JLabel(" dB re 1\u03BCPa ", SwingConstants.LEFT), c); addComponent(scalePanel, new JLabel(" dB", SwingConstants.LEFT), c);
tabPane.add(scalePanel, "Scale"); tabPane.add(scalePanel, "Scale");
@ -91,7 +91,7 @@ public class OneBandDisplayDialog extends PamDialog {
for (int i = 0; i < OneBandControl.NMEASURES; i++) { for (int i = 0; i < OneBandControl.NMEASURES; i++) {
c.gridx = 0; c.gridx = 0;
c.gridy++; 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"); tabPane.add(symPanel, "Symbols");

View File

@ -508,7 +508,7 @@ public class OneBandDisplayPanel {
OneBandDisplayParams params = getDisplayParams(panelType); OneBandDisplayParams params = getDisplayParams(panelType);
for (int i = OneBandControl.NMEASURES-1; i >= 0; i--) { for (int i = OneBandControl.NMEASURES-1; i >= 0; i--) {
if ((params.showWhat & 1<<i) != 0) { if ((params.showWhat & 1<<i) != 0) {
keyPanel.add(new SymbolKeyItem(measureSymbols[i], OneBandControl.measureNames[i])); keyPanel.add(new SymbolKeyItem(measureSymbols[i], OneBandControl.getMeasurementName(i)));
} }
} }
if (displayParams.colourByChannel) { if (displayParams.colourByChannel) {

View File

@ -8,6 +8,7 @@ import javax.swing.JPanel;
import javax.swing.JRadioButton; import javax.swing.JRadioButton;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import PamController.soundMedium.GlobalMediumManager;
import PamView.dialog.PamDialog; import PamView.dialog.PamDialog;
import noiseOneBand.OneBandAlarmParameters; import noiseOneBand.OneBandAlarmParameters;
import noiseOneBand.OneBandControl; import noiseOneBand.OneBandControl;
@ -28,7 +29,7 @@ public class OneBandAlarmParamsDialog extends PamDialog {
mainPanel.setBorder(new TitledBorder("Select measure")); mainPanel.setBorder(new TitledBorder("Select measure"));
ButtonGroup bg = new ButtonGroup(); ButtonGroup bg = new ButtonGroup();
for (int i = 0; i < OneBandControl.NMEASURES; i++) { for (int i = 0; i < OneBandControl.NMEASURES; i++) {
measures[i] = new JRadioButton(OneBandControl.measureNames[i]); measures[i] = new JRadioButton(OneBandControl.getMeasurementName(i));
bg.add(measures[i]); bg.add(measures[i]);
mainPanel.add(measures[i]); mainPanel.add(measures[i]);
} }

View File

@ -1,8 +1,8 @@
package test.export; package test.export;
import static org.junit.jupiter.api.Assertions.assertEquals; import test.helper.PamControllerTestHelper;
import clickDetector.ClickControl;
import clickDetector.ClickDetector;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import clickDetector.ClickDetection; import clickDetector.ClickDetection;
@ -18,14 +18,16 @@ public class ExportTest {
* Test exporting detections to mat files. * Test exporting detections to mat files.
*/ */
@Test @Test
public void matFileTest() { public void matFileTest() throws Exception {
PamControllerTestHelper.InitializePamControllerForTesting();
System.out.println("Matched template classifier test: match corr"); System.out.println("Matched template classifier test: match corr");
//create a list of click detections. //create a list of click detections.
ClickDetection clickDetection = new ClickDetection(0, 0, 0, null, null, 0); ClickControl control = new ClickControl("name");
ClickDetector detector = new ClickDetector(control);
ClickDetection clickDetection = new ClickDetection(0, 0, 0, detector, null, 0);
//now open the mat file and check that we have all the data from these click detections. //now open the mat file and check that we have all the data from these click detections.
} }

View File

@ -0,0 +1,29 @@
package test.helper;
import PamController.PamController;
import PamController.PamSettingManager;
import pamguard.GlobalArguments;
import java.io.File;
import java.io.IOException;
/**
* Helper to initialize a headless {@link PamController} from unit tests.
* This will only initialize the {@link PamController} once; tests are responsible for cleaning
* up any changes they make to the configuration.
*/
public class PamControllerTestHelper {
private static boolean isInitialized = false;
public static void InitializePamControllerForTesting() throws IOException {
if (!isInitialized) {
isInitialized = true;
File file = File.createTempFile("OneBandControlTest", "psfx");
file.deleteOnExit();
GlobalArguments.setParam(GlobalArguments.BATCHFLAG, "true");
PamSettingManager.remote_psf = file.getAbsolutePath();
PamController.create(PamController.RUN_NOTHING);
}
}
}

View File

@ -0,0 +1,41 @@
package test.noiseOneBand;
import PamController.PamController;
import PamController.soundMedium.GlobalMedium;
import test.helper.PamControllerTestHelper;
import noiseOneBand.OneBandControl;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class OneBandControlTest {
@BeforeAll
public static void setUpBeforeClass() throws Exception {
PamControllerTestHelper.InitializePamControllerForTesting();
}
@Test
public void MeasurementnameTest() {
try {
assertEquals(4, OneBandControl.NMEASURES);
assertThrows(Exception.class, () -> OneBandControl.getMeasurementName(4));
PamController.getInstance().getGlobalMediumManager().setCurrentMedium(GlobalMedium.SoundMedium.Water, false);
assertEquals("RMS (dB re 1\u00B5Pa)", OneBandControl.getMeasurementName(0));
assertEquals("0-Peak (dB re 1\u00B5Pa)", OneBandControl.getMeasurementName(1));
assertEquals("Peak-Peak (dB re 1\u00B5Pa)", OneBandControl.getMeasurementName(2));
assertEquals("Integrated SEL (dB re 1\u00B5Pa\u00B2s)", OneBandControl.getMeasurementName(3));
PamController.getInstance().getGlobalMediumManager().setCurrentMedium(GlobalMedium.SoundMedium.Air, false);
assertEquals("RMS (dB re 20\u00B5Pa)", OneBandControl.getMeasurementName(0));
assertEquals("0-Peak (dB re 20\u00B5Pa)", OneBandControl.getMeasurementName(1));
assertEquals("Peak-Peak (dB re 20\u00B5Pa)", OneBandControl.getMeasurementName(2));
assertEquals("Integrated SEL (dB re 400\u00B5Pa\u00B2s)", OneBandControl.getMeasurementName(3));
} finally {
PamController.getInstance().getGlobalMediumManager().setCurrentMedium(GlobalMedium.SoundMedium.Water, false);
}
}
}