Updates to detection display in FX GUI

This commit is contained in:
Jamie Mac 2024-05-24 16:56:37 +01:00
parent bf20889743
commit d8cd536f26
7 changed files with 173 additions and 130 deletions

View File

@ -120,6 +120,15 @@ public class DetectionGroupDisplay extends PamBorderPane {
*/ */
private HidingPane hidingPane; private HidingPane hidingPane;
/**
* Flag for how the deteciton plot is laid out.
*/
private int layoutType = DISPLAY_EXTENDED;
/**
* Toggle switch for showing the scroll pane.
*/
private PamToggleSwitch showScrollSwitch;
/** /**
* Constructor for the detection group display. * Constructor for the detection group display.
@ -127,6 +136,7 @@ public class DetectionGroupDisplay extends PamBorderPane {
public DetectionGroupDisplay() { public DetectionGroupDisplay() {
//create hash map to map DDDataInfos to datablocks for quick access. //create hash map to map DDDataInfos to datablocks for quick access.
dDataInfoHashMap = new HashMap<PamDataBlock, DDDataInfo>(); dDataInfoHashMap = new HashMap<PamDataBlock, DDDataInfo>();
this.layoutType = DISPLAY_EXTENDED;
createDetectionDisplay(DISPLAY_EXTENDED); createDetectionDisplay(DISPLAY_EXTENDED);
this.setCenter(detectionDisplayHolder); this.setCenter(detectionDisplayHolder);
} }
@ -136,9 +146,11 @@ public class DetectionGroupDisplay extends PamBorderPane {
* @param layoutType - the layout of the display - e.g. DetectionGroupDisplay.DISPLAY_COMPACT * @param layoutType - the layout of the display - e.g. DetectionGroupDisplay.DISPLAY_COMPACT
*/ */
public DetectionGroupDisplay(int layoutType) { public DetectionGroupDisplay(int layoutType) {
this.layoutType = layoutType;
//create hash map to map DDDataInfos to datablocks for quick access. //create hash map to map DDDataInfos to datablocks for quick access.
dDataInfoHashMap = new HashMap<PamDataBlock, DDDataInfo>(); dDataInfoHashMap = new HashMap<PamDataBlock, DDDataInfo>();
createDetectionDisplay(DISPLAY_COMPACT); createDetectionDisplay(layoutType);
this.setCenter(detectionDisplayHolder); this.setCenter(detectionDisplayHolder);
} }
@ -241,7 +253,7 @@ public class DetectionGroupDisplay extends PamBorderPane {
gridPane.add(new Label("Plot type"), 0, 0); gridPane.add(new Label("Plot type"), 0, 0);
gridPane.add(detectionDisplay.getDataTypePane(), 1, 0); gridPane.add(detectionDisplay.getDataTypePane(), 1, 0);
PamToggleSwitch showScrollSwitch = new PamToggleSwitch("Show scroll bar"); showScrollSwitch = new PamToggleSwitch("Show scroll bar");
showScrollSwitch.selectedProperty().addListener((obsVal, oldVal, newVal)->{ showScrollSwitch.selectedProperty().addListener((obsVal, oldVal, newVal)->{
//show or hide the scroll bar. //show or hide the scroll bar.
this.setEnableScrollBar(newVal); this.setEnableScrollBar(newVal);
@ -570,11 +582,23 @@ public class DetectionGroupDisplay extends PamBorderPane {
/** /**
* Show the scroll bar which allows the user to chnage time limits. * Show the scroll bar which allows the user to change time limits.
* @param enableScrollBarPane - true to enable the time scroll bar. * @param enableScrollBarPane - true to enable the time scroll bar.
*/ */
public void setEnableScrollBar(boolean enableScrollBarPane) { public void setEnableScrollBar(boolean enableScrollBarPane) {
this.detectionDisplay.setEnableScrollBar(enableScrollBarPane); if (this.layoutType==DISPLAY_COMPACT) {
showScrollSwitch.setSelected(enableScrollBarPane);
}
detectionDisplay.setEnableScrollBar(enableScrollBarPane);
detectionDisplay.setupScrollBar();
}
/**
* Check whether the scroll bar is changing. The scroll bar allows the user to change time limits.
* @return true if the scroll bar pane is showing.
*/
public boolean isEnableScrollBar() {
return this.detectionDisplay.isEnableScrollBar();
} }

View File

@ -75,8 +75,10 @@ public class DetectionGroupDisplayFX extends DetectionGroupDisplay implements U
@Override @Override
public void closeNode() {}; public void closeNode() {};
@Override @Override
public DetectionPlotParams getDisplayParams() { public DetectionPlotParams getDisplayParams() {
return this.detectionPlotParams; return this.detectionPlotParams;
} }
@ -86,6 +88,8 @@ public class DetectionGroupDisplayFX extends DetectionGroupDisplay implements U
} }
else detectionPlotParams.dataSource = null; else detectionPlotParams.dataSource = null;
detectionPlotParams.showScrollBar = this.isEnableScrollBar();
if (this.internalFrame!=null) { if (this.internalFrame!=null) {
//need to use the parent node because inside an internal pane. //need to use the parent node because inside an internal pane.
detectionPlotParams.positionX=internalFrame.getInternalRegion().getLayoutX(); detectionPlotParams.positionX=internalFrame.getInternalRegion().getLayoutX();
@ -189,6 +193,10 @@ public class DetectionGroupDisplayFX extends DetectionGroupDisplay implements U
// System.out.println("LOAD DETECTION DISPLAY DATA SOURCE: " + settings.tabName); // System.out.println("LOAD DETECTION DISPLAY DATA SOURCE: " + settings.tabName);
this.detectionPlotParams = settings.clone(); this.detectionPlotParams = settings.clone();
this.setEnableScrollBar(detectionPlotParams.showScrollBar);
return true; return true;
} }
@ -213,10 +221,9 @@ public class DetectionGroupDisplayFX extends DetectionGroupDisplay implements U
/** /**
* The extra stuff here is to make sure that the plot types for a specific detection are saved. So for example * The extra stuff here is to make sure that the plot types for a specific detection are saved. So for example
* if viewing click spectrum then the spectrum plot is selected whenever 1) PAMGuard is opened again or 2) switching from * if viewing click spectrum then the spectrum plot is selected whenever 1) PAMGuard is opened again or 2) switching from
* one type of detection ot another e.g. whistle to click, then the click does nto revert to shwoing a waveform instead * one type of detection to another e.g. whistle to click, then the click does not revert to showing a waveform instead
* of spectrum. * of spectrum.
*/ */
if (currentDetection!=null) { if (currentDetection!=null) {
//save the current selected detection plot for the particular type of data unit. //save the current selected detection plot for the particular type of data unit.
String detectionPlotName = this.getDetectionDisplay().getCurrentDataInfo().getCurrentDetectionPlot().getName(); String detectionPlotName = this.getDetectionDisplay().getCurrentDataInfo().getCurrentDetectionPlot().getName();

View File

@ -27,6 +27,10 @@ public class DetectionPlotParams extends UserDisplayNodeParams implements Clonea
*/ */
public String dataSource = null; public String dataSource = null;
/**
* True to show the scroll bar.
*/
public boolean showScrollBar = true;
/** /**
* Saves which data axis is used for which data block. The key is the data block long name and the * Saves which data axis is used for which data block. The key is the data block long name and the

View File

@ -107,6 +107,7 @@ public class DDDataPane2 extends PamBorderPane {
detectionPlotDisplay.setMinHidePaneHeight(ddDataInfo.getCurrentDetectionPlot().getSettingsPane().getMinHeight()); detectionPlotDisplay.setMinHidePaneHeight(ddDataInfo.getCurrentDetectionPlot().getSettingsPane().getMinHeight());
} }
//don't want the hide button if there's no settings pane. //don't want the hide button if there's no settings pane.
//detectionPlotDisplay.setEnableSettingsButton(ddDataInfo.getCurrentDetectionPlot().getSettingsPane()!=null); //detectionPlotDisplay.setEnableSettingsButton(ddDataInfo.getCurrentDetectionPlot().getSettingsPane()!=null);

View File

@ -355,16 +355,17 @@ public class DetectionPlotDisplay extends PamBorderPane {
* the current data unit. * the current data unit.
*/ */
public void setupScrollBar(PamDataUnit newDataUnit){ public void setupScrollBar(PamDataUnit newDataUnit){
//setup the scroll bar (or not)
if (enableScrollBar && this.detectionPlotProjector.enableScrollBar && newDataUnit!=null) {
this.setTop(scrollBarPane);
if (currentDataInfo!=null) { if (currentDataInfo!=null) {
//important we put this here as it allows the plot to set up the scroll bar pane. //important we put this here as it allows the plot to set up the scroll bar pane.
this.currentDataInfo.setupAxis(detectionPlotProjector, newDataUnit); this.currentDataInfo.setupAxis(detectionPlotProjector, newDataUnit);
} }
//setup the scroll bar (or not)
if (enableScrollBar && this.detectionPlotProjector.enableScrollBar && newDataUnit!=null) {
this.setTop(scrollBarPane);
//System.out.println("Set min and max limits for scroll bar: " + detectionPlotProjector.getMinScrollLimit() + " " + detectionPlotProjector.getMaxScrollLimit()); //System.out.println("Set min and max limits for scroll bar: " + detectionPlotProjector.getMinScrollLimit() + " " + detectionPlotProjector.getMaxScrollLimit());
scrollBarPane.setMinVal(detectionPlotProjector.getMinScrollLimit()); scrollBarPane.setMinVal(detectionPlotProjector.getMinScrollLimit());
scrollBarPane.setMaxVal(detectionPlotProjector.getMaxScrollLimit()); scrollBarPane.setMaxVal(detectionPlotProjector.getMaxScrollLimit());
@ -384,6 +385,9 @@ public class DetectionPlotDisplay extends PamBorderPane {
} }
else { else {
//need this to ensure the axis change when scroll bar is not longer displayed.
detectionPlotProjector.setAxisMinMax(detectionPlotProjector.getMinScrollLimit(),
detectionPlotProjector.getMaxScrollLimit(), detectionPlotProjector.getScrollAxis());
this.setTop(null); this.setTop(null);
} }
} }
@ -409,19 +413,25 @@ public class DetectionPlotDisplay extends PamBorderPane {
private void drawDataUnit(PamDataUnit newDataUnit) { private void drawDataUnit(PamDataUnit newDataUnit) {
//Debug.out.println("DetectionPlotDisplay DrawDataUnit: " +newDataUnit); //Debug.out.println("DetectionPlotDisplay DrawDataUnit: " +newDataUnit);
if (currentDataInfo!=null){ if (currentDataInfo!=null){
//sometimes the axis just need a little push to make sure the pane and axis object bindings have been updated //sometimes the axis just need a little push to make sure the pane and axis object bindings have been updated
for (int i=0; i<Side.values().length; i++) { for (int i=0; i<Side.values().length; i++) {
dDPlotPane.getAxisPane(Side.values()[i]).layout(); dDPlotPane.getAxisPane(Side.values()[i]).layout();
} }
System.out.println("Axis Width: " + dDPlotPane.getAxisPane(Side.BOTTOM).getWidth() + " canvas width " + dDPlotPane.getPlotCanvas().getWidth());
currentDataInfo.drawData(dDPlotPane.getPlotCanvas().getGraphicsContext2D(), currentDataInfo.drawData(dDPlotPane.getPlotCanvas().getGraphicsContext2D(),
new Rectangle(0,0,dDPlotPane.getPlotCanvas().getWidth(),dDPlotPane.getPlotCanvas().getHeight()), new Rectangle(0,0,dDPlotPane.getPlotCanvas().getWidth(),dDPlotPane.getPlotCanvas().getHeight()),
this.detectionPlotProjector, newDataUnit); this.detectionPlotProjector, newDataUnit);
} }
if (reDrawScroll) { if (reDrawScroll) {
setupScrollBar( newDataUnit); setupScrollBar(newDataUnit);
reDrawScroll=false; reDrawScroll=false;
} }
//dDPlotPane.repaintAxis(); //dDPlotPane.repaintAxis();
} }
@ -554,6 +564,7 @@ public class DetectionPlotDisplay extends PamBorderPane {
*/ */
public void setEnableScrollBar(boolean enableScrollBarPane) { public void setEnableScrollBar(boolean enableScrollBarPane) {
enableScrollBar=enableScrollBarPane; enableScrollBar=enableScrollBarPane;
this.detectionPlotProjector.enableScrollBar = enableScrollBarPane;
setupScrollBar(); setupScrollBar();
} }

View File

@ -57,14 +57,14 @@ public class TabSelectionPane extends SettingsPane<PamGuiTabFX> {
tabChoice=new ComboBox<String>(); tabChoice=new ComboBox<String>();
tabChoice.setMinWidth(100); tabChoice.setMinWidth(100);
PamHBox.setHgrow(tabChoice, Priority.ALWAYS); //make sure choice nox is big enough PamHBox.setHgrow(tabChoice, Priority.ALWAYS); //make sure choice nox is big enough
tabChoice.setEditable(true); tabChoice.setEditable(false);
//listener for adding tabs //listener for adding tabs
addButton=new PamButton(); addButton=new PamButton();
// addButton.setGraphic(PamGlyphDude.createPamGlyph(FontAwesomeIcon.PLUS, Color.WHITE, PamGuiManagerFX.iconSize)); // addButton.setGraphic(PamGlyphDude.createPamGlyph(FontAwesomeIcon.PLUS, Color.WHITE, PamGuiManagerFX.iconSize));
addButton.setGraphic(PamGlyphDude.createPamIcon("mdi2p-plus", Color.WHITE, PamGuiManagerFX.iconSize)); addButton.setGraphic(PamGlyphDude.createPamIcon("mdi2p-plus", Color.WHITE, PamGuiManagerFX.iconSize));
addButton.setOnAction((action)->{ addButton.setOnAction((action)->{
pamGuiFX.addPamTab(new TabInfo("New Display " +(pamGuiFX.getTabs().size()+1)), null, true); pamGuiFX.addPamTab(new TabInfo("Display " +(pamGuiFX.getTabs().size()+1)), null, true);
populateChoiceBox(); populateChoiceBox();
//select the tab which has just been added. //select the tab which has just been added.
tabChoice.getSelectionModel().selectLast(); tabChoice.getSelectionModel().selectLast();

View File

@ -111,12 +111,12 @@ public class PlotPane extends PamBorderPane {
private double bottomBorder; private double bottomBorder;
private double leftBorder; private double leftBorder;
// //
// public static final int BOTTOMAXIS = 0; // public static final int BOTTOMAXIS = 0;
// public static final int BOTTOMAXIS = 1; // public static final int BOTTOMAXIS = 1;
// public static final int BOTTOMAXIS = 2; // public static final int BOTTOMAXIS = 2;
// public static final int BOTTOMAXIS = 3; // public static final int BOTTOMAXIS = 3;
// //
/** /**
* Constructs a default plot with an bottom x axis and left y axis. * Constructs a default plot with an bottom x axis and left y axis.
@ -128,6 +128,16 @@ public class PlotPane extends PamBorderPane {
private PamBorderPane createPlot(boolean sidePanes){ private PamBorderPane createPlot(boolean sidePanes){
//create the panes to hold the axis;
//create the plot pane.
canvasHolder=new PamBorderPane();
canvasHolder.setMaxWidth(4000);
canvasHolder.setMaxHeight(4000);
canvas = new Canvas(50, 50);
canvas.heightProperty().bind(canvasHolder.heightProperty());
canvas.widthProperty().bind(canvasHolder.widthProperty());
//create the x axis for the display. //create the x axis for the display.
xAxisTop = new PamAxisFX(0, 1, 0, 1, 0, 10, PamAxisFX.ABOVE_LEFT, null, PamAxis.LABEL_NEAR_CENTRE, null); xAxisTop = new PamAxisFX(0, 1, 0, 1, 0, 10, PamAxisFX.ABOVE_LEFT, null, PamAxis.LABEL_NEAR_CENTRE, null);
xAxisTop.setCrampLabels(true); xAxisTop.setCrampLabels(true);
@ -145,24 +155,10 @@ public class PlotPane extends PamBorderPane {
yAxisLeftPane=new PamAxisPane2(yAxisLeft, Side.LEFT); yAxisLeftPane=new PamAxisPane2(yAxisLeft, Side.LEFT);
//yAxisLeftPane.setOrientation(Orientation.VERTICAL); //yAxisLeftPane.setOrientation(Orientation.VERTICAL);
yAxisRight = new PamAxisFX(0, 1, 0, 1, 0, 10, PamAxisFX.BELOW_RIGHT, "Graph Y Units", PamAxisFX.LABEL_NEAR_CENTRE, "%4d"); yAxisRight = new PamAxisFX(0, 1, 0, 1, 0, 10, PamAxisFX.BELOW_RIGHT, "Graph Y Units", PamAxisFX.LABEL_NEAR_CENTRE, "%4d");
yAxisRight.setCrampLabels(true); yAxisRight.setCrampLabels(true);
yAxisRightPane=new PamAxisPane2(yAxisRight, Side.RIGHT); yAxisRightPane=new PamAxisPane2(yAxisRight, Side.RIGHT);
//yAxisRightPane.setOrientation(Orientation.VERTICAL); //yAxisRightPane.setOrientation(Orientation.VERTICAL)
//create the panes to hold the axis;
//create the plot pane.
canvasHolder=new PamBorderPane();
canvasHolder.setMaxWidth(4000);
canvasHolder.setMaxHeight(4000);
canvas = new Canvas(50, 50);
canvas.heightProperty().bind(canvasHolder.heightProperty());
canvas.widthProperty().bind(canvasHolder.widthProperty());
//allow hiding panes to be added //allow hiding panes to be added
hiddenSidePane=new PamHiddenSidePane(); hiddenSidePane=new PamHiddenSidePane();
@ -171,8 +167,8 @@ public class PlotPane extends PamBorderPane {
canvasHolder.setCenter(hiddenSidePane); canvasHolder.setCenter(hiddenSidePane);
canvasHolder.setMinHeight(0); canvasHolder.setMinHeight(10);
canvasHolder.setMinWidth(0); canvasHolder.setMinWidth(10);
//canvasHolder.getStyleClass().add("pane-plot"); //canvasHolder.getStyleClass().add("pane-plot");
//now add all axis together //now add all axis together
@ -185,10 +181,10 @@ public class PlotPane extends PamBorderPane {
setAxisVisible(true, true, true, true); setAxisVisible(true, true, true, true);
// topHolder.toFront(); // topHolder.toFront();
//yAxisRightPane.toFront(); //yAxisRightPane.toFront();
// yAxisLeftPane.toFront(); // yAxisLeftPane.toFront();
// bottomHolder.toFront(); // bottomHolder.toFront();
axisArray=new PamAxisFX[4]; axisArray=new PamAxisFX[4];
axisArray[0]=xAxisTop; axisArray[0]=xAxisTop;
@ -268,7 +264,7 @@ public class PlotPane extends PamBorderPane {
rightPane.prefWidthProperty().bind(yAxisRightPane.widthProperty()); rightPane.prefWidthProperty().bind(yAxisRightPane.widthProperty());
rightPane.minWidthProperty().bind(yAxisRightPane.widthProperty()); rightPane.minWidthProperty().bind(yAxisRightPane.widthProperty());
horzHolder.getChildren().addAll(leftPane, axisPane, rightPane); horzHolder.getChildren().addAll(leftPane, axisPane);
//axisPane.toFront(); this changes the order of children in a PamHBox. //axisPane.toFront(); this changes the order of children in a PamHBox.
HBox.setHgrow(axisPane, Priority.ALWAYS); HBox.setHgrow(axisPane, Priority.ALWAYS);
@ -279,12 +275,12 @@ public class PlotPane extends PamBorderPane {
} }
// public void repaintAxis() { // public void repaintAxis() {
// xAxisTopPane.repaint(); // xAxisTopPane.repaint();
// xAxisBottomPane.repaint(); // xAxisBottomPane.repaint();
// yAxisRightPane.repaint(); // yAxisRightPane.repaint();
// yAxisLeftPane.repaint(); // yAxisLeftPane.repaint();
// } // }
/** /**
@ -387,33 +383,33 @@ public class PlotPane extends PamBorderPane {
holderPane.setTop(topHolder) ; holderPane.setTop(topHolder) ;
} }
else if (topBorder > 0) { else if (topBorder > 0) {
// holderPane.setTopSpace(topBorder); // holderPane.setTopSpace(topBorder);
} }
if (bottom) { if (bottom) {
holderPane.setBottom(bottomHolder); holderPane.setBottom(bottomHolder);
} }
else if (bottomBorder > 0) { else if (bottomBorder > 0) {
// holderPane.setBottomSpace(bottomBorder); // holderPane.setBottomSpace(bottomBorder);
} }
if (right) { if (right) {
holderPane.setRight(yAxisRightPane) ; holderPane.setRight(yAxisRightPane) ;
} }
else if (rightBorder > 0){ else if (rightBorder > 0){
// holderPane.setRightSpace(rightBorder); // holderPane.setRightSpace(rightBorder);
} }
if (left) { if (left) {
holderPane.setLeft(yAxisLeftPane) ; holderPane.setLeft(yAxisLeftPane) ;
} }
else if (leftBorder > 0) { else if (leftBorder > 0) {
// holderPane.setLeftSpace(leftBorder); // holderPane.setLeftSpace(leftBorder);
} }
holderPane.setCenter(canvasHolder); holderPane.setCenter(canvasHolder);
//bottomHolder.toBack(); //bottomHolder.toBack();
// this.xAxisTopPane.setVisible(top); // this.xAxisTopPane.setVisible(top);
// this.xAxisBottomPane.setVisible(bottom); // this.xAxisBottomPane.setVisible(bottom);
// this.yAxisRightPane.setVisible(right); // this.yAxisRightPane.setVisible(right);
// this.yAxisLeftPane.setVisible(left); // this.yAxisLeftPane.setVisible(left);
} }
/** /**