2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.io.AlignmentFileReaderI;
24 import jalview.io.BamFile;
25 import jalview.util.MessageManager;
27 import java.awt.GridBagConstraints;
28 import java.awt.GridBagLayout;
29 import java.util.Arrays;
31 import javax.swing.BorderFactory;
32 import javax.swing.JComboBox;
33 import javax.swing.JLabel;
34 import javax.swing.JPanel;
35 import javax.swing.JTextField;
38 * A dialog where a user can choose import options for a bam file
40 public class BamFileOptionsChooser extends JPanel
43 // text field for start of range
44 // JFormattedTextField startRange = new JFormattedTextField(
45 // new NumberFormatter(NumberFormat.getIntegerInstance()));
47 // text field for end of range
48 // JFormattedTextField endRange = new JFormattedTextField(
49 // new NumberFormatter(NumberFormat.getIntegerInstance()));
51 JTextField startRange = new JTextField(10);
53 JTextField endRange = new JTextField(10);
55 // combo box for chromosome list
56 JComboBox<String> chroCombo;
58 public BamFileOptionsChooser(AlignmentFileReaderI source)
60 Object[] preprocessResult = source.preprocess();
61 String[] chromosomes = Arrays.copyOf(preprocessResult,
62 preprocessResult.length, String[].class);
64 setLayout(new GridBagLayout());
65 GridBagConstraints c = new GridBagConstraints();
67 setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
69 // set up chromosome input
70 JLabel chroLabel = new JLabel(
71 MessageManager.getString("label.bam_chromosome"));
72 chroCombo = new JComboBox<>(chromosomes);
74 // set up region input
75 JPanel range = new JPanel();
76 JLabel rangeLabel = new JLabel(
77 MessageManager.getString("label.bam_range"));
78 startRange.setColumns(8);
79 endRange.setColumns(8);
81 JLabel rangeSep = new JLabel("-");
82 range.add(startRange);
86 // chromosome label top left
89 c.anchor = GridBagConstraints.WEST;
90 c.fill = GridBagConstraints.NONE;
91 this.add(chroLabel, c);
93 // chromosome combo top right
96 c.anchor = GridBagConstraints.WEST;
97 c.fill = GridBagConstraints.HORIZONTAL;
98 this.add(chroCombo, c);
100 // region label mid left
103 c.anchor = GridBagConstraints.WEST;
104 c.fill = GridBagConstraints.NONE;
105 this.add(rangeLabel, c);
107 // region input mid right
110 c.anchor = GridBagConstraints.WEST;
111 c.fill = GridBagConstraints.HORIZONTAL;
115 public void update(AlignmentFileReaderI source)
118 int start = Integer.parseInt(startRange.getText());
119 int end = Integer.parseInt(endRange.getText());
120 ((BamFile) source).setOptions((String) chroCombo.getSelectedItem(),