2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.jbgui;
\r
22 import java.awt.event.*;
\r
23 import javax.swing.*;
\r
24 import javax.swing.event.*;
\r
25 import jalview.io.FormatAdapter;
\r
26 import jalview.datamodel.SequenceI;
\r
28 public class GFinder
\r
31 JLabel jLabel1 = new JLabel();
\r
32 protected JButton findAll = new JButton();
\r
33 protected JButton findNext = new JButton();
\r
34 JPanel jPanel1 = new JPanel();
\r
35 GridLayout gridLayout1 = new GridLayout();
\r
36 protected JButton createNewGroup = new JButton();
\r
37 JScrollPane jScrollPane1 = new JScrollPane();
\r
38 protected JTextArea textfield = new JTextArea();
\r
39 BorderLayout borderLayout1 = new BorderLayout();
\r
40 JPanel jPanel2 = new JPanel();
\r
41 JPanel jPanel3 = new JPanel();
\r
42 JPanel jPanel4 = new JPanel();
\r
43 BorderLayout borderLayout2 = new BorderLayout();
\r
44 JPanel jPanel5 = new JPanel();
\r
45 JPanel jPanel6 = new JPanel();
\r
54 e.printStackTrace();
\r
58 private void jbInit()
\r
61 jLabel1.setFont(new java.awt.Font("Verdana", 0, 12));
\r
62 jLabel1.setText("Find");
\r
63 this.setLayout(borderLayout1);
\r
64 findAll.setFont(new java.awt.Font("Verdana", 0, 12));
\r
65 findAll.setText("Find all");
\r
66 findAll.addActionListener(new java.awt.event.ActionListener()
\r
68 public void actionPerformed(ActionEvent e)
\r
70 findAll_actionPerformed(e);
\r
73 findNext.setEnabled(false);
\r
74 findNext.setFont(new java.awt.Font("Verdana", 0, 12));
\r
75 findNext.setText("Find Next");
\r
76 findNext.addActionListener(new java.awt.event.ActionListener()
\r
78 public void actionPerformed(ActionEvent e)
\r
80 findNext_actionPerformed(e);
\r
83 jPanel1.setLayout(gridLayout1);
\r
84 gridLayout1.setHgap(0);
\r
85 gridLayout1.setRows(3);
\r
86 gridLayout1.setVgap(2);
\r
87 createNewGroup.setEnabled(false);
\r
88 createNewGroup.setFont(new java.awt.Font("Verdana", 0, 12));
\r
89 createNewGroup.setToolTipText("");
\r
90 createNewGroup.setMargin(new Insets(0, 0, 0, 0));
\r
91 createNewGroup.setText("Create new group");
\r
92 createNewGroup.addActionListener(new java.awt.event.ActionListener()
\r
94 public void actionPerformed(ActionEvent e)
\r
96 createNewGroup_actionPerformed(e);
\r
99 textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 12));
\r
100 textfield.setText("");
\r
101 textfield.setLineWrap(true);
\r
102 textfield.addCaretListener(new CaretListener()
\r
104 public void caretUpdate(CaretEvent e)
\r
106 textfield_caretUpdate(e);
\r
109 textfield.addKeyListener(new java.awt.event.KeyAdapter() {
\r
110 public void keyPressed(KeyEvent e) {
\r
111 textfield_keyPressed(e);
\r
115 borderLayout1.setHgap(5);
\r
116 borderLayout1.setVgap(5);
\r
117 jPanel4.setLayout(borderLayout2);
\r
118 jPanel2.setPreferredSize(new Dimension(10, 1));
\r
119 jPanel3.setPreferredSize(new Dimension(10, 1));
\r
120 jPanel1.add(findNext, null);
\r
121 jPanel1.add(findAll, null);
\r
122 jPanel1.add(createNewGroup, null);
\r
123 this.add(jLabel1, java.awt.BorderLayout.WEST);
\r
124 this.add(jPanel1, java.awt.BorderLayout.EAST);
\r
125 this.add(jPanel2, java.awt.BorderLayout.SOUTH);
\r
126 this.add(jPanel3, java.awt.BorderLayout.NORTH);
\r
127 this.add(jPanel4, java.awt.BorderLayout.CENTER);
\r
128 jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER);
\r
129 jPanel4.add(jPanel5, java.awt.BorderLayout.SOUTH);
\r
130 jPanel4.add(jPanel6, java.awt.BorderLayout.NORTH);
\r
131 jScrollPane1.getViewport().add(textfield);
\r
134 protected void findNext_actionPerformed(ActionEvent e)
\r
138 protected void findAll_actionPerformed(ActionEvent e)
\r
143 protected void textfield_keyPressed(KeyEvent e)
\r
146 if(e.getKeyCode()==KeyEvent.VK_ENTER)
\r
149 findNext_actionPerformed(null);
\r
151 findNext.setEnabled(true);
\r
154 public void createNewGroup_actionPerformed(ActionEvent e)
\r
158 public void textfield_caretUpdate(CaretEvent e)
\r
160 if (textfield.getText().indexOf(">") > -1)
\r
162 SwingUtilities.invokeLater(new Runnable()
\r
166 String str = textfield.getText();
\r
167 SequenceI[] sequences = new FormatAdapter().readFile(str, "Paste", "FASTA");
\r
168 if(sequences!=null && sequences.length>0)
\r
170 str = jalview.analysis.AlignSeq.extractGaps(
\r
171 jalview.util.Comparison.GapChars, sequences[0].getSequence());
\r
173 textfield.setText(str);
\r