mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-21 22:52:22 +00:00
Fix bug in whistle detection plot
Also add ability to change contour colours
This commit is contained in:
parent
fa6991eb80
commit
6f36e5a47f
@ -6,7 +6,7 @@
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-21.0.2.13-hotspot">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/Amazon Coretto 21">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
@ -649,6 +649,8 @@ public class ModuleConnectionNode extends StandardConnectionNode implements PAMC
|
||||
|
||||
}
|
||||
|
||||
System.out.println("Add module: " + pamControlledUnit.getUnitName() + " " + pamControlledUnit.getPamModuleInfo());
|
||||
|
||||
if (pamControlledUnit.getPamModuleInfo()!=null) {
|
||||
Node icon = ModuleIconFactory.getInstance().
|
||||
getModuleNode(pamControlledUnit.getPamModuleInfo().getClassName());
|
||||
|
@ -132,6 +132,7 @@ public class ModuleIconFactory {
|
||||
break;
|
||||
case TETHYS:
|
||||
iconNode = PamGlyphDude.createModuleIcon("file-codemeta");
|
||||
System.out.println("Get module Tethys " + iconNode);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -215,7 +216,6 @@ public class ModuleIconFactory {
|
||||
* @return the module icon enum
|
||||
*/
|
||||
public ModuleIcon getModuleIcon(String className) {
|
||||
// System.out.println("Get module icon: " + className);
|
||||
ModuleIcon icon = null;
|
||||
switch (className) {
|
||||
case "Acquisition.AcquisitionControl":
|
||||
@ -270,10 +270,12 @@ public class ModuleIconFactory {
|
||||
case "cpod.CPODControl2":
|
||||
icon=ModuleIcon.CPOD;
|
||||
break;
|
||||
case "MetaDataControl":
|
||||
case "Meta Data":
|
||||
icon = ModuleIcon.TETHYS;
|
||||
break;
|
||||
}
|
||||
System.out.println("Get module icon: " + className + " icon " + icon);
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
@ -184,6 +184,29 @@ public class WhistlePlotInfoFX extends TDDataInfoFX {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a whistle fragment.
|
||||
* @param pamDataUnit - the PAM data unit
|
||||
* @param g - the graphics handle
|
||||
* @param windowRect - window describing window pixel dimensions to draw on
|
||||
* @param orientation - orientation
|
||||
* @param tdprojector - projector which converts pixels to time, frequency and vice versa.
|
||||
* @param scrollStart - the scroll start
|
||||
* @param type - type flag for plotting
|
||||
* @param wmControl
|
||||
* @param fftLength - the FFT length in samples
|
||||
* @param fftHop - the FFT hop in samples
|
||||
* @param sampleRate - the sample rate in samples per second
|
||||
* @param fillCol - the fill colour
|
||||
* @param linCol - the line colour.
|
||||
* @param useKhz - true to pot with kHz instead of Hz
|
||||
* @return a 2D path in pixels of the fragment.
|
||||
*/
|
||||
public static Path2D drawWhistleFragement(PamDataUnit pamDataUnit, WhistleMoanControl wmControl, int fftLength, int fftHop, float sampleRate,
|
||||
GraphicsContext g, TimeProjectorFX tdprojector, double scrollStart, int type, Color fillCol, Color linCol, Orientation orientation) {
|
||||
return WhistlePlotInfoFX.drawWhistleFragement(pamDataUnit, wmControl, fftLength, fftHop, sampleRate, g, tdprojector, scrollStart, type, fillCol, linCol, false, orientation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a whistle fragment.
|
||||
@ -200,10 +223,11 @@ public class WhistlePlotInfoFX extends TDDataInfoFX {
|
||||
* @param sampleRate - the sample rate in samples per second
|
||||
* @param fillCol - the fill colour
|
||||
* @param linCol - the line colour.
|
||||
* @param useKhz - true to pot with kHz instead of Hz
|
||||
* @return a 2D path in pixels of the fragment.
|
||||
*/
|
||||
public static Path2D drawWhistleFragement(PamDataUnit pamDataUnit, WhistleMoanControl wmControl, int fftLength, int fftHop, float sampleRate,
|
||||
GraphicsContext g, TimeProjectorFX tdprojector, double scrollStart, int type, Color fillCol, Color linCol, Orientation orientation) {
|
||||
GraphicsContext g, TimeProjectorFX tdprojector, double scrollStart, int type, Color fillCol, Color linCol, boolean useKhz, Orientation orientation) {
|
||||
|
||||
//get position on time axis
|
||||
long timeMillis=pamDataUnit.getTimeMilliseconds();
|
||||
@ -275,7 +299,9 @@ public class WhistlePlotInfoFX extends TDDataInfoFX {
|
||||
sliceMillis += timeMillis;
|
||||
slicePeaks = sliceData.getnPeaks();
|
||||
|
||||
|
||||
tC=tdprojector.getTimePix((long) (sliceMillis-scrollStart));
|
||||
|
||||
if (tC < 0 || tC > tdprojector.getGraphTimePixels()) {
|
||||
return null;
|
||||
}
|
||||
@ -305,6 +331,7 @@ public class WhistlePlotInfoFX extends TDDataInfoFX {
|
||||
}
|
||||
lastPeak = prevSlice.getPeakInfo()[lastPeakNum];
|
||||
f2 = thisPeak[1] * sampleRate / fftLength;
|
||||
if (useKhz) f2=f2/1000.;
|
||||
|
||||
pt2 = new Point2D(tC, tdprojector.getCoord3d(0,f2,0).getCoordinate(1));
|
||||
|
||||
@ -315,9 +342,10 @@ public class WhistlePlotInfoFX extends TDDataInfoFX {
|
||||
awtPath.lineTo(pt2.getX(), pt2.getY());
|
||||
}
|
||||
pathCount++;
|
||||
// System.out.println("yAxis: "+ tdprojector.getCoord3d(0,f2,0).getCoordinate(1)+ " f2: " +f2 + " max val: "+yAxis.getMaxVal()+" "+frequencyInfo.getUnitDivisor());
|
||||
// System.out.println("yAxis: "+ tdprojector.getCoord3d(0,f2,0).getCoordinate(1)+ " f2: " +f2 ); //+yAxis.getMaxVal()+" "+frequencyInfo.getUnitDivisor());
|
||||
|
||||
f1=lastPeak[1] * sampleRate / fftLength;
|
||||
if (useKhz) f1=f1/1000.;
|
||||
|
||||
pt1 = new Point2D(prevtC,tdprojector.getCoord3d(0,f1,0).getCoordinate(1));
|
||||
|
||||
@ -332,9 +360,10 @@ public class WhistlePlotInfoFX extends TDDataInfoFX {
|
||||
pt2 = new Point2D(tC, tdprojector.getCoord3d(0,f2,0).getCoordinate(1));
|
||||
|
||||
f1=lastPeak[0] * sampleRate / fftLength;
|
||||
if (useKhz) f1=f1/1000.;
|
||||
|
||||
pt1 = new Point2D(prevtC, tdprojector.getCoord3d(0,f1,0).getCoordinate(1));
|
||||
|
||||
|
||||
drawWhistleSegment( g, orientation, prevSliceX, pt1.getY(), sliceX, pt2.getY());
|
||||
|
||||
minX = Math.min(minX, pt1.getX());
|
||||
@ -347,10 +376,13 @@ public class WhistlePlotInfoFX extends TDDataInfoFX {
|
||||
maxY = Math.max(maxY, pt2.getY());
|
||||
|
||||
f2=thisPeak[2] * sampleRate / fftLength;
|
||||
if (useKhz) f2=f2/1000.;
|
||||
|
||||
pt2 = new Point2D(tC, tdprojector.getCoord3d(0,f2,0).getCoordinate(1));
|
||||
|
||||
f1=lastPeak[2] * sampleRate / fftLength;
|
||||
if (useKhz) f1=f1/1000.;
|
||||
|
||||
pt1 = new Point2D(prevtC, tdprojector.getCoord3d(0,f1,0).getCoordinate(1));
|
||||
|
||||
drawWhistleSegment( g, orientation, prevSliceX, pt1.getY(), sliceX, pt2.getY());
|
||||
|
@ -20,6 +20,7 @@ import detectionPlotFX.plots.RawFFTPlot.FreqTimeProjector;
|
||||
import detectionPlotFX.projector.DetectionPlotProjector;
|
||||
import javafx.geometry.Side;
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.control.TextFormatter.Change;
|
||||
import javafx.scene.image.WritableImage;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
@ -38,6 +39,12 @@ import javafx.scene.shape.Rectangle;
|
||||
*/
|
||||
public abstract class FFTPlot<D extends PamDataUnit> implements DetectionPlot<D> {
|
||||
|
||||
/**
|
||||
* Plot kHz instead of
|
||||
*/
|
||||
private static final double USE_KHZ_FREQ = 2000;
|
||||
|
||||
|
||||
/**
|
||||
* Reference to the detection plot display.
|
||||
*/
|
||||
@ -63,7 +70,7 @@ public abstract class FFTPlot<D extends PamDataUnit> implements DetectionPlot<D>
|
||||
/**
|
||||
* The FFT parameters.
|
||||
*/
|
||||
protected FFTPlotParams fftParams = new FFTPlotParams();
|
||||
protected FFTPlotParams fftParams = createPlotParams();
|
||||
|
||||
|
||||
private static DataTypeInfo dataTypeInfo = new DataTypeInfo(ParameterType.FREQUENCY, ParameterUnits.HZ);
|
||||
@ -79,6 +86,10 @@ public abstract class FFTPlot<D extends PamDataUnit> implements DetectionPlot<D>
|
||||
private FFTWriteableImage writableImage;
|
||||
|
||||
|
||||
/**
|
||||
* True if plotting as kHz instead of Hz - usually for higher frequency data greater than USE_KHZ_FREQ;
|
||||
*/
|
||||
private boolean useKHz = false;
|
||||
|
||||
public FFTPlot(DetectionPlotDisplay displayPlot, DetectionPlotProjector projector) {
|
||||
this.detectionPlotDisplay=displayPlot;
|
||||
@ -186,10 +197,11 @@ public abstract class FFTPlot<D extends PamDataUnit> implements DetectionPlot<D>
|
||||
* @param freqAxis
|
||||
*/
|
||||
public void setupFreqAxis(double minFreq, double maxFreq, DetectionPlotProjector projector) {
|
||||
if (maxFreq>2000) {
|
||||
if (maxFreq>USE_KHZ_FREQ) {
|
||||
//use kHz
|
||||
//projector.getAxis(Side.LEFT).setLabelScale(0.001);
|
||||
projector.setAxisMinMax(minFreq, maxFreq/ 1000, Side.LEFT, "Frequency (kHz)");
|
||||
this.useKHz = true;
|
||||
projector.setAxisMinMax(minFreq, maxFreq/1000., Side.LEFT, "Frequency (kHz)");
|
||||
}
|
||||
else {
|
||||
projector.setAxisMinMax(minFreq, maxFreq, Side.LEFT, "Frequency (Hz)");
|
||||
@ -407,7 +419,9 @@ public abstract class FFTPlot<D extends PamDataUnit> implements DetectionPlot<D>
|
||||
|
||||
//add settings listener to dynamic settings pane.
|
||||
setttingsPane.addSettingsListener(()->{
|
||||
settingsChanged(setttingsPane.getParams(new FFTPlotParams()));
|
||||
//this needs to be a new instance of the the FFTPlotParams or some settings don't
|
||||
//register a chnage
|
||||
settingsChanged(setttingsPane.getParams(createPlotParams() ));
|
||||
});
|
||||
|
||||
// /////////*****Test Pane*******///////////
|
||||
@ -431,6 +445,14 @@ public abstract class FFTPlot<D extends PamDataUnit> implements DetectionPlot<D>
|
||||
}
|
||||
return (Pane) setttingsPane.getContentNode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create plot paramters for the FFT plot params
|
||||
* @return
|
||||
*/
|
||||
public FFTPlotParams createPlotParams() {
|
||||
return new FFTPlotParams();
|
||||
}
|
||||
|
||||
public class SimpleFFTDataUnit extends DataUnit2D<PamDataUnit,SuperDetection> {
|
||||
|
||||
@ -537,7 +559,6 @@ public abstract class FFTPlot<D extends PamDataUnit> implements DetectionPlot<D>
|
||||
* The PAM detection used for plotting
|
||||
*/
|
||||
private D pamDetection;
|
||||
|
||||
|
||||
|
||||
public FFTWriteableImage(int x, int y, FFTPlotParams fftParams, D pamDetection) {
|
||||
@ -546,9 +567,12 @@ public abstract class FFTPlot<D extends PamDataUnit> implements DetectionPlot<D>
|
||||
this.pamDetection=pamDetection;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isUseKHz() {
|
||||
return useKHz;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -349,12 +349,21 @@ public class FFTSettingsPane<D extends PamDataUnit> extends DynamicSettingsPane<
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VBox holder. This is the main pane whihc holds the spectrogram colour settings.
|
||||
* This is the main pane which holds the spectrogram colour and FFT settings.
|
||||
* @return the VBox holder.
|
||||
*/
|
||||
public PamHBox getVBoxHolder() {
|
||||
public PamHBox getHolderPane() {
|
||||
return holder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the Pane which holds the FFT Settings e.. length hop etc.
|
||||
* @return the pane with controls for FFT settings.
|
||||
*/
|
||||
public Pane getFFTPane() {
|
||||
return fftPane;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the colour combo box which allows users to change the gradient colour
|
||||
|
@ -133,6 +133,7 @@ public abstract class RawFFTPlot<D extends PamDataUnit> extends FFTPlot<D> {
|
||||
reloadImage=true;
|
||||
}
|
||||
lastData=dataUnit;
|
||||
|
||||
//three threaded sequences. 1) Load the data
|
||||
//2) generate the image and 3), on the FX thread, paint the image,
|
||||
if (reloadRaw && detectionPlotDisplay.isViewer()){
|
||||
@ -142,19 +143,19 @@ public abstract class RawFFTPlot<D extends PamDataUnit> extends FFTPlot<D> {
|
||||
//Otherwise variables get cleared etc and it;s a mess
|
||||
spectrogram.checkConfig();
|
||||
|
||||
loadRawData(dataUnit, fftParams.detPadding, fftParams.plotChannel);
|
||||
loadRawData(dataUnit, fftParams.detPadding, fftParams.plotChannel);
|
||||
//rawDataOrder.startRawDataLoad(dataUnit, fftParams.detPadding, fftParams.plotChannel);
|
||||
//on a different thread which will call repaint again
|
||||
}
|
||||
else if (reloadImage && detectionPlotDisplay.isViewer()){
|
||||
// System.out.println("Load IMAGE data: seconds: " + this.rawDataOrder.getRawDataObserver().getRawData().length
|
||||
// + " for data unit: " + +dataUnit.getUID());
|
||||
System.out.println("Load IMAGE data: seconds: " + this.rawDataOrder.getRawDataObserver().getRawData().length
|
||||
+ " for data unit: " + +dataUnit.getUID());
|
||||
spectrogram.checkConfig();
|
||||
startImageLoad();
|
||||
}
|
||||
else {
|
||||
//repaint the image!!
|
||||
// System.out.println("PAINT the image for: " +dataUnit.getUID());
|
||||
System.out.println("PAINT the image for: " +dataUnit.getUID());
|
||||
if (detectionPlotDisplay.isViewer()) paintSpecImage(graphicsContext, rectangle, projector);
|
||||
paintDetections(dataUnit, graphicsContext, rectangle, projector) ;
|
||||
}
|
||||
@ -177,6 +178,8 @@ public abstract class RawFFTPlot<D extends PamDataUnit> extends FFTPlot<D> {
|
||||
// if (pamDetection != null) {
|
||||
// sR = pamDetection.getParentDataBlock().getSampleRate();
|
||||
// }
|
||||
|
||||
//TODO - need to get this working
|
||||
projector.setEnableScrollBar(false);
|
||||
|
||||
setupFreqAxis(0, sR/2, projector);
|
||||
@ -305,8 +308,8 @@ public abstract class RawFFTPlot<D extends PamDataUnit> extends FFTPlot<D> {
|
||||
*/
|
||||
protected synchronized void loadDataUnitImage(double[] rawData, float sR, int channel, long dataStart, Task task ){
|
||||
|
||||
System.out.println("RawFFTPlot: Raw data to process: " + rawData.length + " bins: FFTPlot: hop: " + fftParams.fftLength + " length: " + fftParams.fftHop
|
||||
+ " sampleRate: " + sR);
|
||||
// System.out.println("RawFFTPlot: Raw data to process: " + rawData.length + " bins: FFTPlot: hop: " + fftParams.fftLength + " length: " + fftParams.fftHop
|
||||
// + " sampleRate: " + sR);
|
||||
|
||||
this.simpleFFTBlock.setFftHop(fftParams.fftHop);
|
||||
this.simpleFFTBlock.setFftLength(fftParams.fftLength);
|
||||
@ -480,11 +483,11 @@ public abstract class RawFFTPlot<D extends PamDataUnit> extends FFTPlot<D> {
|
||||
fftPlotParams.windowFunction!=this.fftParams.windowFunction ||
|
||||
fftPlotParams.normalise!=this.fftParams.normalise) {
|
||||
|
||||
// Debug.out.println("CheckSettings: Image needs relaoded: FFTLength: "
|
||||
// + (fftPlotParams.fftLength!=this.fftParams.fftLength) + " FFTHop: "
|
||||
// + (fftPlotParams.fftHop!=this.fftParams.fftHop) + " WindowFunction: "
|
||||
// + (fftPlotParams.windowFunction!=this.fftParams.windowFunction) + " Normalise: "
|
||||
// + (fftPlotParams.normalise!=this.fftParams.normalise) + " ");
|
||||
System.out.println("CheckSettings: Image needs relaoded: FFTLength: "
|
||||
+ (fftPlotParams.fftLength!=this.fftParams.fftLength) + " FFTHop: "
|
||||
+ (fftPlotParams.fftHop!=this.fftParams.fftHop) + " WindowFunction: "
|
||||
+ (fftPlotParams.windowFunction!=this.fftParams.windowFunction) + " Normalise: "
|
||||
+ (fftPlotParams.normalise!=this.fftParams.normalise) + " ");
|
||||
|
||||
this.reloadImage=true;
|
||||
}
|
||||
@ -682,6 +685,8 @@ public abstract class RawFFTPlot<D extends PamDataUnit> extends FFTPlot<D> {
|
||||
|
||||
@Override
|
||||
public Coordinate3d getCoord3d(double d1, double d2, double d3) {
|
||||
// PamAxisFX axis = projector.getAxis(Side.LEFT);
|
||||
// System.out.println("d2 : " + d2 + " minmax: " + axis.getMinVal() + " " + axis.getMaxVal());
|
||||
return projector.getCoord3d(d1,d2,d3);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class DetectionPlotProjector extends GeneralProjector<Coordinate3d> {
|
||||
/**
|
||||
* True to enable the scroll bar.
|
||||
*/
|
||||
public boolean enableScrollBar = false;
|
||||
public boolean enableScrollBar = true;
|
||||
|
||||
/**
|
||||
* Projector for the ddPlotPane.
|
||||
|
@ -1,22 +1,21 @@
|
||||
package detectionPlotFX.whistleDDPlot;
|
||||
|
||||
import PamguardMVC.debug.Debug;
|
||||
import dataPlotsFX.whistlePlotFX.WhistlePlotInfoFX;
|
||||
import detectionPlotFX.layout.DetectionPlotDisplay;
|
||||
import detectionPlotFX.plots.RawFFTPlot;
|
||||
import detectionPlotFX.plots.FFTPlotParams;
|
||||
import detectionPlotFX.plots.FFTSettingsPane;
|
||||
import detectionPlotFX.plots.RawFFTPlot;
|
||||
import detectionPlotFX.projector.DetectionPlotProjector;
|
||||
import javafx.geometry.Orientation;
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import pamViewFX.fxNodes.pamAxis.PamAxisFX;
|
||||
import whistlesAndMoans.ConnectedRegionDataUnit;
|
||||
import whistlesAndMoans.WhistleMoanControl;
|
||||
|
||||
/**
|
||||
* Plots a whistle contour over.
|
||||
* Plots a whistle contour over a spectrgram if one is available.
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
@ -27,21 +26,6 @@ public class WhistleFFTPlot extends RawFFTPlot<ConnectedRegionDataUnit> {
|
||||
*/
|
||||
private WhistleMoanControl whistleMoanControl;
|
||||
|
||||
/**
|
||||
* Line colour
|
||||
*/
|
||||
private Color lineColor=Color.BLACK;
|
||||
|
||||
/**
|
||||
* The fill colour
|
||||
*/
|
||||
private Color fillColor=Color.BLACK;
|
||||
|
||||
/**
|
||||
* The whislte settings pane.
|
||||
*/
|
||||
private WhistleSettingsPane setttingsPane;
|
||||
|
||||
/**
|
||||
* The whistle FFT plot
|
||||
* @param displayPlot - the display plot.
|
||||
@ -56,7 +40,9 @@ public class WhistleFFTPlot extends RawFFTPlot<ConnectedRegionDataUnit> {
|
||||
public void paintDetections(ConnectedRegionDataUnit whistleDataUnit,
|
||||
GraphicsContext graphicsContext, Rectangle windowRect, DetectionPlotProjector projector) {
|
||||
|
||||
// Debug.out.println("Draw whistle fragment: " + whistleDataUnit + " sR: "+ whistleDataUnit.getParentDataBlock().getSampleRate() + " Scroll start: " + getScrollStart());
|
||||
|
||||
// System.out.println("Draw whistle fragment: " + whistleDataUnit + " sR: "+ whistleDataUnit.getParentDataBlock().getSampleRate() + " Scroll start: " + getScrollStart());
|
||||
|
||||
WhistlePlotInfoFX.drawWhistleFragement(whistleDataUnit,
|
||||
whistleMoanControl,
|
||||
//need to have fft which was used in making the detections
|
||||
@ -64,20 +50,23 @@ public class WhistleFFTPlot extends RawFFTPlot<ConnectedRegionDataUnit> {
|
||||
whistleMoanControl.getWhistleToneProcess().getOutputData().getFftHop(),
|
||||
whistleDataUnit.getParentDataBlock().getSampleRate(), //need to use this because FFT sample rate can be unreliable
|
||||
graphicsContext,
|
||||
super.getProjector(), getScrollStart(), 0, fillColor, lineColor, Orientation.HORIZONTAL);
|
||||
super.getProjector(), getScrollStart(), 0, getContourColor(), getContourColor(), this.isUseKHz(), Orientation.HORIZONTAL);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pane getSettingsPane() {
|
||||
return super.getSettingsPane();
|
||||
// if (setttingsPane==null){
|
||||
// setttingsPane= new WhistleSettingsPane(whistleMoanControl, this);
|
||||
// setttingsPane.setParams(super.getFFTParams()) ;
|
||||
// }
|
||||
// return (Pane) setttingsPane.getContentNode();
|
||||
private Color getContourColor() {
|
||||
return ((WhistlePlotParams) this.getFFTParams()).contourColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FFTSettingsPane<?> createSettingsPane(){
|
||||
return new WhistleSettingsPane(null, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FFTPlotParams createPlotParams() {
|
||||
return new WhistlePlotParams();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
13
src/detectionPlotFX/whistleDDPlot/WhistlePlotParams.java
Normal file
13
src/detectionPlotFX/whistleDDPlot/WhistlePlotParams.java
Normal file
@ -0,0 +1,13 @@
|
||||
package detectionPlotFX.whistleDDPlot;
|
||||
|
||||
|
||||
import detectionPlotFX.plots.FFTPlotParams;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
public class WhistlePlotParams extends FFTPlotParams {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
Color contourColor = Color.GRAY;
|
||||
|
||||
}
|
@ -1,20 +1,11 @@
|
||||
package detectionPlotFX.whistleDDPlot;
|
||||
|
||||
import detectionPlotFX.plots.RawFFTPlot;
|
||||
import detectionPlotFX.plots.FFTPlotParams;
|
||||
import detectionPlotFX.plots.FFTSettingsPane;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.ColorPicker;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Slider;
|
||||
import javafx.scene.control.Spinner;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.layout.Pane;
|
||||
import pamViewFX.PamGuiManagerFX;
|
||||
import pamViewFX.fxGlyphs.PamGlyphDude;
|
||||
import pamViewFX.fxNodes.PamButton;
|
||||
import pamViewFX.fxNodes.PamHBox;
|
||||
import pamViewFX.fxNodes.PamSpinner;
|
||||
import pamViewFX.fxNodes.PamVBox;
|
||||
import whistlesAndMoans.ConnectedRegionDataUnit;
|
||||
@ -27,24 +18,18 @@ import whistlesAndMoans.ConnectedRegionDataUnit;
|
||||
*/
|
||||
public class WhistleSettingsPane extends FFTSettingsPane<ConnectedRegionDataUnit> {
|
||||
|
||||
//TODO - neeed to complete this class;
|
||||
//TODO - need to complete this class;
|
||||
|
||||
/**
|
||||
* Allows fragments colours.
|
||||
*/
|
||||
private ColorPicker colorPicker;
|
||||
|
||||
/**
|
||||
* The time buffer control. Controls the time shown before and after the whislte.
|
||||
*/
|
||||
private PamSpinner<Double> timeBuffer;
|
||||
|
||||
private PamSpinner<Integer> fftSpinnerLength;
|
||||
|
||||
|
||||
public WhistleSettingsPane(Object owner, RawFFTPlot<?> fftPlot) {
|
||||
super(owner, fftPlot);
|
||||
//add whistle fragment to bottom;
|
||||
//super.getVBoxHolder().getChildren().add(createWhistlePane());
|
||||
super.getFFTPane().getChildren().add(createWhistlePane());
|
||||
}
|
||||
|
||||
|
||||
@ -54,55 +39,79 @@ public class WhistleSettingsPane extends FFTSettingsPane<ConnectedRegionDataUnit
|
||||
*/
|
||||
private Pane createWhistlePane(){
|
||||
|
||||
//make the colour box smaller so we can fit more stuff in.
|
||||
super.getColorBox().setPrefWidth(50);
|
||||
super.getSpectroControlPane().setPrefWidth(75);
|
||||
// //make the colour box smaller so we can fit more stuff in.
|
||||
// super.getColorBox().setPrefWidth(50);
|
||||
// super.getSpectroControlPane().setPrefWidth(75);
|
||||
|
||||
//colour picker
|
||||
Label contourColourLabel = new Label("Contour Colour");
|
||||
colorPicker = new ColorPicker();
|
||||
|
||||
//buffer
|
||||
Label timeBufferLabel = new Label("Time Buffer");
|
||||
timeBuffer = new PamSpinner<Double>(0, 500, 1, 0.2);
|
||||
timeBuffer.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL);
|
||||
colorPicker.valueProperty().addListener((obsval, oldVal, newVal)->{
|
||||
newSettings();
|
||||
});
|
||||
|
||||
//slider for changing the FFT length.
|
||||
Label fftSpinnerLabel = new Label("FFT Length");
|
||||
ObservableList<Integer> stepSizeListLength=FXCollections.observableArrayList();
|
||||
for (int i=2; i<15; i++){
|
||||
stepSizeListLength.add((int) Math.pow(2,i));
|
||||
}
|
||||
fftSpinnerLength=new PamSpinner<Integer>(stepSizeListLength);
|
||||
fftSpinnerLength.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL);
|
||||
fftSpinnerLength.setEditable(true);
|
||||
|
||||
//Slider for changing hop size
|
||||
Label windowLengthLabel = new Label("Window Length");
|
||||
PamButton pamButton = new PamButton();
|
||||
// pamButton.setGraphic(PamGlyphDude.createPamGlyph(MaterialIcon.ADJUST, PamGuiManagerFX.iconSize));
|
||||
pamButton.setGraphic(PamGlyphDude.createPamIcon("mdi2a-adjust", PamGuiManagerFX.iconSize));
|
||||
pamButton.setTooltip(new Tooltip("Optimise the window length based on the average frequency slope of the signal"));
|
||||
|
||||
PamHBox windowLengthHBox= new PamHBox(windowLengthLabel, pamButton);
|
||||
windowLengthHBox.setAlignment(Pos.CENTER_LEFT);
|
||||
windowLengthHBox.setSpacing(5);
|
||||
|
||||
Slider windowSizeSlider= new Slider();
|
||||
windowSizeSlider.setMax(8192);
|
||||
windowSizeSlider.setMin(8);
|
||||
|
||||
windowSizeSlider.setShowTickLabels(true);
|
||||
windowSizeSlider.setShowTickMarks(true);
|
||||
windowSizeSlider.setMajorTickUnit(1024);
|
||||
windowSizeSlider.setMinorTickCount(0); //disable minor tick marks
|
||||
// //buffer
|
||||
// Label timeBufferLabel = new Label("Time Buffer");
|
||||
// timeBuffer = new PamSpinner<Double>(0, 500, 1, 0.2);
|
||||
// timeBuffer.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL);
|
||||
//
|
||||
// //slider for changing the FFT length.
|
||||
// Label fftSpinnerLabel = new Label("FFT Length");
|
||||
// ObservableList<Integer> stepSizeListLength=FXCollections.observableArrayList();
|
||||
// for (int i=2; i<15; i++){
|
||||
// stepSizeListLength.add((int) Math.pow(2,i));
|
||||
// }
|
||||
// fftSpinnerLength=new PamSpinner<Integer>(stepSizeListLength);
|
||||
// fftSpinnerLength.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL);
|
||||
// fftSpinnerLength.setEditable(true);
|
||||
//
|
||||
// //Slider for changing hop size
|
||||
// Label windowLengthLabel = new Label("Window Length");
|
||||
// PamButton pamButton = new PamButton();
|
||||
//// pamButton.setGraphic(PamGlyphDude.createPamGlyph(MaterialIcon.ADJUST, PamGuiManagerFX.iconSize));
|
||||
// pamButton.setGraphic(PamGlyphDude.createPamIcon("mdi2a-adjust", PamGuiManagerFX.iconSize));
|
||||
// pamButton.setTooltip(new Tooltip("Optimise the window length based on the average frequency slope of the signal"));
|
||||
//
|
||||
// PamHBox windowLengthHBox= new PamHBox(windowLengthLabel, pamButton);
|
||||
// windowLengthHBox.setAlignment(Pos.CENTER_LEFT);
|
||||
// windowLengthHBox.setSpacing(5);
|
||||
//
|
||||
// Slider windowSizeSlider= new Slider();
|
||||
// windowSizeSlider.setMax(8192);
|
||||
// windowSizeSlider.setMin(8);
|
||||
//
|
||||
// windowSizeSlider.setShowTickLabels(true);
|
||||
// windowSizeSlider.setShowTickMarks(true);
|
||||
// windowSizeSlider.setMajorTickUnit(1024);
|
||||
// windowSizeSlider.setMinorTickCount(0); //disable minor tick marks
|
||||
|
||||
|
||||
PamVBox pamVBox = new PamVBox(contourColourLabel, colorPicker, timeBufferLabel, timeBuffer,
|
||||
fftSpinnerLabel, fftSpinnerLength, windowLengthHBox, windowSizeSlider);
|
||||
PamVBox pamVBox = new PamVBox(contourColourLabel, colorPicker);
|
||||
pamVBox.setSpacing(7);
|
||||
|
||||
return pamVBox;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the params from the current settings of the controls.
|
||||
* @param wignerParams - the params to set.
|
||||
* @return the new FFT parameters
|
||||
*/
|
||||
@Override
|
||||
public FFTPlotParams getParams(FFTPlotParams fftPlotParams) {
|
||||
((WhistlePlotParams) fftPlotParams).contourColor = this.colorPicker.getValue();
|
||||
return super.getParams(fftPlotParams);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setParams(FFTPlotParams input) {
|
||||
this.colorPicker.setValue(((WhistlePlotParams) input).contourColor);
|
||||
super.setParams(input);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,11 +7,14 @@ import java.io.Serializable;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenuItem;
|
||||
|
||||
import Array.ArrayManager;
|
||||
import PamController.PamControlledUnit;
|
||||
import PamController.PamControlledUnitSettings;
|
||||
import PamController.PamController;
|
||||
import PamController.PamGUIManager;
|
||||
import PamController.PamSettingManager;
|
||||
import PamController.PamSettings;
|
||||
import PamModel.PamModuleInfo;
|
||||
import metadata.swing.MetaDataDialog;
|
||||
|
||||
/**
|
||||
@ -44,6 +47,7 @@ public class MetaDataContol extends PamControlledUnit implements PamSettings {
|
||||
public static MetaDataContol getMetaDataControl() {
|
||||
if (singleInstance == null) {
|
||||
singleInstance = new MetaDataContol(unitType);
|
||||
singleInstance.addModuleInfo(); //needed for FX
|
||||
// add this line to add it to the main modules list. Then it will get menu's, etc.
|
||||
PamController.getInstance().addControlledUnit(singleInstance);
|
||||
}
|
||||
@ -108,6 +112,17 @@ public class MetaDataContol extends PamControlledUnit implements PamSettings {
|
||||
// send around a notification ?
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add module info to the array manager. Need to do this to add icon which is used in data model.
|
||||
*/
|
||||
private void addModuleInfo(){
|
||||
//need to add module info due to fact array manager is a special case
|
||||
PamModuleInfo metaModuleInfo=new PamModuleInfo(unitType, "Handles project metadata", MetaDataContol.class);
|
||||
metaModuleInfo.setCoreModule(true);
|
||||
metaModuleInfo.addGUICompatabilityFlag(PamGUIManager.FX);
|
||||
this.setPamModuleInfo(metaModuleInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user