Debian Codegraph @

src/dr/app/beauti/traitspanel/TraitValueDialog.java

raw symbols SCIP
1 /*
2 * TraitValueDialog.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.traitspanel;
27
28 import dr.app.beauti.options.TraitGuesser;
29 import jam.panels.OptionsPanel;
30
31 import javax.swing.*;
32 import javax.swing.border.EmptyBorder;
33 import java.awt.event.ItemEvent;
34 import java.awt.event.ItemListener;
35
36
37 /**
38 * @author Andrew Rambaut
39 * @author Alexei Drummond
40 * @author Walter Xie
41 * @version $Id: GuessTraitDialog.java,v 1.4 2009/05/25 13:29:34 rambaut Exp $
42 */
43 public class TraitValueDialog {
44
45 private JFrame frame;
46 private final OptionsPanel optionPanel;
47
48 JLabel descriptionText = new JLabel();
49
50 private final JTextField valueText = new JTextField(16);
51
52 public TraitValueDialog(JFrame frame) {
53 this.frame = frame;
54
55 optionPanel = new OptionsPanel(12, 12);
56
57 optionPanel.addSpanningComponent(descriptionText);
58 optionPanel.addComponentWithLabel("Value: ", valueText);
59 }
60
61 public void setDescription(String description) {
62 descriptionText.setText(description);
63 }
64
65 public int showDialog() {
66
67 JOptionPane optionPane = new JOptionPane(optionPanel,
68 JOptionPane.QUESTION_MESSAGE,
69 JOptionPane.OK_CANCEL_OPTION,
70 null,
71 null,
72 null);
73 optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
74
75 final JDialog dialog = optionPane.createDialog(frame, "Set Trait Value for Taxa");
76 dialog.pack();
77
78 dialog.setVisible(true);
79
80 int result = JOptionPane.CANCEL_OPTION;
81 Integer value = (Integer) optionPane.getValue();
82 if (value != null && value != -1) {
83 result = value;
84 }
85
86 return result;
87 }
88
89 public String getTraitValue() {
90 return valueText.getText();
91 }
92 }