Squashed commit of the following:

commit bad2255710
Author: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com>
Date:   Thu Jul 18 09:47:47 2024 +0100

    Better symbol options

    Add clearer options button to multi option symbol manager panel.
This commit is contained in:
Jamie Mac 2024-07-18 10:36:26 +01:00
parent 12bf8cb5f7
commit aa686cac5e
10 changed files with 167 additions and 13 deletions

View File

@ -4,7 +4,7 @@
<groupId>org.pamguard</groupId>
<artifactId>Pamguard</artifactId>
<name>Pamguard</name>
<version>2.02.11f</version>
<version>2.02.12</version>
<description>Pamguard using Maven to control dependencies</description>
<url>www.pamguard.org</url>
<organization>

View File

@ -10,6 +10,8 @@ import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import PamController.PamController;
public class GenericSwingDialog extends PamDialog {
private boolean allOk;
@ -45,6 +47,9 @@ public class GenericSwingDialog extends PamDialog {
* @return
*/
public static boolean showDialog(Window parentFrame, String title, Point screenPoint, PamDialogPanel ...dialogPanels) {
if (parentFrame == null) {
parentFrame = PamController.getMainFrame();
}
GenericSwingDialog swingDialog = new GenericSwingDialog(parentFrame, title, dialogPanels);
swingDialog.setParams();
swingDialog.pack();

View File

@ -5,6 +5,7 @@ import javax.swing.JComponent;
/**
* General class for dialog panels which will be incorporated into one or
* more actual dialogs.
* Can be quickly opened with GenericSwingDialog
* @author Doug Gillespie
*
*/

View File

@ -150,7 +150,8 @@ abstract public class SymbolModifier {
if (dialogPanel == null) {
return null;
}
JMenuItem menuItem = new JMenuItem("Options ...");
JMenuItem menuItem = new JMenuItem("More options ...");
menuItem.setToolTipText("More symbol options");
menuItem.addActionListener(new ActionListener() {
@Override

View File

@ -8,12 +8,13 @@ import java.util.Enumeration;
import javax.swing.tree.TreeNode;
import PamUtils.PamUtils;
import PamView.dialog.PamDialogPanel;
import PamView.symbol.modifier.SymbolModifier;
public class ModifierTreeNode implements TreeNode {
private SymbolModifier modifier;
private SymbolTreeRoot rootNode;
private ArrayList<ChoiceTreeNode> choiceNodes;
private ArrayList<TreeNode> choiceNodes;
public ModifierTreeNode(SymbolTreeRoot rootNode, SymbolModifier modifier) {
super();
@ -22,17 +23,25 @@ public class ModifierTreeNode implements TreeNode {
int modBits = modifier.getModifyableBits();
int nMod = Integer.bitCount(modBits);
choiceNodes = new ArrayList<>();
int leafIndex = 0;
for (int i = 0; i < nMod; i++) {
choiceNodes.add(new ChoiceTreeNode(this, 1<<PamUtils.getNthChannel(i, modBits), i));
choiceNodes.add(new ChoiceTreeNode(this, 1<<PamUtils.getNthChannel(i, modBits), leafIndex++));
}
PamDialogPanel optionsPanel = modifier.getDialogPanel();
if (optionsPanel != null) {
choiceNodes.add(new OptionsTreeNode(this, modifier, optionsPanel, leafIndex++));
}
}
@Override
public TreeNode getChildAt(int childIndex) {
return choiceNodes.get(childIndex);
// return
// return
}
@Override
@ -73,16 +82,22 @@ public class ModifierTreeNode implements TreeNode {
}
public void setModBitmap(int modBitMap) {
for (ChoiceTreeNode cN : choiceNodes) {
cN.checkBox.setSelected((cN.selectionBit & modBitMap) != 0);
for (TreeNode tN : choiceNodes) {
if (tN instanceof ChoiceTreeNode) {
ChoiceTreeNode cN = (ChoiceTreeNode) tN;
cN.checkBox.setSelected((cN.selectionBit & modBitMap) != 0);
}
}
}
public int getModBitmap() {
int mp = 0;
for (ChoiceTreeNode cN : choiceNodes) {
if (cN.checkBox.isSelected()) {
mp |= cN.selectionBit;
for (TreeNode tN : choiceNodes) {
if (tN instanceof ChoiceTreeNode) {
ChoiceTreeNode cN = (ChoiceTreeNode) tN;
if (cN.checkBox.isSelected()) {
mp |= cN.selectionBit;
}
}
}
return mp;

View File

@ -0,0 +1,81 @@
package PamView.symbol.modifier.swing;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Enumeration;
import javax.swing.JButton;
import javax.swing.tree.TreeNode;
import PamView.dialog.GenericSwingDialog;
import PamView.dialog.PamDialogPanel;
import PamView.symbol.modifier.SymbolModifier;
public class OptionsTreeNode implements TreeNode {
private ModifierTreeNode parent;
private SymbolModifier modifier;
private PamDialogPanel optionsPanel;
protected JButton optionsButton;
private int leafIndex;
public OptionsTreeNode(ModifierTreeNode parent, SymbolModifier modifier, PamDialogPanel optionsPanel, int leafIndex) {
this.parent = parent;
this.modifier = modifier;
this.optionsPanel = optionsPanel;
this.leafIndex = leafIndex;
optionsButton = new JButton("more ...");
optionsButton.setToolTipText("More symbol options");
optionsButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
showOptions();
}
});
}
private void showOptions() {
optionsPanel.setParams();
boolean ok = GenericSwingDialog.showDialog(null, "Options", optionsPanel);
if (ok) {
optionsPanel.getParams();
}
}
@Override
public TreeNode getChildAt(int childIndex) {
return null;
}
@Override
public int getChildCount() {
return 0;
}
@Override
public TreeNode getParent() {
return parent;
}
@Override
public int getIndex(TreeNode node) {
return leafIndex;
}
@Override
public boolean getAllowsChildren() {
return false;
}
@Override
public boolean isLeaf() {
return true;
}
@Override
public Enumeration<? extends TreeNode> children() {
return null;
}
}

View File

@ -137,6 +137,7 @@ public class SymbolModifierPanel implements PamDialogPanel {
JMenuItem optsItem = modifier.getModifierOptionsMenu();
if (optsItem != null) {
popMenu.add(optsItem);
popMenu.addSeparator();
}
}
if (nodeInd > 0) {

View File

@ -43,6 +43,10 @@ public class SymbolTreeRenderer extends DefaultTreeCellRenderer {
if (value instanceof ChoiceTreeNode) {
return checkboxChoice(tree, (ChoiceTreeNode) value, sel, expanded, leaf, row, hasFocus);
}
if (value instanceof OptionsTreeNode) {
return ((OptionsTreeNode) value).optionsButton;
}
Component component = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if (value instanceof ModifierTreeNode) {

View File

@ -1,7 +1,13 @@
package clickDetector.tdPlots;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
import PamView.GeneralProjector;
import PamView.PamSymbol;
import PamView.dialog.PamDialogPanel;
import PamView.symbol.PamSymbolChooser;
import PamView.symbol.SymbolData;
import PamView.symbol.modifier.SymbolModType;
@ -32,4 +38,41 @@ public class ClickClassSymbolModifier extends SymbolModifier {
}
}
@Override
public PamDialogPanel getDialogPanel() {
// Just a play to check buttons and menus work. Not actually used at all so revert to super: returns null.
return super.getDialogPanel();
// return new DumyPanel();
}
private class DumyPanel implements PamDialogPanel {
private JPanel mainPanel;
public DumyPanel() {
super();
mainPanel = new JPanel();
mainPanel.setBorder(new TitledBorder("More options"));
mainPanel.add(new JCheckBox("Dummy option"));
}
@Override
public JComponent getDialogComponent() {
// TODO Auto-generated method stub
return mainPanel;
}
@Override
public void setParams() {
// TODO Auto-generated method stub
}
@Override
public boolean getParams() {
// TODO Auto-generated method stub
return false;
}
}
}

View File

@ -39,6 +39,9 @@ public class WMDDataSelector extends DataSelector {
@Override
public double scoreData(PamDataUnit pamDataUnit) {
if (getParams().getCombinationFlag() == DataSelectParams.DATA_SELECT_DISABLE) {
return 1;
}
ConnectedRegionDataUnit crDataUnit = (ConnectedRegionDataUnit) pamDataUnit;
return (wantWhistle(crDataUnit) ? 1: 0);
}