import jalview.api.analysis.SimilarityParamsI;
import jalview.util.MessageManager;
+import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
+import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
+import java.awt.Insets;
import java.awt.event.ActionEvent;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyVetoException;
import java.util.ArrayList;
import java.util.List;
+import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
JRadioButton pca;
- JRadioButton tree;
-
JRadioButton neighbourJoining;
JRadioButton averageDistance;
JComboBox<String> modelNames;
- private JInternalFrame frame;
+ JButton ok;
- private ButtonGroup treeTypes;
+ private JInternalFrame frame;
private JCheckBox includeGaps;
*/
void init()
{
+ setLayout(new BorderLayout());
frame = new JInternalFrame();
frame.setContentPane(this);
this.setBackground(Color.white);
/*
- * Layout consists of 4 or 5 panels:
- * - first with choice of Tree or PCA
- * - second with choice of tree method NJ or AV
- * - third with choice of score model
- * - fourth with score model parameter options [suppressed]
- * - fifth with OK and Cancel
+ * Layout consists of 3 or 4 panels:
+ * - first with choice of PCA or tree method NJ or AV
+ * - second with choice of score model
+ * - third with score model parameter options [suppressed]
+ * - fourth with OK and Cancel
*/
- tree = new JRadioButton(MessageManager.getString("label.tree"));
- tree.setOpaque(false);
pca = new JRadioButton(
MessageManager.getString("label.principal_component_analysis"));
pca.setOpaque(false);
MessageManager.getString("label.tree_calc_nj"));
averageDistance = new JRadioButton(
MessageManager.getString("label.tree_calc_av"));
- ItemListener listener = new ItemListener()
+ neighbourJoining.setOpaque(false);
+
+ JPanel calcChoicePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ calcChoicePanel.setOpaque(false);
+
+ // first create the Tree calculation's border panel
+ JPanel treePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ treePanel.setOpaque(false);
+
+ treePanel.setBorder(BorderFactory.createTitledBorder(MessageManager
+ .getString("label.tree")));
+
+ // then copy the inset dimensions for the border-less PCA panel
+ JPanel pcaBorderless = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ Insets b = treePanel.getBorder().getBorderInsets(treePanel);
+ pcaBorderless.setBorder(BorderFactory.createEmptyBorder(2, b.left, 2,
+ b.right));
+ pcaBorderless.setOpaque(false);
+
+ pcaBorderless.add(pca, FlowLayout.LEFT);
+ calcChoicePanel.add(pcaBorderless, FlowLayout.LEFT);
+
+
+ treePanel.add(neighbourJoining);
+ treePanel.add(averageDistance);
+
+ calcChoicePanel.add(treePanel);
+
+ ButtonGroup calcTypes = new ButtonGroup();
+ calcTypes.add(pca);
+ calcTypes.add(neighbourJoining);
+ calcTypes.add(averageDistance);
{
@Override
public void itemStateChanged(ItemEvent e)
averageDistance.setEnabled(tree.isSelected());
}
};
- pca.addItemListener(listener);
- tree.addItemListener(listener);
- ButtonGroup calcTypes = new ButtonGroup();
- calcTypes.add(pca);
- calcTypes.add(tree);
- JPanel calcChoicePanel = new JPanel();
- calcChoicePanel.setOpaque(false);
- tree.setSelected(true);
- calcChoicePanel.add(tree);
- calcChoicePanel.add(pca);
-
- neighbourJoining.setOpaque(false);
- treeTypes = new ButtonGroup();
- treeTypes.add(neighbourJoining);
- treeTypes.add(averageDistance);
- neighbourJoining.setSelected(true);
- JPanel treeChoicePanel = new JPanel();
- treeChoicePanel.setOpaque(false);
- treeChoicePanel.add(neighbourJoining);
- treeChoicePanel.add(averageDistance);
/*
* score models drop-down - with added tooltips!
*/
modelNames = buildModelOptionsList();
- JPanel scoreModelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ JPanel scoreModelPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
scoreModelPanel.setOpaque(false);
- scoreModelPanel.add(modelNames, FlowLayout.LEFT);
+ scoreModelPanel.add(modelNames);
/*
* score model parameters
actionPanel.add(cancel);
boolean includeParams = false;
- this.add(calcChoicePanel);
- this.add(treeChoicePanel);
- this.add(scoreModelPanel);
+ this.add(calcChoicePanel, BorderLayout.CENTER);
+ calcChoicePanel.add(scoreModelPanel);
if (includeParams)
{
- this.add(paramsPanel);
+ scoreModelPanel.add(paramsPanel);
}
- this.add(actionPanel);
+ this.add(actionPanel, BorderLayout.SOUTH);
int width = 350;
- int height = includeParams ? 400 : 220;
+ int height = includeParams ? 420 : 240;
+
+ setMinimumSize(new Dimension(325, height - 10));
String title = MessageManager.getString("label.choose_calculation");
if (af.getViewport().viewName != null)
{
Desktop.addInternalFrame(frame,
title, width,
height, false);
-
+ calcChoicePanel.doLayout();
+ revalidate();
/*
* null the AlignmentPanel's reference to the dialog when it is closed
*/