From ccfe63de177540228855a8361ed0f46061830aea Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 2 May 2017 17:53:53 +0100 Subject: [PATCH] =?utf8?q?JAL-1632=20removed=20=E2=80=98tree=E2=80=99=20opti?= =?utf8?q?on=20and=20changed=20dialog=20layout?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/gui/CalculationChooser.java | 102 ++++++++++++++++++------------- 1 file changed, 58 insertions(+), 44 deletions(-) diff --git a/src/jalview/gui/CalculationChooser.java b/src/jalview/gui/CalculationChooser.java index ee67d06..27e05c6 100644 --- a/src/jalview/gui/CalculationChooser.java +++ b/src/jalview/gui/CalculationChooser.java @@ -27,20 +27,25 @@ import jalview.api.analysis.ScoreModelI; 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; @@ -72,17 +77,15 @@ public class CalculationChooser extends JPanel JRadioButton pca; - JRadioButton tree; - JRadioButton neighbourJoining; JRadioButton averageDistance; JComboBox modelNames; - private JInternalFrame frame; + JButton ok; - private ButtonGroup treeTypes; + private JInternalFrame frame; private JCheckBox includeGaps; @@ -109,20 +112,18 @@ public class CalculationChooser extends JPanel */ 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); @@ -130,7 +131,38 @@ public class CalculationChooser extends JPanel 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) @@ -139,35 +171,15 @@ public class CalculationChooser extends JPanel 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 @@ -213,17 +225,18 @@ public class CalculationChooser extends JPanel 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) { @@ -233,7 +246,8 @@ public class CalculationChooser extends JPanel Desktop.addInternalFrame(frame, title, width, height, false); - + calcChoicePanel.doLayout(); + revalidate(); /* * null the AlignmentPanel's reference to the dialog when it is closed */ -- 1.7.10.2