Change click data selector

Change Click BT display so it can handle CompoundDataSelectors
This commit is contained in:
Douglas Gillespie 2024-07-22 11:42:19 +01:00
parent 577670ccd0
commit 687220dad5
5 changed files with 68 additions and 10 deletions

View File

@ -101,4 +101,25 @@ public class CompoundDataSelector extends DataSelector {
return selectorList;
}
@Override
public DataSelector findDataSelector(Class selectorClass) {
/**
* Check this, then all in the selector list. Should iterate happily back to
* a basic data selector as required even if there are multiple Compound ones.
*/
if (this.getClass() == selectorClass) {
return this;
}
if (selectorList == null) {
return null;
}
for (DataSelector aSelector : selectorList) {
DataSelector subSel = aSelector.findDataSelector(selectorClass);
if (subSel != null) {
return subSel;
}
}
return null;
}
}

View File

@ -97,6 +97,23 @@ public abstract class DataSelector {
*/
abstract public DynamicSettingsPane<Boolean> getDialogPaneFX();
/**
* Find a data selector within a data selector. This is primarily for use with
* ComoundDataSelector objects which may encapsulate multiple other selectors,
* particularly when annotations are in use. but it's needed here so that it
* can be called on any DataSelector object.
* @param selectorClass class to data selector to find.
* @return DataSelector or null if that class of data selector doesn't exist.
*/
public DataSelector findDataSelector(Class selectorClass) {
if (this.getClass() == selectorClass) {
return this;
}
else {
return null;
}
}
/**
* Get a menu item for the data selector that can be easily added
* to any other menu.

View File

@ -68,7 +68,7 @@ public class BTAmplitudeSelector implements PamDialogPanel {
super();
this.clickControl = clickControl;
this.btDisplay = btDisplay;
dataSelector = btDisplay.getDataSelector();
dataSelector = btDisplay.getClickDataSelector();
clickDataBlock = clickControl.getClickDataBlock();
histoPlot = new HistogramDisplay();
histoPlot.setGraphicsOverLayer(histoOverLayer = new HistoOverLayer());

View File

@ -117,6 +117,7 @@ import PamguardMVC.PamDataUnit;
import PamguardMVC.PamObservable;
import PamguardMVC.PamObserver;
import PamguardMVC.dataSelector.DataSelectDialog;
import PamguardMVC.dataSelector.DataSelector;
import PamguardMVC.superdet.SuperDetection;
import clickDetector.ClickClassifiers.ClickIdInformation;
import clickDetector.ClickClassifiers.ClickIdentifier;
@ -2244,11 +2245,15 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
if (btDisplayParameters.amplitudeSelect == false) {
return;
}
ClickDataSelector clickDataSelector = getClickDataSelector();
if (clickDataSelector == null) {
return;
}
int n = countAmplitudeDeselected();
PamDataBlock<ClickDetection> clickData = clickControl.getClickDataBlock();
int nAll = clickData.getUnitsCount();
String txt = String.format("%d of %d loaded clicks will not be displayed because their amplitude is < %3.1fdB",
n, nAll, getDataSelector().getParams().minimumAmplitude);
n, nAll, clickDataSelector.getParams().minimumAmplitude);
Insets insets = getInsets();
int x = insets.left;
int y = getHeight()-5;
@ -2789,7 +2794,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
BTDisplayParameters newParameters =
ClickDisplayDialog.showDialog(clickControl,
clickControl.getGuiFrame(), btDisplayParameters, getDataSelector().getClickAlarmParameters());
clickControl.getGuiFrame(), btDisplayParameters, getClickDataSelector().getClickAlarmParameters());
if (newParameters != null){
btDisplayParameters = newParameters.clone();
if (getVScaleManager() != null) {
@ -2812,8 +2817,23 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
* Get a data selector specific to this display.
* @return click data selector specific to this display.
*/
public ClickDataSelector getDataSelector() {
return (ClickDataSelector) clickControl.getClickDataBlock().getDataSelector(getUnitName(), false);
public DataSelector getDataSelector() {
return clickControl.getClickDataBlock().getDataSelector(getUnitName(), false);
}
/**
* get the click specific data selector which may now be burried in a
* CompoundDataSelector if annotations have been used.
* @return ClickDataSelector.
*/
public ClickDataSelector getClickDataSelector() {
DataSelector baseSel = getDataSelector();
if (baseSel == null) {
return null;
}
else {
return (ClickDataSelector) baseSel.findDataSelector(ClickDataSelector.class);
}
}
class AmplitudeSelector implements ActionListener {
@ -3403,7 +3423,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
else if (btDisplayParameters.colourScheme == BTDisplayParameters.COLOUR_BY_HYDROPHONE) {
keyPanel.add(new TextKeyItem("Colour by hydrophone"));
}
ClickAlarmParameters selectParams = getDataSelector().getParams();
ClickAlarmParameters selectParams = getClickDataSelector().getParams();
// if (btDisplayParameters.getShowSpecies(0)) {
if (selectParams.onlineAutoEvents | selectParams.onlineManualEvents) {
keyPanel.add(symbolChooser.getDefaultSymbol(true).makeKeyItem("Unidentified species"));
@ -3487,7 +3507,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
PamDataBlock<ClickDetection> clickData = clickControl.getClickDataBlock();
ClickDetection click;
int n = 0;
double minAmpli = getDataSelector().getParams().minimumAmplitude;
double minAmpli = getClickDataSelector().getParams().minimumAmplitude;
synchronized (clickData.getSynchLock()) {
ListIterator<ClickDetection> clickIterator = clickData.getListIterator(0);
while (clickIterator.hasNext()) {
@ -4151,7 +4171,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
amplitudeSelectorLabel.setText("");
}
else {
String txt = String.format(" Amplitude Selector showing clicks > %3.1fdB", getDataSelector().getParams().minimumAmplitude);
String txt = String.format(" Amplitude Selector showing clicks > %3.1fdB", getClickDataSelector().getParams().minimumAmplitude);
amplitudeSelectorLabel.setText(txt);
}
}

View File

@ -255,7 +255,7 @@ public class OfflineToolbar {
return;
}
try {
ClickDataSelector clickDataSelector = currentBTDisplay.getDataSelector();
ClickDataSelector clickDataSelector = currentBTDisplay.getClickDataSelector();
ClickAlarmParameters selectParams = clickDataSelector.getParams();
BTDisplayParameters btDisplayParameters = currentBTDisplay.getBtDisplayParameters();
@ -288,7 +288,7 @@ public class OfflineToolbar {
}
private void checkButtons(BTDisplayParameters btDisplayParameters) {
ClickDataSelector clickDataSelector = currentBTDisplay.getDataSelector();
ClickDataSelector clickDataSelector = currentBTDisplay.getClickDataSelector();
ClickAlarmParameters selectParams = clickDataSelector.getParams();
showEchoes.setSelected(selectParams.useEchoes);
showNonSpecies.setSelected(selectParams.getUseSpecies(0));