mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-10-29 23:30:44 +00:00
Updates to detection display in FX GUI
This commit is contained in:
parent
bf20889743
commit
d8cd536f26
@ -120,6 +120,15 @@ public class DetectionGroupDisplay extends PamBorderPane {
|
||||
*/
|
||||
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.
|
||||
@ -127,6 +136,7 @@ public class DetectionGroupDisplay extends PamBorderPane {
|
||||
public DetectionGroupDisplay() {
|
||||
//create hash map to map DDDataInfos to datablocks for quick access.
|
||||
dDataInfoHashMap = new HashMap<PamDataBlock, DDDataInfo>();
|
||||
this.layoutType = DISPLAY_EXTENDED;
|
||||
createDetectionDisplay(DISPLAY_EXTENDED);
|
||||
this.setCenter(detectionDisplayHolder);
|
||||
}
|
||||
@ -136,9 +146,11 @@ public class DetectionGroupDisplay extends PamBorderPane {
|
||||
* @param layoutType - the layout of the display - e.g. DetectionGroupDisplay.DISPLAY_COMPACT
|
||||
*/
|
||||
public DetectionGroupDisplay(int layoutType) {
|
||||
this.layoutType = layoutType;
|
||||
|
||||
//create hash map to map DDDataInfos to datablocks for quick access.
|
||||
dDataInfoHashMap = new HashMap<PamDataBlock, DDDataInfo>();
|
||||
createDetectionDisplay(DISPLAY_COMPACT);
|
||||
createDetectionDisplay(layoutType);
|
||||
this.setCenter(detectionDisplayHolder);
|
||||
}
|
||||
|
||||
@ -241,7 +253,7 @@ public class DetectionGroupDisplay extends PamBorderPane {
|
||||
gridPane.add(new Label("Plot type"), 0, 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)->{
|
||||
//show or hide the scroll bar.
|
||||
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.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,8 +75,10 @@ public class DetectionGroupDisplayFX extends DetectionGroupDisplay implements U
|
||||
|
||||
@Override
|
||||
public void closeNode() {};
|
||||
|
||||
@Override
|
||||
public DetectionPlotParams getDisplayParams() {
|
||||
|
||||
return this.detectionPlotParams;
|
||||
}
|
||||
|
||||
@ -86,6 +88,8 @@ public class DetectionGroupDisplayFX extends DetectionGroupDisplay implements U
|
||||
}
|
||||
else detectionPlotParams.dataSource = null;
|
||||
|
||||
detectionPlotParams.showScrollBar = this.isEnableScrollBar();
|
||||
|
||||
if (this.internalFrame!=null) {
|
||||
//need to use the parent node because inside an internal pane.
|
||||
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);
|
||||
|
||||
this.detectionPlotParams = settings.clone();
|
||||
|
||||
|
||||
this.setEnableScrollBar(detectionPlotParams.showScrollBar);
|
||||
|
||||
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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
if (currentDetection!=null) {
|
||||
//save the current selected detection plot for the particular type of data unit.
|
||||
String detectionPlotName = this.getDetectionDisplay().getCurrentDataInfo().getCurrentDetectionPlot().getName();
|
||||
|
@ -27,6 +27,10 @@ public class DetectionPlotParams extends UserDisplayNodeParams implements Clonea
|
||||
*/
|
||||
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
|
||||
|
@ -107,6 +107,7 @@ public class DDDataPane2 extends PamBorderPane {
|
||||
detectionPlotDisplay.setMinHidePaneHeight(ddDataInfo.getCurrentDetectionPlot().getSettingsPane().getMinHeight());
|
||||
|
||||
}
|
||||
|
||||
//don't want the hide button if there's no settings pane.
|
||||
//detectionPlotDisplay.setEnableSettingsButton(ddDataInfo.getCurrentDetectionPlot().getSettingsPane()!=null);
|
||||
|
||||
|
@ -355,16 +355,17 @@ public class DetectionPlotDisplay extends PamBorderPane {
|
||||
* the current data unit.
|
||||
*/
|
||||
public void setupScrollBar(PamDataUnit newDataUnit){
|
||||
|
||||
if (currentDataInfo!=null) {
|
||||
//important we put this here as it allows the plot to set up the scroll bar pane.
|
||||
this.currentDataInfo.setupAxis(detectionPlotProjector, newDataUnit);
|
||||
}
|
||||
|
||||
//setup the scroll bar (or not)
|
||||
if (enableScrollBar && this.detectionPlotProjector.enableScrollBar && newDataUnit!=null) {
|
||||
|
||||
this.setTop(scrollBarPane);
|
||||
|
||||
if (currentDataInfo!=null) {
|
||||
//important we put this here as it allows the plot to set up the scroll bar pane.
|
||||
this.currentDataInfo.setupAxis(detectionPlotProjector, newDataUnit);
|
||||
}
|
||||
|
||||
//System.out.println("Set min and max limits for scroll bar: " + detectionPlotProjector.getMinScrollLimit() + " " + detectionPlotProjector.getMaxScrollLimit());
|
||||
scrollBarPane.setMinVal(detectionPlotProjector.getMinScrollLimit());
|
||||
scrollBarPane.setMaxVal(detectionPlotProjector.getMaxScrollLimit());
|
||||
@ -384,6 +385,9 @@ public class DetectionPlotDisplay extends PamBorderPane {
|
||||
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -409,19 +413,25 @@ public class DetectionPlotDisplay extends PamBorderPane {
|
||||
private void drawDataUnit(PamDataUnit newDataUnit) {
|
||||
//Debug.out.println("DetectionPlotDisplay DrawDataUnit: " +newDataUnit);
|
||||
if (currentDataInfo!=null){
|
||||
|
||||
//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++) {
|
||||
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(),
|
||||
new Rectangle(0,0,dDPlotPane.getPlotCanvas().getWidth(),dDPlotPane.getPlotCanvas().getHeight()),
|
||||
this.detectionPlotProjector, newDataUnit);
|
||||
}
|
||||
if (reDrawScroll) {
|
||||
setupScrollBar( newDataUnit);
|
||||
setupScrollBar(newDataUnit);
|
||||
reDrawScroll=false;
|
||||
}
|
||||
|
||||
//dDPlotPane.repaintAxis();
|
||||
}
|
||||
|
||||
@ -554,6 +564,7 @@ public class DetectionPlotDisplay extends PamBorderPane {
|
||||
*/
|
||||
public void setEnableScrollBar(boolean enableScrollBarPane) {
|
||||
enableScrollBar=enableScrollBarPane;
|
||||
this.detectionPlotProjector.enableScrollBar = enableScrollBarPane;
|
||||
setupScrollBar();
|
||||
}
|
||||
|
||||
|
@ -57,14 +57,14 @@ public class TabSelectionPane extends SettingsPane<PamGuiTabFX> {
|
||||
tabChoice=new ComboBox<String>();
|
||||
tabChoice.setMinWidth(100);
|
||||
PamHBox.setHgrow(tabChoice, Priority.ALWAYS); //make sure choice nox is big enough
|
||||
tabChoice.setEditable(true);
|
||||
tabChoice.setEditable(false);
|
||||
|
||||
//listener for adding tabs
|
||||
addButton=new PamButton();
|
||||
// addButton.setGraphic(PamGlyphDude.createPamGlyph(FontAwesomeIcon.PLUS, Color.WHITE, PamGuiManagerFX.iconSize));
|
||||
addButton.setGraphic(PamGlyphDude.createPamIcon("mdi2p-plus", Color.WHITE, PamGuiManagerFX.iconSize));
|
||||
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();
|
||||
//select the tab which has just been added.
|
||||
tabChoice.getSelectionModel().selectLast();
|
||||
|
@ -111,12 +111,12 @@ public class PlotPane extends PamBorderPane {
|
||||
private double bottomBorder;
|
||||
|
||||
private double leftBorder;
|
||||
//
|
||||
// public static final int BOTTOMAXIS = 0;
|
||||
// public static final int BOTTOMAXIS = 1;
|
||||
// public static final int BOTTOMAXIS = 2;
|
||||
// public static final int BOTTOMAXIS = 3;
|
||||
//
|
||||
//
|
||||
// public static final int BOTTOMAXIS = 0;
|
||||
// public static final int BOTTOMAXIS = 1;
|
||||
// public static final int BOTTOMAXIS = 2;
|
||||
// public static final int BOTTOMAXIS = 3;
|
||||
//
|
||||
|
||||
/**
|
||||
* 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){
|
||||
|
||||
//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.
|
||||
xAxisTop = new PamAxisFX(0, 1, 0, 1, 0, 10, PamAxisFX.ABOVE_LEFT, null, PamAxis.LABEL_NEAR_CENTRE, null);
|
||||
xAxisTop.setCrampLabels(true);
|
||||
@ -145,64 +155,50 @@ public class PlotPane extends PamBorderPane {
|
||||
yAxisLeftPane=new PamAxisPane2(yAxisLeft, Side.LEFT);
|
||||
//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.setCrampLabels(true);
|
||||
yAxisRightPane=new PamAxisPane2(yAxisRight, Side.RIGHT);
|
||||
//yAxisRightPane.setOrientation(Orientation.VERTICAL);
|
||||
//yAxisRightPane.setOrientation(Orientation.VERTICAL)
|
||||
|
||||
//allow hiding panes to be added
|
||||
hiddenSidePane=new PamHiddenSidePane();
|
||||
hiddenSidePane.getChildren().add(canvas);
|
||||
hiddenSidePane.toFront();
|
||||
|
||||
|
||||
//create the panes to hold the axis;
|
||||
canvasHolder.setCenter(hiddenSidePane);
|
||||
canvasHolder.setMinHeight(10);
|
||||
canvasHolder.setMinWidth(10);
|
||||
//canvasHolder.getStyleClass().add("pane-plot");
|
||||
|
||||
//create the plot pane.
|
||||
canvasHolder=new PamBorderPane();
|
||||
canvasHolder.setMaxWidth(4000);
|
||||
canvasHolder.setMaxHeight(4000);
|
||||
//now add all axis together
|
||||
holderPane=new PamBorderPane();
|
||||
|
||||
canvas = new Canvas(50, 50);
|
||||
canvas.heightProperty().bind(canvasHolder.heightProperty());
|
||||
canvas.widthProperty().bind(canvasHolder.widthProperty());
|
||||
//now need to add some corner sections to the top and bottom axis as borderpane is being used
|
||||
topHolder=createHorzHolder(xAxisTopPane);
|
||||
bottomHolder=createHorzHolder(xAxisBottomPane);
|
||||
|
||||
setAxisVisible(true, true, true, true);
|
||||
|
||||
|
||||
//allow hiding panes to be added
|
||||
hiddenSidePane=new PamHiddenSidePane();
|
||||
hiddenSidePane.getChildren().add(canvas);
|
||||
hiddenSidePane.toFront();
|
||||
// topHolder.toFront();
|
||||
//yAxisRightPane.toFront();
|
||||
// yAxisLeftPane.toFront();
|
||||
// bottomHolder.toFront();
|
||||
|
||||
axisArray=new PamAxisFX[4];
|
||||
axisArray[0]=xAxisTop;
|
||||
axisArray[1]=yAxisRight;
|
||||
axisArray[2]=xAxisBottom;
|
||||
axisArray[3]=yAxisLeft;
|
||||
|
||||
canvasHolder.setCenter(hiddenSidePane);
|
||||
canvasHolder.setMinHeight(0);
|
||||
canvasHolder.setMinWidth(0);
|
||||
//canvasHolder.getStyleClass().add("pane-plot");
|
||||
axisPanes=new PamAxisPane2[4];
|
||||
axisPanes[0]=xAxisTopPane;
|
||||
axisPanes[1]=yAxisRightPane;
|
||||
axisPanes[2]=xAxisBottomPane;
|
||||
axisPanes[3]=yAxisLeftPane;
|
||||
|
||||
//now add all axis together
|
||||
holderPane=new PamBorderPane();
|
||||
|
||||
//now need to add some corner sections to the top and bottom axis as borderpane is being used
|
||||
topHolder=createHorzHolder(xAxisTopPane);
|
||||
bottomHolder=createHorzHolder(xAxisBottomPane);
|
||||
|
||||
setAxisVisible(true, true, true, true);
|
||||
|
||||
|
||||
// topHolder.toFront();
|
||||
//yAxisRightPane.toFront();
|
||||
// yAxisLeftPane.toFront();
|
||||
// bottomHolder.toFront();
|
||||
|
||||
axisArray=new PamAxisFX[4];
|
||||
axisArray[0]=xAxisTop;
|
||||
axisArray[1]=yAxisRight;
|
||||
axisArray[2]=xAxisBottom;
|
||||
axisArray[3]=yAxisLeft;
|
||||
|
||||
axisPanes=new PamAxisPane2[4];
|
||||
axisPanes[0]=xAxisTopPane;
|
||||
axisPanes[1]=yAxisRightPane;
|
||||
axisPanes[2]=xAxisBottomPane;
|
||||
axisPanes[3]=yAxisLeftPane;
|
||||
|
||||
return holderPane;
|
||||
return holderPane;
|
||||
}
|
||||
|
||||
|
||||
@ -268,23 +264,23 @@ public class PlotPane extends PamBorderPane {
|
||||
rightPane.prefWidthProperty().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.
|
||||
HBox.setHgrow(axisPane, Priority.ALWAYS);
|
||||
HBox.setHgrow(axisPane, Priority.ALWAYS);
|
||||
|
||||
//horzHolder.getStyleClass().add("pane");
|
||||
|
||||
return horzHolder;
|
||||
return horzHolder;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// public void repaintAxis() {
|
||||
// xAxisTopPane.repaint();
|
||||
// xAxisBottomPane.repaint();
|
||||
// yAxisRightPane.repaint();
|
||||
// yAxisLeftPane.repaint();
|
||||
// }
|
||||
// public void repaintAxis() {
|
||||
// xAxisTopPane.repaint();
|
||||
// xAxisBottomPane.repaint();
|
||||
// yAxisRightPane.repaint();
|
||||
// yAxisLeftPane.repaint();
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
@ -387,33 +383,33 @@ public class PlotPane extends PamBorderPane {
|
||||
holderPane.setTop(topHolder) ;
|
||||
}
|
||||
else if (topBorder > 0) {
|
||||
// holderPane.setTopSpace(topBorder);
|
||||
// holderPane.setTopSpace(topBorder);
|
||||
}
|
||||
if (bottom) {
|
||||
holderPane.setBottom(bottomHolder);
|
||||
}
|
||||
else if (bottomBorder > 0) {
|
||||
// holderPane.setBottomSpace(bottomBorder);
|
||||
// holderPane.setBottomSpace(bottomBorder);
|
||||
}
|
||||
if (right) {
|
||||
holderPane.setRight(yAxisRightPane) ;
|
||||
}
|
||||
else if (rightBorder > 0){
|
||||
// holderPane.setRightSpace(rightBorder);
|
||||
// holderPane.setRightSpace(rightBorder);
|
||||
}
|
||||
if (left) {
|
||||
holderPane.setLeft(yAxisLeftPane) ;
|
||||
}
|
||||
else if (leftBorder > 0) {
|
||||
// holderPane.setLeftSpace(leftBorder);
|
||||
// holderPane.setLeftSpace(leftBorder);
|
||||
}
|
||||
holderPane.setCenter(canvasHolder);
|
||||
//bottomHolder.toBack();
|
||||
|
||||
// this.xAxisTopPane.setVisible(top);
|
||||
// this.xAxisBottomPane.setVisible(bottom);
|
||||
// this.yAxisRightPane.setVisible(right);
|
||||
// this.yAxisLeftPane.setVisible(left);
|
||||
// this.xAxisTopPane.setVisible(top);
|
||||
// this.xAxisBottomPane.setVisible(bottom);
|
||||
// this.yAxisRightPane.setVisible(right);
|
||||
// this.yAxisLeftPane.setVisible(left);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user