/* * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.gui; import jalview.io.AlignmentFileReaderI; import jalview.io.BamFile; import jalview.util.MessageManager; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.util.Arrays; import javax.swing.BorderFactory; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; /** * A dialog where a user can choose import options for a bam file */ public class BamFileOptionsChooser extends JPanel { // text field for start of range // JFormattedTextField startRange = new JFormattedTextField( // new NumberFormatter(NumberFormat.getIntegerInstance())); // text field for end of range // JFormattedTextField endRange = new JFormattedTextField( // new NumberFormatter(NumberFormat.getIntegerInstance())); JTextField startRange = new JTextField(10); JTextField endRange = new JTextField(10); // combo box for chromosome list JComboBox chroCombo; public BamFileOptionsChooser(AlignmentFileReaderI source) { Object[] preprocessResult = source.preprocess(); String[] chromosomes = Arrays.copyOf(preprocessResult, preprocessResult.length, String[].class); setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); // set up chromosome input JLabel chroLabel = new JLabel( MessageManager.getString("label.bam_chromosome")); chroCombo = new JComboBox<>(chromosomes); // set up region input JPanel range = new JPanel(); JLabel rangeLabel = new JLabel( MessageManager.getString("label.bam_range")); startRange.setColumns(8); endRange.setColumns(8); JLabel rangeSep = new JLabel("-"); range.add(startRange); range.add(rangeSep); range.add(endRange); // chromosome label top left c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; this.add(chroLabel, c); // chromosome combo top right c.gridx = 1; c.weightx = 1; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; this.add(chroCombo, c); // region label mid left c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; this.add(rangeLabel, c); // region input mid right c.gridx = 1; c.weightx = 1; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; this.add(range, c); } public void update(AlignmentFileReaderI source) { int start = Integer.parseInt(startRange.getText()); int end = Integer.parseInt(endRange.getText()); ((BamFile) source).setOptions((String) chroCombo.getSelectedItem(), start, end); } }