diff --git a/src/detectionPlotFX/DetectionGroupDisplay.java b/src/detectionPlotFX/DetectionGroupDisplay.java index 3b9754f2..69289edf 100644 --- a/src/detectionPlotFX/DetectionGroupDisplay.java +++ b/src/detectionPlotFX/DetectionGroupDisplay.java @@ -118,8 +118,17 @@ public class DetectionGroupDisplay extends PamBorderPane { /** * Hiding pane for the plot settings. */ - 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. @@ -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(); + 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(); - 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(); } diff --git a/src/detectionPlotFX/DetectionGroupDisplayFX.java b/src/detectionPlotFX/DetectionGroupDisplayFX.java index a06b520d..ea831e73 100644 --- a/src/detectionPlotFX/DetectionGroupDisplayFX.java +++ b/src/detectionPlotFX/DetectionGroupDisplayFX.java @@ -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(); diff --git a/src/detectionPlotFX/DetectionPlotParams.java b/src/detectionPlotFX/DetectionPlotParams.java index f951e1c6..80840b7d 100644 --- a/src/detectionPlotFX/DetectionPlotParams.java +++ b/src/detectionPlotFX/DetectionPlotParams.java @@ -26,8 +26,12 @@ public class DetectionPlotParams extends UserDisplayNodeParams implements Clonea * The data source for the detection plot. */ 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 * result is the name of the plot e.g. waveform. In this way users can set how they want the data plots to display diff --git a/src/detectionPlotFX/layout/DDDataPane2.java b/src/detectionPlotFX/layout/DDDataPane2.java index 240a54f3..f73e289c 100644 --- a/src/detectionPlotFX/layout/DDDataPane2.java +++ b/src/detectionPlotFX/layout/DDDataPane2.java @@ -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); diff --git a/src/detectionPlotFX/layout/DetectionPlotDisplay.java b/src/detectionPlotFX/layout/DetectionPlotDisplay.java index 439301e9..1c77fa6e 100644 --- a/src/detectionPlotFX/layout/DetectionPlotDisplay.java +++ b/src/detectionPlotFX/layout/DetectionPlotDisplay.java @@ -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 { tabChoice=new ComboBox(); 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(); diff --git a/src/pamViewFX/fxPlotPanes/PlotPane.java b/src/pamViewFX/fxPlotPanes/PlotPane.java index 6f62eb2f..6f94e068 100644 --- a/src/pamViewFX/fxPlotPanes/PlotPane.java +++ b/src/pamViewFX/fxPlotPanes/PlotPane.java @@ -21,22 +21,22 @@ import pamViewFX.fxNodes.pamAxis.PamAxisPane2; * */ public class PlotPane extends PamBorderPane { - + /** * The x axis which sits at the top of the plot */ private PamAxisFX xAxisTop; - + /** * The x axis which sits at the bottom of the plot */ private PamAxisFX xAxisBottom; - + /** * The y Axis which sits to the left of the plot */ private PamAxisFX yAxisLeft; - + /* *The y axis which sits to right of the plot */ @@ -88,7 +88,7 @@ public class PlotPane extends PamBorderPane { * Convenience variable, an array with all axis in order, top, right, bottom, left. */ private PamAxisFX[] axisArray; - + /** * Convenience variable, an array with all axis in order, top, right, bottom, left. */ @@ -98,7 +98,7 @@ public class PlotPane extends PamBorderPane { * The holder pane for stuff */ private PamBorderPane holderPane; - + /** * Overlaid pane on canvas which can be used to add hiding panes to the plot. */ @@ -111,23 +111,33 @@ 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. */ public PlotPane(){ this.setCenter(createPlot(false)); } - - + + 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,67 +155,53 @@ 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) - - //create the panes to hold the axis; - - //create the plot pane. - canvasHolder=new PamBorderPane(); - canvasHolder.setMaxWidth(4000); - canvasHolder.setMaxHeight(4000); + //allow hiding panes to be added + hiddenSidePane=new PamHiddenSidePane(); + hiddenSidePane.getChildren().add(canvas); + hiddenSidePane.toFront(); - canvas = new Canvas(50, 50); - canvas.heightProperty().bind(canvasHolder.heightProperty()); - canvas.widthProperty().bind(canvasHolder.widthProperty()); - - - //allow hiding panes to be added - hiddenSidePane=new PamHiddenSidePane(); - hiddenSidePane.getChildren().add(canvas); - hiddenSidePane.toFront(); - - - canvasHolder.setCenter(hiddenSidePane); - canvasHolder.setMinHeight(0); - canvasHolder.setMinWidth(0); - //canvasHolder.getStyleClass().add("pane-plot"); - //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); + canvasHolder.setCenter(hiddenSidePane); + canvasHolder.setMinHeight(10); + canvasHolder.setMinWidth(10); + //canvasHolder.getStyleClass().add("pane-plot"); - setAxisVisible(true, true, true, true); + //now add all axis together + holderPane=new PamBorderPane(); - -// 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; + //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; } - - + + /** * Set a hiding pane within the plot area * @param pane - the pane whihc is hidden @@ -231,7 +227,7 @@ public class PlotPane extends PamBorderPane { break; } } - + /** * Get one of the hiding panes within the plot area * @param side - the location of the pna eon the plot (left or right) @@ -258,7 +254,7 @@ public class PlotPane extends PamBorderPane { */ private PamHBox createHorzHolder(PamAxisPane2 axisPane){ PamHBox horzHolder=new PamHBox(); - + Pane leftPane=new Pane(); //need both min and pref to make binding work properly; leftPane.prefWidthProperty().bind(yAxisLeftPane.widthProperty()); @@ -267,26 +263,26 @@ public class PlotPane extends PamBorderPane { Pane rightPane=new Pane(); 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(); + // } + + /** * Get the canvas- this is where the plotting takes place. * @return the plot canvas. @@ -294,8 +290,8 @@ public class PlotPane extends PamBorderPane { public Canvas getPlotCanvas() { return canvas; } - - + + /** * Get an axis of the plot pane. * @param side the axis to get. @@ -314,10 +310,10 @@ public class PlotPane extends PamBorderPane { default: return null; } - + } - - + + /** * Get an axis pane. The axis pane is the node which displays a PamAxisFX. * @param side the axis pane to get. @@ -337,7 +333,7 @@ public class PlotPane extends PamBorderPane { return null; } } - + /** * Get all the axis of the plot pane. * @return a list of axis in the order: TOP, RIGHT, BOTTOM, LEFT. @@ -345,7 +341,7 @@ public class PlotPane extends PamBorderPane { public PamAxisFX[] getAllAxis() { return axisArray; } - + /** * Get an axis pane * @param side the axis to get. @@ -353,14 +349,14 @@ public class PlotPane extends PamBorderPane { public PamAxisPane2[] getAllAxisPanes() { return axisPanes; } - + public void setEmptyBorders(double top, double right, double bottom, double left) { this.topBorder = top; this.rightBorder = right; this.bottomBorder = bottom; this.leftBorder = left; } - + /** * Set which axis are visible. * @param top true to show the top axis @@ -370,9 +366,9 @@ public class PlotPane extends PamBorderPane { */ public void setAxisVisible(boolean top, boolean right, boolean bottom, boolean left) { - + //holderPane.getChildren().clear(); - + //HACK- 05/08/2016 have to do this because there is a bug in switching children postions in a border pane. //casues a duplicate childrne error. holderPane.setRight(null); @@ -381,41 +377,41 @@ public class PlotPane extends PamBorderPane { holderPane.setBottom(null); holderPane.getChildren().clear(); //end of HACK. - + if (top) { 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); } - + /** * Set the minimium height of the right and left hide pane. Set -1 for there to be no minimum height. * If the hide pane goes below the minimum height it pops out of its holder. @@ -456,12 +452,12 @@ public class PlotPane extends PamBorderPane { public PamAxisFX getyAxisRight() { return yAxisRight; } - - - - - - - + + + + + + + }