~ubuntu-branches/ubuntu/utopic/figtree/utopic

« back to all changes in this revision

Viewing changes to src/figtree/treeviewer/annotations/SelectAnnotationDialog.java

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Tille
  • Date: 2011-02-21 08:17:38 UTC
  • Revision ID: james.westby@ubuntu.com-20110221081738-80pe2ulo8rg7up10
Tags: upstream-1.3.1
ImportĀ upstreamĀ versionĀ 1.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * DemographicDialog.java
 
3
 *
 
4
 * (c) 2002-2005 BEAST Development Core Team
 
5
 *
 
6
 * This package may be distributed under the
 
7
 * Lesser Gnu Public Licence (LGPL)
 
8
 */
 
9
package figtree.treeviewer.annotations;
 
10
 
 
11
import jam.panels.OptionsPanel;
 
12
 
 
13
import javax.swing.*;
 
14
import javax.swing.border.EmptyBorder;
 
15
import java.util.List;
 
16
 
 
17
/**
 
18
 * DemographicDialog.java
 
19
 *
 
20
 * Title:                       Tracer
 
21
 * Description:         An application for analysing MCMC trace files.
 
22
 * @author                      Andrew Rambaut
 
23
 * @author                      Alexei Drummond
 
24
 * @version                     $Id: AnnotationDialog.java,v 1.5 2007/09/04 23:54:44 rambaut Exp $
 
25
 */
 
26
public class SelectAnnotationDialog {
 
27
 
 
28
    private JFrame frame;
 
29
    private OptionsPanel options;
 
30
    private JComboBox annotationCombo;
 
31
 
 
32
    public SelectAnnotationDialog(JFrame frame) {
 
33
        this.frame = frame;
 
34
    }
 
35
 
 
36
    public int showDialog(List<String> annotationNames) {
 
37
 
 
38
        options = new OptionsPanel(6, 6);
 
39
 
 
40
        annotationCombo = new JComboBox(annotationNames.toArray());
 
41
        annotationCombo.setSelectedIndex(0);
 
42
        setupOptionsPanel();
 
43
 
 
44
        JOptionPane optionPane = new JOptionPane(options,
 
45
                JOptionPane.QUESTION_MESSAGE,
 
46
                JOptionPane.OK_CANCEL_OPTION,
 
47
                null,
 
48
                null,
 
49
                null);
 
50
        optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));
 
51
 
 
52
        final JDialog dialog = optionPane.createDialog(frame, "Select Annotation");
 
53
        dialog.pack();
 
54
 
 
55
        dialog.setVisible(true);
 
56
 
 
57
        int result = JOptionPane.CANCEL_OPTION;
 
58
        Integer value = (Integer)optionPane.getValue();
 
59
        if (value != null && value.intValue() != -1) {
 
60
            result = value.intValue();
 
61
        }
 
62
 
 
63
        return result;
 
64
    }
 
65
 
 
66
    private void setupOptionsPanel() {
 
67
        options.removeAll();
 
68
 
 
69
        options.addComponentWithLabel("Annotation:", annotationCombo);
 
70
 
 
71
    }
 
72
 
 
73
    public String getAnnotationName() {
 
74
        return (String)annotationCombo.getSelectedItem();
 
75
    }
 
76
 
 
77
 
 
78
}
 
 
b'\\ No newline at end of file'