2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.jbgui;
22 import java.awt.event.*;
24 import javax.swing.event.*;
25 import jalview.io.FormatAdapter;
26 import jalview.datamodel.SequenceI;
27 import java.awt.BorderLayout;
32 JLabel jLabel1 = new JLabel();
33 protected JButton findAll = new JButton();
34 protected JButton findNext = new JButton();
35 JPanel jPanel1 = new JPanel();
36 GridLayout gridLayout1 = new GridLayout();
37 protected JButton createNewGroup = new JButton();
38 JScrollPane jScrollPane1 = new JScrollPane();
39 protected JTextArea textfield = new JTextArea();
40 BorderLayout borderLayout1 = new BorderLayout();
41 JPanel jPanel2 = new JPanel();
42 JPanel jPanel3 = new JPanel();
43 JPanel jPanel4 = new JPanel();
44 BorderLayout borderLayout2 = new BorderLayout();
45 JPanel jPanel6 = new JPanel();
46 protected JCheckBox caseSensitive = new JCheckBox();
62 jLabel1.setFont(new java.awt.Font("Verdana", 0, 12));
63 jLabel1.setText("Find");
64 this.setLayout(borderLayout1);
65 findAll.setFont(new java.awt.Font("Verdana", 0, 12));
66 findAll.setText("Find all");
67 findAll.addActionListener(new java.awt.event.ActionListener()
69 public void actionPerformed(ActionEvent e)
71 findAll_actionPerformed(e);
74 findNext.setEnabled(false);
75 findNext.setFont(new java.awt.Font("Verdana", 0, 12));
76 findNext.setText("Find Next");
77 findNext.addActionListener(new java.awt.event.ActionListener()
79 public void actionPerformed(ActionEvent e)
81 findNext_actionPerformed(e);
84 jPanel1.setLayout(gridLayout1);
85 gridLayout1.setHgap(0);
86 gridLayout1.setRows(3);
87 gridLayout1.setVgap(2);
88 createNewGroup.setEnabled(false);
89 createNewGroup.setFont(new java.awt.Font("Verdana", 0, 12));
90 createNewGroup.setToolTipText("");
91 createNewGroup.setMargin(new Insets(0, 0, 0, 0));
92 createNewGroup.setText("New Feature");
93 createNewGroup.addActionListener(new java.awt.event.ActionListener()
95 public void actionPerformed(ActionEvent e)
97 createNewGroup_actionPerformed(e);
100 textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 12));
101 textfield.setText("");
102 textfield.setLineWrap(true);
103 textfield.addCaretListener(new CaretListener()
105 public void caretUpdate(CaretEvent e)
107 textfield_caretUpdate(e);
110 textfield.addKeyListener(new java.awt.event.KeyAdapter() {
111 public void keyPressed(KeyEvent e) {
112 textfield_keyPressed(e);
116 borderLayout1.setHgap(5);
117 borderLayout1.setVgap(5);
118 jPanel4.setLayout(borderLayout2);
119 jPanel2.setPreferredSize(new Dimension(10, 1));
120 jPanel3.setPreferredSize(new Dimension(10, 1));
121 caseSensitive.setHorizontalAlignment(SwingConstants.LEFT);
122 caseSensitive.setText("Match Case");
123 jPanel1.add(findNext, null);
124 jPanel1.add(findAll, null);
125 jPanel1.add(createNewGroup, null);
126 this.add(jLabel1, java.awt.BorderLayout.WEST);
127 this.add(jPanel1, java.awt.BorderLayout.EAST);
128 this.add(jPanel2, java.awt.BorderLayout.SOUTH);
129 this.add(jPanel3, java.awt.BorderLayout.NORTH);
130 this.add(jPanel4, java.awt.BorderLayout.CENTER);
131 jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER);
132 jScrollPane1.getViewport().add(textfield);
133 jPanel4.add(jPanel6, java.awt.BorderLayout.NORTH);
134 jPanel4.add(caseSensitive, java.awt.BorderLayout.SOUTH);
137 protected void findNext_actionPerformed(ActionEvent e)
141 protected void findAll_actionPerformed(ActionEvent e)
146 protected void textfield_keyPressed(KeyEvent e)
149 if(e.getKeyCode()==KeyEvent.VK_ENTER)
152 findNext_actionPerformed(null);
154 findNext.setEnabled(true);
157 public void createNewGroup_actionPerformed(ActionEvent e)
161 public void textfield_caretUpdate(CaretEvent e)
163 if (textfield.getText().indexOf(">") > -1)
165 SwingUtilities.invokeLater(new Runnable()
169 String str = textfield.getText();
170 SequenceI[] sequences = null;
171 try{sequences = new FormatAdapter().readFile(str, "Paste", "FASTA");}
172 catch(Exception ex){}
173 if(sequences!=null && sequences.length>0)
175 str = jalview.analysis.AlignSeq.extractGaps(
176 jalview.util.Comparison.GapChars, sequences[0].getSequence());
178 textfield.setText(str);