Debian Codegraph @

src/dr/app/treespace/inputpanel/InputFileSettingsDialog.java

raw symbols SCIP
1 /*
2 * InputFileSettingsDialog.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.treespace.inputpanel;
27
28 import dr.app.gui.components.RealNumberField;
29 import jam.panels.OptionsPanel;
30 import dr.app.gui.components.WholeNumberField;
31
32 import javax.swing.*;
33 import javax.swing.border.EmptyBorder;
34
35 import dr.app.treespace.InputFile;
36
37 /**
38 * @author Andrew Rambaut
39 * @version $Id:$
40 */
41 public class InputFileSettingsDialog {
42
43 private JFrame frame;
44
45 private WholeNumberField burninField;
46 private RealNumberField mrsdField;
47
48 private OptionsPanel optionPanel;
49
50 private InputFile inputFile = null;
51
52 public InputFileSettingsDialog(JFrame frame) {
53 this.frame = frame;
54
55 burninField = new WholeNumberField(0, Integer.MAX_VALUE);
56 burninField.setColumns(8);
57
58 mrsdField = new RealNumberField(0, Double.POSITIVE_INFINITY);
59 mrsdField.setColumns(20);
60
61 optionPanel = new OptionsPanel(12, 12);
62 }
63
64 private void setupPanel(InputFile inputFile) {
65 optionPanel.removeAll();
66
67 if (inputFile.getTree() != null) {
68 if (inputFile.getType() == InputFile.Type.POSTERIOR_TREES) {
69 optionPanel.addComponentWithLabel("Burnin (number of trees):", burninField);
70 burninField.setValue(inputFile.getBurnin());
71 }
72
73 optionPanel.addComponentWithLabel("Most recently sampled date:", mrsdField);
74 mrsdField.setValue(inputFile.getMostRecentSampleDate());
75 }
76
77 }
78
79 public int showDialog(InputFile inputFile) {
80
81 this.inputFile = inputFile;
82
83 setupPanel(inputFile);
84
85 final JOptionPane optionPane = new JOptionPane(optionPanel,
86 JOptionPane.QUESTION_MESSAGE,
87 JOptionPane.OK_CANCEL_OPTION,
88 null,
89 null,
90 null);
91 optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
92
93 final JDialog dialog = optionPane.createDialog(frame, "Edit Input File Settings");
94 dialog.pack();
95
96
97 int result = JOptionPane.CANCEL_OPTION;
98
99 dialog.setVisible(true);
100
101 Integer value = (Integer) optionPane.getValue();
102 if (value != null && value != -1) {
103 result = value;
104 }
105
106 return result;
107 }
108
109 public InputFile getInputFile() {
110 inputFile.setBurnin(burninField.getValue());
111 inputFile.setMostRecentSampleDate(mrsdField.getValue());
112 return inputFile;
113 }
114
115 }