mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2025-05-12 17:47:24 +00:00
Mino UI fixes
Added frequency format to FFT settings pane Auto label change when new source selecting in deep learning model
This commit is contained in:
parent
9f758a211e
commit
88e4faf899
src
dataPlotsFX
data
scrollingPlot2D
spectrogramPlotFX
pamViewFX/fxNodes/pamAxis
rawDeepLearningClassifier
@ -2,15 +2,12 @@ package dataPlotsFX.data;
|
||||
|
||||
import PamView.GeneralProjector.ParameterType;
|
||||
import PamView.GeneralProjector.ParameterUnits;
|
||||
import PamguardMVC.debug.Debug;
|
||||
import dataPlots.data.TDDataInfo;
|
||||
import dataPlotsFX.projector.TDProjectorFX;
|
||||
import javafx.beans.property.DoubleProperty;
|
||||
import javafx.beans.property.IntegerProperty;
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
|
||||
/**
|
||||
* Information about the scale requirements
|
||||
@ -79,6 +76,11 @@ public class TDScaleInfo {
|
||||
* minimum is at top of graph and the maximum is a the bottom
|
||||
*/
|
||||
private boolean reverseAxis = false;
|
||||
|
||||
// /**
|
||||
// * String converter for axis.
|
||||
// */
|
||||
// private StringConverter<Double> stringConverter = new DoubleStringConverter();
|
||||
|
||||
|
||||
// @Deprecated
|
||||
@ -387,6 +389,14 @@ public class TDScaleInfo {
|
||||
minVal.set(scaleInfoData.minVal);
|
||||
maxVal.set(scaleInfoData.maxVal);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get the string converter. This is used for writing units to axis
|
||||
// * @return the string converter;
|
||||
// */
|
||||
// public StringConverter<Double> getUnitConverter(){
|
||||
// return stringConverter;
|
||||
// }
|
||||
|
||||
/**
|
||||
* If true then the axis is reversed
|
||||
|
@ -417,7 +417,9 @@ abstract public class Scrolling2DPlotInfo extends TDDataInfoFX implements Plot2D
|
||||
//System.out.println(" FFTPlotInfo: setSampleRate(float sampleRate, boolean notify)");
|
||||
this.fftSampleRate = sampleRate;
|
||||
// call function in outerclass which can be overridden...
|
||||
Scrolling2DPlotInfo.this.setSampleRate(sampleRate, notify);
|
||||
Platform.runLater(()->{
|
||||
Scrolling2DPlotInfo.this.setSampleRate(sampleRate, notify);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -148,6 +148,7 @@ public class FFTPlotInfo extends Scrolling2DPlotInfo {
|
||||
boolean setNiquist = (currentMax == currentRange || currentMax > sampleRate/2.);
|
||||
// DoubleProperty[] frequencyLimits = new doublep
|
||||
spectrogramControlPane.setMinFrequency(0);
|
||||
|
||||
if (setNiquist) {
|
||||
spectrogramControlPane.setMaxFrequency(sampleRate/2.);
|
||||
//change so that the high limit covers the whole display.
|
||||
|
@ -0,0 +1,28 @@
|
||||
package dataPlotsFX.spectrogramPlotFX;
|
||||
|
||||
import PamUtils.FrequencyFormat;
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
/**
|
||||
* Format frequency string converter.
|
||||
*/
|
||||
public class FrequencyStringConverter extends StringConverter<Number> {
|
||||
|
||||
|
||||
private FrequencyFormat format;
|
||||
|
||||
public FrequencyStringConverter(FrequencyFormat format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Number object) {
|
||||
return String.format(format.getNumberFormat(), object.doubleValue() / format.getScale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number fromString(String string) {
|
||||
return Double.valueOf(string)*format.getScale();
|
||||
}
|
||||
|
||||
}
|
@ -8,6 +8,7 @@ import javafx.geometry.Orientation;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.canvas.Canvas;
|
||||
import javafx.scene.layout.Pane;
|
||||
import PamUtils.FrequencyFormat;
|
||||
import dataPlotsFX.layout.TDGraphFX;
|
||||
import dataPlotsFX.layout.TDSettingsPane;
|
||||
import dataPlotsFX.scrollingPlot2D.Plot2DControPane;
|
||||
@ -29,16 +30,17 @@ public class TDSpectrogramControlPane extends Plot2DControPane implements TDSett
|
||||
* Reference to the TDGraph for this pane.
|
||||
*/
|
||||
private TDGraphFX tdGraph;
|
||||
//
|
||||
// /**
|
||||
// * Frequencies can be shown in kHz to stop very large numbers on axis. True if frequencies are to be represented in kHz rather than Hz.
|
||||
// */
|
||||
// double frequencyScale = 1;
|
||||
|
||||
/**
|
||||
* Frequencies can be shown in kHz to stop very large numbers on axis. True if frequencies are to be represented in kHz rather than Hz.
|
||||
*/
|
||||
double frequencyScale = 1;
|
||||
|
||||
/**
|
||||
* Value at which the slider switches from Hz to kHz
|
||||
*/
|
||||
private static int convertTokHz=2000;
|
||||
// /**
|
||||
// * Value at which the slider switches from Hz to kHz
|
||||
// */
|
||||
// private static int convertTokHz=2000;
|
||||
|
||||
|
||||
|
||||
private Canvas icon;
|
||||
@ -79,7 +81,7 @@ public class TDSpectrogramControlPane extends Plot2DControPane implements TDSett
|
||||
//add listeners to repaint when frequency changes.
|
||||
addFrequencyListeners(frequencyLimits);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add listeners to min/max double property for frequency limits. Will change
|
||||
@ -117,21 +119,21 @@ public class TDSpectrogramControlPane extends Plot2DControPane implements TDSett
|
||||
icon.getGraphicsContext2D().fillRect(0, 0, 20, 20);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Check whether the slider is displaying in units of Hz or kHz.
|
||||
// * @return true if displaying in units of kHz.
|
||||
// */
|
||||
// public boolean isKhz(){
|
||||
// return kHz;
|
||||
// }
|
||||
// /**
|
||||
// * Check whether the slider is displaying in units of Hz or kHz.
|
||||
// * @return true if displaying in units of kHz.
|
||||
// */
|
||||
// public boolean isKhz(){
|
||||
// return kHz;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Frequency scale = 1 for Hz and 1000 for kHz.
|
||||
* @return the frequencyScale
|
||||
*/
|
||||
public double getFrequencyScale() {
|
||||
return frequencyScale;
|
||||
}
|
||||
// /**
|
||||
// * Frequency scale = 1 for Hz and 1000 for kHz.
|
||||
// * @return the frequencyScale
|
||||
// */
|
||||
// public double getFrequencyScale() {
|
||||
// return frequencyScale;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Set the frequency range of the slider.
|
||||
@ -154,18 +156,17 @@ public class TDSpectrogramControlPane extends Plot2DControPane implements TDSett
|
||||
|
||||
if (minVal>=max) minVal=0;
|
||||
if (maxVal>max) maxVal=max;
|
||||
|
||||
//check to see if using kHz;
|
||||
if (max>convertTokHz) {
|
||||
frequencyScale = 1000;
|
||||
getFreqLabel().setText("Frequency (kHz)");;
|
||||
}
|
||||
else {
|
||||
frequencyScale = 1000;
|
||||
getFreqLabel().setText("Frequency (Hz)");
|
||||
}
|
||||
max=max/frequencyScale;
|
||||
minVal=minVal/frequencyScale;
|
||||
maxVal=maxVal/frequencyScale;
|
||||
|
||||
|
||||
FrequencyFormat format = FrequencyFormat.getFrequencyFormat(max);
|
||||
getFreqLabel().setText("Frequency (" + format.getUnitText() + ")");
|
||||
|
||||
// ///scale the frequency by the correct value.
|
||||
// max=max/frequencyScale;
|
||||
// minVal=minVal/frequencyScale;
|
||||
// maxVal=maxVal/frequencyScale;
|
||||
|
||||
getFrequencySlider() .setMin(min);
|
||||
getFrequencySlider() .setMax(max); //Nyquist
|
||||
@ -175,6 +176,8 @@ public class TDSpectrogramControlPane extends Plot2DControPane implements TDSett
|
||||
//set tick mark spacing
|
||||
getFrequencySlider().majorTickUnitProperty().setValue((max-min)/4);
|
||||
getFrequencySlider().majorTickUnitProperty().setValue((max-min)/(4*4));
|
||||
|
||||
getFrequencySlider().setLabelFormatter(new FrequencyStringConverter(format));
|
||||
|
||||
}
|
||||
|
||||
@ -186,19 +189,19 @@ public class TDSpectrogramControlPane extends Plot2DControPane implements TDSett
|
||||
* frequencyLimits- the frequency limits to set bin to range slider.
|
||||
*/
|
||||
private void setFrequencyBinding(DoubleProperty[] frequencyLimits){
|
||||
// frequencyLimits[0].unbind();
|
||||
// frequencyLimits[1].unbind();
|
||||
// frequencyLimits[0].bind(getFrequencySlider() .lowValueProperty().multiply(frequencyScale));
|
||||
// frequencyLimits[1].bind(getFrequencySlider() .highValueProperty().multiply(frequencyScale));
|
||||
|
||||
// frequencyLimits[0].unbind();
|
||||
// frequencyLimits[1].unbind();
|
||||
// frequencyLimits[0].bind(getFrequencySlider() .lowValueProperty().multiply(frequencyScale));
|
||||
// frequencyLimits[1].bind(getFrequencySlider() .highValueProperty().multiply(frequencyScale));
|
||||
|
||||
getFrequencySlider() .lowValueProperty().addListener((obsVal, oldVal, newVal)->{
|
||||
frequencyLimits[0].setValue(newVal.doubleValue()*frequencyScale);
|
||||
frequencyLimits[0].setValue(newVal.doubleValue());
|
||||
});
|
||||
|
||||
|
||||
getFrequencySlider() .highValueProperty().addListener((obsVal, oldVal, newVal)->{
|
||||
frequencyLimits[1].setValue(newVal.doubleValue()*frequencyScale);
|
||||
frequencyLimits[1].setValue(newVal.doubleValue());
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -209,7 +212,6 @@ public class TDSpectrogramControlPane extends Plot2DControPane implements TDSett
|
||||
public void setMinFrequency(double frequency){
|
||||
if (frequency<0) return;
|
||||
double sliderVal=frequency;
|
||||
sliderVal/=frequencyScale;
|
||||
getFrequencySlider() .lowValueProperty().setValue(sliderVal);
|
||||
}
|
||||
|
||||
@ -220,16 +222,16 @@ public class TDSpectrogramControlPane extends Plot2DControPane implements TDSett
|
||||
*/
|
||||
public void setMaxFrequency(double frequency){
|
||||
if (frequency<0) return;
|
||||
double sliderVal=frequency/frequencyScale;
|
||||
double sliderVal=frequency;
|
||||
getFrequencySlider().highValueProperty().setValue(sliderVal);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the maximum allowable value from the frequency slider.
|
||||
* @return maximum allowed value of the range.
|
||||
*/
|
||||
public double getMaxFrequencyRange() {
|
||||
return getFrequencySlider().getMax()*frequencyScale;
|
||||
return getFrequencySlider().getMax();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -203,12 +203,11 @@ public class PamAxisPane2 extends StackPane {
|
||||
//the axis label.
|
||||
axis.labelProperty().bind(pamAxisFX.labelProperty());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Formats number son the axis. Actually quite hard - for example we want dB not to have a decimal points for ICI.
|
||||
* Formats numbers on the axis. Actually quite hard - for example we want dB not to have a decimal points for ICI.
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
|
@ -80,7 +80,7 @@ public class ArchiveModelWorker extends GenericModelWorker {
|
||||
//System.out.println(Paths.get(genericParams.modelPath));
|
||||
this.currentPath = dlParams.modelPath;
|
||||
dlModel = loadModel(currentPath);
|
||||
System.out.println("LOAD A NEW MODEL: " + currentPath);
|
||||
//System.out.println("LOAD A NEW MODEL: " + currentPath);
|
||||
}
|
||||
}
|
||||
catch (EngineException e) {
|
||||
|
@ -183,6 +183,8 @@ public class DLSettingsPane extends SettingsPane<RawDLParams>{
|
||||
this.dlControl.createDataSelector(getSelectedParentDataBlock());
|
||||
//enable the controls to show a data selector or not.
|
||||
enableControls();
|
||||
|
||||
this.setSegInfoLabel();//refresh label
|
||||
});
|
||||
|
||||
//create the detection
|
||||
@ -584,7 +586,7 @@ public class DLSettingsPane extends SettingsPane<RawDLParams>{
|
||||
|
||||
sourcePane.setParams(currParams.groupedSourceParams);
|
||||
sourcePane.sourceChanged();
|
||||
|
||||
sourcePane.setSourceList();
|
||||
|
||||
dlControl.createDataSelector(sourcePane.getSource());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user