2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2007 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.*;
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.setFont(new java.awt.Font("Verdana", 0, 12));
75 findNext.setText("Find Next");
76 findNext.addActionListener(new java.awt.event.ActionListener()
78 public void actionPerformed(ActionEvent e)
80 findNext_actionPerformed(e);
83 jPanel1.setLayout(gridLayout1);
84 gridLayout1.setHgap(0);
85 gridLayout1.setRows(3);
86 gridLayout1.setVgap(2);
87 createNewGroup.setEnabled(false);
88 createNewGroup.setFont(new java.awt.Font("Verdana", 0, 12));
89 createNewGroup.setMargin(new Insets(0, 0, 0, 0));
90 createNewGroup.setText("New Feature");
91 createNewGroup.addActionListener(new java.awt.event.ActionListener()
93 public void actionPerformed(ActionEvent e)
95 createNewGroup_actionPerformed(e);
98 textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 12));
99 textfield.setText("");
100 textfield.setLineWrap(true);
101 textfield.addCaretListener(new CaretListener()
103 public void caretUpdate(CaretEvent e)
105 textfield_caretUpdate(e);
108 textfield.addKeyListener(new java.awt.event.KeyAdapter()
110 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)
145 protected void textfield_keyPressed(KeyEvent e)
147 if (e.getKeyCode() == KeyEvent.VK_ENTER)
150 findNext_actionPerformed(null);
154 public void createNewGroup_actionPerformed(ActionEvent e)
158 public void textfield_caretUpdate(CaretEvent e)
160 if (textfield.getText().indexOf(">") > -1)
162 SwingUtilities.invokeLater(new Runnable()
166 String str = textfield.getText();
170 al = new FormatAdapter().readFile(str, "Paste", "FASTA");
174 if (al != null && al.getHeight() > 0)
176 str = jalview.analysis.AlignSeq.extractGaps(
177 jalview.util.Comparison.GapChars,
178 al.getSequenceAt(0).getSequenceAsString());
180 textfield.setText(str);