X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FCalculationChooser.java;h=27e05c644a0166af022588644ac3b8feb61a60a6;hb=ccfe63de177540228855a8361ed0f46061830aea;hp=ee67d065b484e45cf9a12ffdb908332171c5c22d;hpb=a7d1a5ed63200f60f5365322e0711ddb05563409;p=jalview.git 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 */