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
27 import java.awt.BorderLayout;
\r
29 public class GFinder
\r
32 JLabel jLabel1 = new JLabel();
\r
33 protected JButton findAll = new JButton();
\r
34 protected JButton findNext = new JButton();
\r
35 JPanel jPanel1 = new JPanel();
\r
36 GridLayout gridLayout1 = new GridLayout();
\r
37 protected JButton createNewGroup = new JButton();
\r
38 JScrollPane jScrollPane1 = new JScrollPane();
\r
39 protected JTextArea textfield = new JTextArea();
\r
40 BorderLayout borderLayout1 = new BorderLayout();
\r
41 JPanel jPanel2 = new JPanel();
\r
42 JPanel jPanel3 = new JPanel();
\r
43 JPanel jPanel4 = new JPanel();
\r
44 BorderLayout borderLayout2 = new BorderLayout();
\r
45 JPanel jPanel6 = new JPanel();
\r
46 protected JCheckBox caseSensitive = new JCheckBox();
\r
55 e.printStackTrace();
\r
59 private void jbInit()
\r
62 jLabel1.setFont(new java.awt.Font("Verdana", 0, 12));
\r
63 jLabel1.setText("Find");
\r
64 this.setLayout(borderLayout1);
\r
65 findAll.setFont(new java.awt.Font("Verdana", 0, 12));
\r
66 findAll.setText("Find all");
\r
67 findAll.addActionListener(new java.awt.event.ActionListener()
\r
69 public void actionPerformed(ActionEvent e)
\r
71 findAll_actionPerformed(e);
\r
74 findNext.setEnabled(false);
\r
75 findNext.setFont(new java.awt.Font("Verdana", 0, 12));
\r
76 findNext.setText("Find Next");
\r
77 findNext.addActionListener(new java.awt.event.ActionListener()
\r
79 public void actionPerformed(ActionEvent e)
\r
81 findNext_actionPerformed(e);
\r
84 jPanel1.setLayout(gridLayout1);
\r
85 gridLayout1.setHgap(0);
\r
86 gridLayout1.setRows(3);
\r
87 gridLayout1.setVgap(2);
\r
88 createNewGroup.setEnabled(false);
\r
89 createNewGroup.setFont(new java.awt.Font("Verdana", 0, 12));
\r
90 createNewGroup.setToolTipText("");
\r
91 createNewGroup.setMargin(new Insets(0, 0, 0, 0));
\r
92 createNewGroup.setText("New Feature");
\r
93 createNewGroup.addActionListener(new java.awt.event.ActionListener()
\r
95 public void actionPerformed(ActionEvent e)
\r
97 createNewGroup_actionPerformed(e);
\r
100 textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 12));
\r
101 textfield.setText("");
\r
102 textfield.setLineWrap(true);
\r
103 textfield.addCaretListener(new CaretListener()
\r
105 public void caretUpdate(CaretEvent e)
\r
107 textfield_caretUpdate(e);
\r
110 textfield.addKeyListener(new java.awt.event.KeyAdapter() {
\r
111 public void keyPressed(KeyEvent e) {
\r
112 textfield_keyPressed(e);
\r
116 borderLayout1.setHgap(5);
\r
117 borderLayout1.setVgap(5);
\r
118 jPanel4.setLayout(borderLayout2);
\r
119 jPanel2.setPreferredSize(new Dimension(10, 1));
\r
120 jPanel3.setPreferredSize(new Dimension(10, 1));
\r
121 caseSensitive.setHorizontalAlignment(SwingConstants.LEFT);
\r
122 caseSensitive.setText("Match Case");
\r
123 jPanel1.add(findNext, null);
\r
124 jPanel1.add(findAll, null);
\r
125 jPanel1.add(createNewGroup, null);
\r
126 this.add(jLabel1, java.awt.BorderLayout.WEST);
\r
127 this.add(jPanel1, java.awt.BorderLayout.EAST);
\r
128 this.add(jPanel2, java.awt.BorderLayout.SOUTH);
\r
129 this.add(jPanel3, java.awt.BorderLayout.NORTH);
\r
130 this.add(jPanel4, java.awt.BorderLayout.CENTER);
\r
131 jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER);
\r
132 jScrollPane1.getViewport().add(textfield);
\r
133 jPanel4.add(jPanel6, java.awt.BorderLayout.NORTH);
\r
134 jPanel4.add(caseSensitive, java.awt.BorderLayout.SOUTH);
\r
137 protected void findNext_actionPerformed(ActionEvent e)
\r
141 protected void findAll_actionPerformed(ActionEvent e)
\r
146 protected void textfield_keyPressed(KeyEvent e)
\r
149 if(e.getKeyCode()==KeyEvent.VK_ENTER)
\r
152 findNext_actionPerformed(null);
\r
154 findNext.setEnabled(true);
\r
157 public void createNewGroup_actionPerformed(ActionEvent e)
\r
161 public void textfield_caretUpdate(CaretEvent e)
\r
163 if (textfield.getText().indexOf(">") > -1)
\r
165 SwingUtilities.invokeLater(new Runnable()
\r
169 String str = textfield.getText();
\r
170 SequenceI[] sequences = null;
\r
171 try{sequences = new FormatAdapter().readFile(str, "Paste", "FASTA");}
\r
172 catch(Exception ex){}
\r
173 if(sequences!=null && sequences.length>0)
\r
175 str = jalview.analysis.AlignSeq.extractGaps(
\r
176 jalview.util.Comparison.GapChars, sequences[0].getSequence());
\r
178 textfield.setText(str);
\r