Debian Codegraph @

src/dr/app/beauti/treespanel/GenerateTreeDialog.java

raw symbols SCIP
1 /*
2 * GenerateTreeDialog.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.app.beauti.treespanel;
27
28 import dr.app.beauti.options.AbstractPartitionData;
29 import dr.app.beauti.options.BeautiOptions;
30 import dr.app.beauti.options.PartitionData;
31 import jam.panels.OptionsPanel;
32
33 import javax.swing.*;
34 import javax.swing.border.EmptyBorder;
35
36 /**
37 * @author Andrew Rambaut
38 * @author Alexei Drummond
39 * @version $Id: PriorDialog.java,v 1.4 2006/09/05 13:29:34 rambaut Exp $
40 */
41 public class GenerateTreeDialog {
42
43 private JFrame frame;
44
45 public static enum MethodTypes {
46 NJ,
47 UPGMA
48 }
49
50
51 JTextField nameField;
52 JComboBox partitionCombo;
53 JComboBox methodCombo;
54
55 OptionsPanel optionPanel;
56
57 public GenerateTreeDialog(JFrame frame) {
58 this.frame = frame;
59
60 nameField = new JTextField();
61 nameField.setColumns(20);
62
63 methodCombo = new JComboBox(MethodTypes.values());
64 partitionCombo = new JComboBox();
65
66 optionPanel = new OptionsPanel(12, 12);
67 optionPanel.addComponentWithLabel("Name:", nameField);
68 optionPanel.addComponentWithLabel("Data Partition:", partitionCombo);
69 optionPanel.addComponentWithLabel("Construction Method:", methodCombo);
70
71
72 }
73
74 public int showDialog(BeautiOptions options) {
75
76 JOptionPane optionPane = new JOptionPane(optionPanel,
77 JOptionPane.QUESTION_MESSAGE,
78 JOptionPane.OK_CANCEL_OPTION,
79 null,
80 null,
81 null);
82 optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
83
84 partitionCombo.removeAllItems();
85 for (AbstractPartitionData partition : options.dataPartitions) {
86 partitionCombo.addItem(partition);
87 }
88 final JDialog dialog = optionPane.createDialog(frame, "Construct New Tree");
89 dialog.pack();
90
91 dialog.setVisible(true);
92
93 int result = JOptionPane.CANCEL_OPTION;
94 Integer value = (Integer) optionPane.getValue();
95 if (value != null && value != -1) {
96 result = value;
97 }
98
99 return result;
100 }
101
102 public String getName() {
103 return nameField.getText();
104 }
105
106 public PartitionData getDataPartition() {
107 return (PartitionData)partitionCombo.getSelectedItem();
108 }
109 public MethodTypes getMethodType() {
110 return (MethodTypes)methodCombo.getSelectedItem();
111 }
112 }