mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-25 08:32:32 +00:00
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:
parent
12bf8cb5f7
commit
aa686cac5e
@ -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>
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
*
|
||||
*/
|
||||
|
@ -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
|
||||
|
@ -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,8 +23,16 @@ 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++));
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +41,7 @@ public class ModifierTreeNode implements TreeNode {
|
||||
@Override
|
||||
public TreeNode getChildAt(int childIndex) {
|
||||
return choiceNodes.get(childIndex);
|
||||
// return
|
||||
// return
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,18 +82,24 @@ public class ModifierTreeNode implements TreeNode {
|
||||
}
|
||||
|
||||
public void setModBitmap(int modBitMap) {
|
||||
for (ChoiceTreeNode cN : choiceNodes) {
|
||||
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) {
|
||||
for (TreeNode tN : choiceNodes) {
|
||||
if (tN instanceof ChoiceTreeNode) {
|
||||
ChoiceTreeNode cN = (ChoiceTreeNode) tN;
|
||||
if (cN.checkBox.isSelected()) {
|
||||
mp |= cN.selectionBit;
|
||||
}
|
||||
}
|
||||
}
|
||||
return mp;
|
||||
}
|
||||
|
||||
|
81
src/PamView/symbol/modifier/swing/OptionsTreeNode.java
Normal file
81
src/PamView/symbol/modifier/swing/OptionsTreeNode.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
@ -137,6 +137,7 @@ public class SymbolModifierPanel implements PamDialogPanel {
|
||||
JMenuItem optsItem = modifier.getModifierOptionsMenu();
|
||||
if (optsItem != null) {
|
||||
popMenu.add(optsItem);
|
||||
popMenu.addSeparator();
|
||||
}
|
||||
}
|
||||
if (nodeInd > 0) {
|
||||
|
@ -44,6 +44,10 @@ public class SymbolTreeRenderer extends DefaultTreeCellRenderer {
|
||||
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) {
|
||||
setModifierStuff((ModifierTreeNode) value, component);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user