Debian Codegraph @

src/dr/app/coalgen/SimulationsPanel.java

raw symbols SCIP
1 /*
2 * SimulationsPanel.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.coalgen;
27
28 import jam.framework.Exportable;
29 import jam.panels.OptionsPanel;
30
31 import javax.swing.*;
32 import java.awt.*;
33 import dr.app.gui.components.WholeNumberField;
34
35 /**
36 * @author Andrew Rambaut
37 * @author Alexei Drummond
38 * @version $Id$
39 */
40 public class SimulationsPanel extends JPanel implements Exportable {
41
42 private final CoalGenFrame frame;
43 private final CoalGenData data;
44
45 private OptionsPanel optionPanel;
46
47 private final JLabel replicatesLabel = new JLabel("Number of replicates:");
48 private final WholeNumberField replicatesField = new WholeNumberField(1, Integer.MAX_VALUE);
49
50
51 public SimulationsPanel(final CoalGenFrame frame, final CoalGenData data) {
52
53 super();
54
55 this.frame = frame;
56 this.data = data;
57
58 setOpaque(false);
59 setLayout(new BorderLayout());
60
61 optionPanel = new OptionsPanel(12, 12, SwingConstants.CENTER);
62 add(optionPanel, BorderLayout.NORTH);
63
64 replicatesField.setColumns(8);
65 replicatesField.setValue(data.replicateCount);
66
67 optionPanel.addComponents(replicatesLabel, replicatesField);
68 }
69
70 public final void tracesChanged() {
71 replicatesLabel.setEnabled(data.traces == null);
72 replicatesField.setEnabled(data.traces == null);
73 if (data.traces != null) {
74 replicatesField.setValue(data.traces.getStateCount());
75 }
76
77 replicatesField.setValue(data.replicateCount);
78 }
79
80 public final void collectSettings() {
81 data.replicateCount = replicatesField.getValue();
82 }
83
84 public JComponent getExportableComponent() {
85 return this;
86 }
87 }