2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.jbgui;
21 import java.awt.event.*;
23 import javax.swing.event.*;
25 import jalview.datamodel.*;
28 public class GFinder extends JPanel
30 JLabel jLabel1 = new JLabel();
32 protected JButton findAll = new JButton();
34 protected JButton findNext = new JButton();
36 JPanel jPanel1 = new JPanel();
38 GridLayout gridLayout1 = new GridLayout();
40 protected JButton createNewGroup = new JButton();
42 JScrollPane jScrollPane1 = new JScrollPane();
44 protected JTextArea textfield = new JTextArea();
46 BorderLayout borderLayout1 = new BorderLayout();
48 JPanel jPanel2 = new JPanel();
50 JPanel jPanel3 = new JPanel();
52 JPanel jPanel4 = new JPanel();
54 BorderLayout borderLayout2 = new BorderLayout();
56 JPanel jPanel6 = new JPanel();
58 protected JCheckBox caseSensitive = new JCheckBox();
71 private void jbInit() throws Exception
73 jLabel1.setFont(new java.awt.Font("Verdana", 0, 12));
74 jLabel1.setText("Find");
75 this.setLayout(borderLayout1);
76 findAll.setFont(new java.awt.Font("Verdana", 0, 12));
77 findAll.setText("Find all");
78 findAll.addActionListener(new java.awt.event.ActionListener()
80 public void actionPerformed(ActionEvent e)
82 findAll_actionPerformed(e);
85 findNext.setFont(new java.awt.Font("Verdana", 0, 12));
86 findNext.setText("Find Next");
87 findNext.addActionListener(new java.awt.event.ActionListener()
89 public void actionPerformed(ActionEvent e)
91 findNext_actionPerformed(e);
94 jPanel1.setLayout(gridLayout1);
95 gridLayout1.setHgap(0);
96 gridLayout1.setRows(3);
97 gridLayout1.setVgap(2);
98 createNewGroup.setEnabled(false);
99 createNewGroup.setFont(new java.awt.Font("Verdana", 0, 12));
100 createNewGroup.setMargin(new Insets(0, 0, 0, 0));
101 createNewGroup.setText("New Feature");
102 createNewGroup.addActionListener(new java.awt.event.ActionListener()
104 public void actionPerformed(ActionEvent e)
106 createNewGroup_actionPerformed(e);
109 textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 12));
110 textfield.setText("");
111 textfield.setLineWrap(true);
112 textfield.addCaretListener(new CaretListener()
114 public void caretUpdate(CaretEvent e)
116 textfield_caretUpdate(e);
119 textfield.addKeyListener(new java.awt.event.KeyAdapter()
121 public void keyPressed(KeyEvent e)
123 textfield_keyPressed(e);
127 borderLayout1.setHgap(5);
128 borderLayout1.setVgap(5);
129 jPanel4.setLayout(borderLayout2);
130 jPanel2.setPreferredSize(new Dimension(10, 1));
131 jPanel3.setPreferredSize(new Dimension(10, 1));
132 caseSensitive.setHorizontalAlignment(SwingConstants.LEFT);
133 caseSensitive.setText("Match Case");
134 jPanel1.add(findNext, null);
135 jPanel1.add(findAll, null);
136 jPanel1.add(createNewGroup, null);
137 this.add(jLabel1, java.awt.BorderLayout.WEST);
138 this.add(jPanel1, java.awt.BorderLayout.EAST);
139 this.add(jPanel2, java.awt.BorderLayout.SOUTH);
140 this.add(jPanel3, java.awt.BorderLayout.NORTH);
141 this.add(jPanel4, java.awt.BorderLayout.CENTER);
142 jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER);
143 jScrollPane1.getViewport().add(textfield);
144 jPanel4.add(jPanel6, java.awt.BorderLayout.NORTH);
145 jPanel4.add(caseSensitive, java.awt.BorderLayout.SOUTH);
148 protected void findNext_actionPerformed(ActionEvent e)
152 protected void findAll_actionPerformed(ActionEvent e)
156 protected void textfield_keyPressed(KeyEvent e)
158 if (e.getKeyCode() == KeyEvent.VK_ENTER)
161 findNext_actionPerformed(null);
165 public void createNewGroup_actionPerformed(ActionEvent e)
169 public void textfield_caretUpdate(CaretEvent e)
171 if (textfield.getText().indexOf(">") > -1)
173 SwingUtilities.invokeLater(new Runnable()
177 String str = textfield.getText();
181 al = new FormatAdapter().readFile(str, "Paste", "FASTA");
182 } catch (Exception ex)
185 if (al != null && al.getHeight() > 0)
187 str = jalview.analysis.AlignSeq.extractGaps(
188 jalview.util.Comparison.GapChars, al.getSequenceAt(0)
189 .getSequenceAsString());
191 textfield.setText(str);