From c01e966eafce596e9709c8b69bb9969530fd4ee9 Mon Sep 17 00:00:00 2001 From: Jamie Mac Date: Thu, 18 Jul 2024 16:37:15 +0100 Subject: [PATCH] Fix bugs in detection display --- .../modifier/swing/OptionsTreeNode.java | 6 +++ .../modifier/swing/SymbolModifierPanel.java | 2 - src/pamViewFX/PamGuiTabFX.java | 18 +++++-- src/pamViewFX/fxPlotPanes/PlotPane.java | 47 +++++++++++++++---- 4 files changed, 58 insertions(+), 15 deletions(-) diff --git a/src/PamView/symbol/modifier/swing/OptionsTreeNode.java b/src/PamView/symbol/modifier/swing/OptionsTreeNode.java index ea4e9857..42c69408 100644 --- a/src/PamView/symbol/modifier/swing/OptionsTreeNode.java +++ b/src/PamView/symbol/modifier/swing/OptionsTreeNode.java @@ -1,10 +1,12 @@ package PamView.symbol.modifier.swing; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Enumeration; import javax.swing.JButton; +import javax.swing.border.EmptyBorder; import javax.swing.tree.TreeNode; import PamView.dialog.GenericSwingDialog; @@ -25,6 +27,10 @@ public class OptionsTreeNode implements TreeNode { this.optionsPanel = optionsPanel; this.leafIndex = leafIndex; optionsButton = new JButton("more ..."); + Insets insets = optionsButton.getInsets(); + if (insets == null) insets = new Insets(0,0,0,0); + insets.bottom = insets.top = insets.left = 1; + optionsButton.setBorder(new EmptyBorder(insets)); optionsButton.setToolTipText("More symbol options"); optionsButton.addActionListener(new ActionListener() { diff --git a/src/PamView/symbol/modifier/swing/SymbolModifierPanel.java b/src/PamView/symbol/modifier/swing/SymbolModifierPanel.java index 70fa539b..ddef072e 100644 --- a/src/PamView/symbol/modifier/swing/SymbolModifierPanel.java +++ b/src/PamView/symbol/modifier/swing/SymbolModifierPanel.java @@ -18,12 +18,10 @@ import javax.swing.tree.TreePath; import PamView.dialog.DialogScrollPane; import PamView.dialog.PamDialogPanel; -import PamView.symbol.PamSymbolChooser; import PamView.symbol.StandardSymbolChooser; import PamView.symbol.StandardSymbolOptions; import PamView.symbol.modifier.SymbolModifier; import PamView.symbol.modifier.SymbolModifierParams; -import PamguardMVC.debug.Debug; /** * Panel to include in a dialog with options to select and activate a variety of symbol modifiers. diff --git a/src/pamViewFX/PamGuiTabFX.java b/src/pamViewFX/PamGuiTabFX.java index 9e1f3fb2..42fc18d8 100644 --- a/src/pamViewFX/PamGuiTabFX.java +++ b/src/pamViewFX/PamGuiTabFX.java @@ -253,6 +253,10 @@ public class PamGuiTabFX extends PamTabFX { double r1 = 1 - r; int smallWindows = 0; + + + //the padding between windows + double padding = 10; ArrayList dw = internalPanes; @@ -268,7 +272,9 @@ public class PamGuiTabFX extends PamTabFX { //now place windows in correct position //large windows - double x, y, w, h = 0; + double x, y, w, h = 0.; + double pad =0.; + if (largeWindows > 0) { x = 0; y = 0; @@ -284,7 +290,10 @@ public class PamGuiTabFX extends PamTabFX { if (dw.get(i).getUserDisplayNode().isMinorDisplay()== true) continue; dw.get(i).setPaneLayout(x, y); - dw.get(i).setPaneSize(w, h); + + //set the padding if the pane is not the last pane. + pad = (i== dw.size()-1) ? 0 : padding; + dw.get(i).setPaneSize(w - (horz? pad:0), h - (horz? 0:pad)); if (horz) x += w; else y += h; } @@ -307,7 +316,10 @@ public class PamGuiTabFX extends PamTabFX { for (int i = 0; i < dw.size(); i++) { if (dw.get(i).getUserDisplayNode().isMinorDisplay() == false) continue; dw.get(i).setPaneLayout(x, y); - dw.get(i).setPaneSize(w, h); + + //set the padding if the pane is not the last pane. + pad = (i== dw.size()-1) ? 0 : padding; + dw.get(i).setPaneSize(w- (horz? pad:0), h - (horz? 0:pad)); if (horz) x += w; else y +=h; } diff --git a/src/pamViewFX/fxPlotPanes/PlotPane.java b/src/pamViewFX/fxPlotPanes/PlotPane.java index f85fc79b..30355c8e 100644 --- a/src/pamViewFX/fxPlotPanes/PlotPane.java +++ b/src/pamViewFX/fxPlotPanes/PlotPane.java @@ -1,6 +1,9 @@ package pamViewFX.fxPlotPanes; import Layout.PamAxis; +import javafx.beans.binding.Bindings; +import javafx.beans.property.SimpleDoubleProperty; +import javafx.beans.value.ObservableValue; import javafx.geometry.Side; import javafx.scene.Node; import javafx.scene.canvas.Canvas; @@ -256,13 +259,31 @@ public class PlotPane extends PamBorderPane { PamHBox horzHolder=new PamHBox(); Pane leftPane=new Pane(); + + //create an observable which is the size of the axis pane if the pane is visible and otherwise + //is zero. + ObservableValue valLeft = Bindings + .when(yAxisLeftPane.visibleProperty()) + .then(yAxisLeftPane.widthProperty()) + .otherwise( + new SimpleDoubleProperty(0.) + ); + //need both min and pref to make binding work properly; - leftPane.prefWidthProperty().bind(yAxisLeftPane.widthProperty()); - leftPane.minWidthProperty().bind(yAxisLeftPane.widthProperty()); + leftPane.prefWidthProperty().bind(valLeft); + leftPane.minWidthProperty().bind(valLeft); Pane rightPane=new Pane(); - rightPane.prefWidthProperty().bind(yAxisRightPane.widthProperty()); - rightPane.minWidthProperty().bind(yAxisRightPane.widthProperty()); + + ObservableValue valRight = Bindings + .when(yAxisRightPane.visibleProperty()) + .then(yAxisRightPane.widthProperty()) + .otherwise( + new SimpleDoubleProperty(0.) + ); + + rightPane.prefWidthProperty().bind(valRight); + rightPane.minWidthProperty().bind(valRight); horzHolder.getChildren().addAll(leftPane, axisPane, rightPane); //axisPane.toFront(); this changes the order of children in a PamHBox. @@ -369,8 +390,8 @@ public class PlotPane extends PamBorderPane { //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. + //HACK- 05/08/2016 have to do this because there is a bug in switching children positions in a border pane. + //causes duplicate children error holderPane.setRight(null); holderPane.setLeft(null); holderPane.setTop(null); @@ -385,24 +406,30 @@ public class PlotPane extends PamBorderPane { else if (topBorder > 0) { // holderPane.setTopSpace(topBorder); } + if (bottom) { holderPane.setBottom(bottomHolder); } else if (bottomBorder > 0) { // holderPane.setBottomSpace(bottomBorder); } + if (right) { holderPane.setRight(yAxisRightPane) ; + yAxisRightPane.setVisible(true); } - else if (rightBorder > 0){ - // holderPane.setRightSpace(rightBorder); + else { + yAxisRightPane.setVisible(false); } + if (left) { holderPane.setLeft(yAxisLeftPane) ; + yAxisLeftPane.setVisible(true); } - else if (leftBorder > 0) { - // holderPane.setLeftSpace(leftBorder); + else { + yAxisLeftPane.setVisible(false); } + holderPane.setCenter(canvasHolder); //bottomHolder.toBack();