2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 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.*;
26 import jalview.datamodel.*;
29 public class GFinder extends JPanel
31 JLabel jLabel1 = new JLabel();
33 protected JButton findAll = new JButton();
35 protected JButton findNext = new JButton();
37 JPanel jPanel1 = new JPanel();
39 GridLayout gridLayout1 = new GridLayout();
41 protected JButton createNewGroup = new JButton();
43 JScrollPane jScrollPane1 = new JScrollPane();
45 protected JTextArea textfield = new JTextArea();
47 BorderLayout borderLayout1 = new BorderLayout();
49 JPanel jPanel2 = new JPanel();
51 JPanel jPanel3 = new JPanel();
53 JPanel jPanel4 = new JPanel();
55 BorderLayout borderLayout2 = new BorderLayout();
57 JPanel jPanel6 = new JPanel();
59 protected JCheckBox caseSensitive = new JCheckBox();
72 private void jbInit() throws Exception
74 jLabel1.setFont(new java.awt.Font("Verdana", 0, 12));
75 jLabel1.setText("Find");
76 this.setLayout(borderLayout1);
77 findAll.setFont(new java.awt.Font("Verdana", 0, 12));
78 findAll.setText("Find all");
79 findAll.addActionListener(new java.awt.event.ActionListener()
81 public void actionPerformed(ActionEvent e)
83 findAll_actionPerformed(e);
86 findNext.setFont(new java.awt.Font("Verdana", 0, 12));
87 findNext.setText("Find Next");
88 findNext.addActionListener(new java.awt.event.ActionListener()
90 public void actionPerformed(ActionEvent e)
92 findNext_actionPerformed(e);
95 jPanel1.setLayout(gridLayout1);
96 gridLayout1.setHgap(0);
97 gridLayout1.setRows(3);
98 gridLayout1.setVgap(2);
99 createNewGroup.setEnabled(false);
100 createNewGroup.setFont(new java.awt.Font("Verdana", 0, 12));
101 createNewGroup.setMargin(new Insets(0, 0, 0, 0));
102 createNewGroup.setText("New Feature");
103 createNewGroup.addActionListener(new java.awt.event.ActionListener()
105 public void actionPerformed(ActionEvent e)
107 createNewGroup_actionPerformed(e);
110 textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 12));
111 textfield.setText("");
112 textfield.setLineWrap(true);
113 textfield.addCaretListener(new CaretListener()
115 public void caretUpdate(CaretEvent e)
117 textfield_caretUpdate(e);
120 textfield.addKeyListener(new java.awt.event.KeyAdapter()
122 public void keyPressed(KeyEvent e)
124 textfield_keyPressed(e);
128 borderLayout1.setHgap(5);
129 borderLayout1.setVgap(5);
130 jPanel4.setLayout(borderLayout2);
131 jPanel2.setPreferredSize(new Dimension(10, 1));
132 jPanel3.setPreferredSize(new Dimension(10, 1));
133 caseSensitive.setHorizontalAlignment(SwingConstants.LEFT);
134 caseSensitive.setText("Match Case");
135 jPanel1.add(findNext, null);
136 jPanel1.add(findAll, null);
137 jPanel1.add(createNewGroup, null);
138 this.add(jLabel1, java.awt.BorderLayout.WEST);
139 this.add(jPanel1, java.awt.BorderLayout.EAST);
140 this.add(jPanel2, java.awt.BorderLayout.SOUTH);
141 this.add(jPanel3, java.awt.BorderLayout.NORTH);
142 this.add(jPanel4, java.awt.BorderLayout.CENTER);
143 jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER);
144 jScrollPane1.getViewport().add(textfield);
145 jPanel4.add(jPanel6, java.awt.BorderLayout.NORTH);
146 jPanel4.add(caseSensitive, java.awt.BorderLayout.SOUTH);
149 protected void findNext_actionPerformed(ActionEvent e)
153 protected void findAll_actionPerformed(ActionEvent e)
157 protected void textfield_keyPressed(KeyEvent e)
159 if (e.getKeyCode() == KeyEvent.VK_ENTER)
162 findNext_actionPerformed(null);
166 public void createNewGroup_actionPerformed(ActionEvent e)
170 public void textfield_caretUpdate(CaretEvent e)
172 if (textfield.getText().indexOf(">") > -1)
174 SwingUtilities.invokeLater(new Runnable()
178 String str = textfield.getText();
182 al = new FormatAdapter().readFile(str, "Paste", "FASTA");
183 } catch (Exception ex)
186 if (al != null && al.getHeight() > 0)
188 str = jalview.analysis.AlignSeq.extractGaps(
189 jalview.util.Comparison.GapChars, al.getSequenceAt(0)
190 .getSequenceAsString());
192 textfield.setText(str);