mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-22 07:02:29 +00:00
Updated the prediction plots on time display
Deep learning prediciton plots on the time display have now been updated to have some colour options and also act as a legend.
This commit is contained in:
parent
53b8ca9479
commit
4f96500911
@ -33,7 +33,7 @@ public class DLPredDisplayParams implements Serializable, Cloneable, ManagedPara
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
protected DLPredDisplayParams clone() {
|
||||
public DLPredDisplayParams clone() {
|
||||
try {
|
||||
return (DLPredDisplayParams) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
|
@ -8,6 +8,7 @@ import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.ColorPicker;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
import pamViewFX.fxGlyphs.PamSVGIcon;
|
||||
@ -48,19 +49,29 @@ public class DLPredictionPane extends PamBorderPane implements TDSettingsPane {
|
||||
*/
|
||||
private PamVBox predColHolder;
|
||||
|
||||
/**
|
||||
* Stops the set params from triggering listeners in controls
|
||||
* that call get params (all sorts of bad things happen if this occurs)
|
||||
*/
|
||||
private boolean setParams = false;
|
||||
|
||||
|
||||
public DLPredictionPane(DLPredictionPlotInfoFX dlPredictionPlotInfoFX) {
|
||||
|
||||
System.out.println("HELLO PREDICTION PANE");
|
||||
|
||||
this.dlPredictionPlotInfoFX=dlPredictionPlotInfoFX;
|
||||
mainPane = new PamBorderPane();
|
||||
mainPane.setCenter(predColHolder = new PamVBox());
|
||||
predColHolder.setSpacing(5);
|
||||
predColHolder.setPadding(new Insets(5,0,0,0));
|
||||
|
||||
if (dlPredictionPlotInfoFX.getDlControl().getDLModel()!=null) {
|
||||
layoutColourPanes( dlPredictionPlotInfoFX.getDlControl().getDLModel().getClassNames());
|
||||
}
|
||||
this.setParams();
|
||||
|
||||
// if (dlPredictionPlotInfoFX.getDlControl().getDLModel()!=null) {
|
||||
// layoutColourPanes( dlPredictionPlotInfoFX.getDlControl().getDLModel().getClassNames());
|
||||
// }
|
||||
|
||||
this.getParams();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -84,6 +95,8 @@ public class DLPredictionPane extends PamBorderPane implements TDSettingsPane {
|
||||
}
|
||||
|
||||
public void setParams() {
|
||||
// System.out.println("SET params");
|
||||
setParams= true;
|
||||
|
||||
if (dlPredictionPlotInfoFX.getDlControl().getDLModel()!=null) {
|
||||
//populate the prediction pane.
|
||||
@ -92,6 +105,7 @@ public class DLPredictionPane extends PamBorderPane implements TDSettingsPane {
|
||||
layoutColourPanes(classNames);
|
||||
}
|
||||
|
||||
setParams=false;
|
||||
}
|
||||
|
||||
private void layoutColourPanes(DLClassName[] classNames){
|
||||
@ -103,11 +117,27 @@ public class DLPredictionPane extends PamBorderPane implements TDSettingsPane {
|
||||
predColHolder.getChildren().clear();
|
||||
|
||||
for (int i=0; i<classNames.length; i++) {
|
||||
if (i<colourPanes.size()-1 && classNames[i].className.equals(this.colourPanes.get(i).getName())) {
|
||||
//probably the same
|
||||
colourPanes.add(this.colourPanes.get(i));
|
||||
// System.out.println("classNames: " + classNames[i].className + " "
|
||||
// + this.colourPanes.size() + " LINE INFOS: " + this.dlPredictionPlotInfoFX.getDlPredParams().lineInfos);
|
||||
if (i<this.colourPanes.size()) {
|
||||
if (!classNames[i].className.equals(this.colourPanes.get(i).getName())) {
|
||||
colourPanes.add(new PredictionColourPane(classNames[i].className, true, Color.BLACK));
|
||||
}
|
||||
else {
|
||||
colourPanes.add(this.colourPanes.get(i));
|
||||
}
|
||||
}
|
||||
colourPanes.add(new PredictionColourPane(classNames[i].className, true, Color.BLACK));
|
||||
else {
|
||||
colourPanes.add(new PredictionColourPane(classNames[i].className, true, Color.BLACK));
|
||||
}
|
||||
|
||||
//now check if we can recycle colours
|
||||
if (this.dlPredictionPlotInfoFX.getDlPredParams().lineInfos!=null && i<this.dlPredictionPlotInfoFX.getDlPredParams().lineInfos.length) {
|
||||
//probably the same
|
||||
//System.out.println("LINE INFOS: " + this.dlPredictionPlotInfoFX.getDlPredParams().lineInfos[i].color);
|
||||
colourPanes.get(i).setLineInfo(dlPredictionPlotInfoFX.getDlPredParams().lineInfos[i]);
|
||||
}
|
||||
|
||||
predColHolder.getChildren().add(colourPanes.get(i));
|
||||
}
|
||||
|
||||
@ -119,6 +149,9 @@ public class DLPredictionPane extends PamBorderPane implements TDSettingsPane {
|
||||
* Get the parameters.
|
||||
*/
|
||||
private void getParams() {
|
||||
// System.out.println("GET params");
|
||||
if (setParams) return;
|
||||
|
||||
this.dlPredictionPlotInfoFX.getDlPredParams().lineInfos = new LineInfo[colourPanes.size()];
|
||||
for (int i=0; i<colourPanes.size(); i++) {
|
||||
this.dlPredictionPlotInfoFX.getDlPredParams().lineInfos[i] = new LineInfo(
|
||||
@ -164,8 +197,8 @@ public class DLPredictionPane extends PamBorderPane implements TDSettingsPane {
|
||||
|
||||
|
||||
/**
|
||||
* Pane for
|
||||
* @author au671271
|
||||
* Pane for showing prediciton and colour.
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
private class PredictionColourPane extends PamHBox {
|
||||
@ -192,6 +225,7 @@ public class DLPredictionPane extends PamBorderPane implements TDSettingsPane {
|
||||
newSettings();
|
||||
});
|
||||
toggleSwitch.setPrefWidth(120);
|
||||
toggleSwitch.setTooltip(new Tooltip(name));
|
||||
|
||||
this.colourPicker = new ColorPicker();
|
||||
this.colourPicker.valueProperty().addListener((obsVal, oldVal, newval)->{
|
||||
@ -210,6 +244,11 @@ public class DLPredictionPane extends PamBorderPane implements TDSettingsPane {
|
||||
|
||||
}
|
||||
|
||||
public void setLineInfo(LineInfo lineInfo) {
|
||||
this.colourPicker.setValue(lineInfo.color);
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -15,12 +15,10 @@ import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import dataPlotsFX.TDManagedSymbolChooserFX;
|
||||
import dataPlotsFX.TDSymbolChooserFX;
|
||||
import dataPlotsFX.clickPlotFX.ClickDisplayParams;
|
||||
import dataPlotsFX.data.TDDataInfoFX;
|
||||
import dataPlotsFX.data.TDDataProviderFX;
|
||||
import dataPlotsFX.data.generic.GenericScaleInfo;
|
||||
import dataPlotsFX.layout.TDGraphFX;
|
||||
import dataPlotsFX.layout.TDSettingsPane;
|
||||
import dataPlotsFX.projector.TDProjectorFX;
|
||||
import javafx.geometry.Point2D;
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
@ -337,7 +335,7 @@ public class DLPredictionPlotInfoFX extends TDDataInfoFX {
|
||||
* @see dataPlots.data.TDDataInfo#getHidingDialogComponent()
|
||||
*/
|
||||
@Override
|
||||
public TDSettingsPane getGraphSettingsPane() {
|
||||
public DLPredictionPane getGraphSettingsPane() {
|
||||
if (predictionSettingsPane==null) {
|
||||
predictionSettingsPane = new DLPredictionPane(this);
|
||||
}
|
||||
@ -355,6 +353,15 @@ public class DLPredictionPlotInfoFX extends TDDataInfoFX {
|
||||
*/
|
||||
@Override
|
||||
public Serializable getStoredSettings() {
|
||||
if (dlPredParams.lineInfos!=null) {
|
||||
for (int i=0; i<dlPredParams.lineInfos.length; i++) {
|
||||
//set the colour as a double[] because it is not serializable.
|
||||
dlPredParams.lineInfos[i].colorSerializable = new double[] {dlPredParams.lineInfos[i].color.getRed(),
|
||||
dlPredParams.lineInfos[i].color.getGreen(), dlPredParams.lineInfos[i].color.getBlue()};
|
||||
}
|
||||
}
|
||||
//System.out.println("First colour is getStore: " + dlPredParams.lineInfos[0].color);
|
||||
|
||||
return dlPredParams;
|
||||
}
|
||||
|
||||
@ -363,9 +370,20 @@ public class DLPredictionPlotInfoFX extends TDDataInfoFX {
|
||||
*/
|
||||
@Override
|
||||
public boolean setStoredSettings(Serializable storedSettings) {
|
||||
if (ClickDisplayParams.class.isAssignableFrom(storedSettings.getClass())) {
|
||||
if (DLPredDisplayParams.class.isAssignableFrom(storedSettings.getClass())) {
|
||||
dlPredParams = (DLPredDisplayParams) storedSettings;
|
||||
if (dlPredParams.lineInfos!=null) {
|
||||
for (int i=0; i<dlPredParams.lineInfos.length; i++) {
|
||||
//set the colour because it is not serializable <- what a pain
|
||||
dlPredParams.lineInfos[i].color = Color.color(dlPredParams.lineInfos[i].colorSerializable[0],
|
||||
dlPredParams.lineInfos[i].colorSerializable[1], dlPredParams.lineInfos[i].colorSerializable[2]);
|
||||
}
|
||||
}
|
||||
//System.out.println("First colour is setStore: " + dlPredParams.lineInfos[0].color);
|
||||
updateSettings();
|
||||
//Platform.runLater(()->{
|
||||
getGraphSettingsPane().setParams();
|
||||
//});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -25,7 +25,12 @@ public class LineInfo implements Serializable, Cloneable{
|
||||
/**
|
||||
* The colour of the line
|
||||
*/
|
||||
public Color color = Color.DODGERBLUE;
|
||||
public transient Color color = Color.DODGERBLUE;
|
||||
|
||||
/**
|
||||
* Only used when serializing the data...
|
||||
*/
|
||||
public double[] colorSerializable = new double[] {30/255., 144/255., 255/255.}; //DODOGER BLUE;
|
||||
|
||||
/**
|
||||
* True if the line is enabled (shown on the plot)
|
||||
|
@ -81,8 +81,6 @@ public class DLDetectionBinarySource extends BinaryDataSource {
|
||||
DLDetection cd = (DLDetection) pamDataUnit;
|
||||
|
||||
//System.out.println("DLDetecitonBinarySource: packed: " + pamDataUnit.getBasicData().getMeasuredAmplitudeType());
|
||||
|
||||
|
||||
// make a byte array output stream and write the data to that,
|
||||
// then dump that down to the main storage stream
|
||||
if (dos == null || bos == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user