2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
3 * Copyright (C) 2014 The Jalview Authors
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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.jbgui;
22 import java.awt.event.*;
24 import javax.swing.event.*;
26 import jalview.datamodel.*;
28 import jalview.util.MessageManager;
30 public class GFinder extends JPanel
32 JLabel jLabel1 = new JLabel();
34 protected JButton findAll = new JButton();
36 protected JButton findNext = new JButton();
38 JPanel jPanel1 = new JPanel();
40 GridLayout gridLayout1 = new GridLayout();
42 protected JButton createNewGroup = new JButton();
44 JScrollPane jScrollPane1 = new JScrollPane();
46 protected JTextArea textfield = new JTextArea();
48 BorderLayout borderLayout1 = new BorderLayout();
50 JPanel jPanel2 = new JPanel();
52 JPanel jPanel3 = new JPanel();
54 JPanel jPanel4 = new JPanel();
56 BorderLayout borderLayout2 = new BorderLayout();
58 JPanel jPanel6 = new JPanel();
60 protected JCheckBox caseSensitive = new JCheckBox();
73 private void jbInit() throws Exception
75 jLabel1.setFont(new java.awt.Font("Verdana", 0, 12));
76 jLabel1.setText(MessageManager.getString("action.find"));
77 this.setLayout(borderLayout1);
78 findAll.setFont(new java.awt.Font("Verdana", 0, 12));
79 findAll.setText(MessageManager.getString("action.find_all"));
80 findAll.addActionListener(new java.awt.event.ActionListener()
82 public void actionPerformed(ActionEvent e)
84 findAll_actionPerformed(e);
87 findNext.setFont(new java.awt.Font("Verdana", 0, 12));
88 findNext.setText(MessageManager.getString("action.find_next"));
89 findNext.addActionListener(new java.awt.event.ActionListener()
91 public void actionPerformed(ActionEvent e)
93 findNext_actionPerformed(e);
96 jPanel1.setLayout(gridLayout1);
97 gridLayout1.setHgap(0);
98 gridLayout1.setRows(3);
99 gridLayout1.setVgap(2);
100 createNewGroup.setEnabled(false);
101 createNewGroup.setFont(new java.awt.Font("Verdana", 0, 12));
102 createNewGroup.setMargin(new Insets(0, 0, 0, 0));
103 createNewGroup.setText(MessageManager.getString("label.new_feature"));
104 createNewGroup.addActionListener(new java.awt.event.ActionListener()
106 public void actionPerformed(ActionEvent e)
108 createNewGroup_actionPerformed(e);
111 textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 12));
112 textfield.setText("");
113 textfield.setLineWrap(true);
114 textfield.addCaretListener(new CaretListener()
116 public void caretUpdate(CaretEvent e)
118 textfield_caretUpdate(e);
121 textfield.addKeyListener(new java.awt.event.KeyAdapter()
123 public void keyPressed(KeyEvent e)
125 textfield_keyPressed(e);
129 borderLayout1.setHgap(5);
130 borderLayout1.setVgap(5);
131 jPanel4.setLayout(borderLayout2);
132 jPanel2.setPreferredSize(new Dimension(10, 1));
133 jPanel3.setPreferredSize(new Dimension(10, 1));
134 caseSensitive.setHorizontalAlignment(SwingConstants.LEFT);
135 caseSensitive.setText(MessageManager.getString("label.match_case"));
136 jPanel1.add(findNext, null);
137 jPanel1.add(findAll, null);
138 jPanel1.add(createNewGroup, null);
139 this.add(jLabel1, java.awt.BorderLayout.WEST);
140 this.add(jPanel1, java.awt.BorderLayout.EAST);
141 this.add(jPanel2, java.awt.BorderLayout.SOUTH);
142 this.add(jPanel3, java.awt.BorderLayout.NORTH);
143 this.add(jPanel4, java.awt.BorderLayout.CENTER);
144 jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER);
145 jScrollPane1.getViewport().add(textfield);
146 jPanel4.add(jPanel6, java.awt.BorderLayout.NORTH);
147 jPanel4.add(caseSensitive, java.awt.BorderLayout.SOUTH);
150 protected void findNext_actionPerformed(ActionEvent e)
154 protected void findAll_actionPerformed(ActionEvent e)
158 protected void textfield_keyPressed(KeyEvent e)
160 if (e.getKeyCode() == KeyEvent.VK_ENTER)
163 findNext_actionPerformed(null);
167 public void createNewGroup_actionPerformed(ActionEvent e)
171 public void textfield_caretUpdate(CaretEvent e)
173 if (textfield.getText().indexOf(">") > -1)
175 SwingUtilities.invokeLater(new Runnable()
179 String str = textfield.getText();
183 al = new FormatAdapter().readFile(str, "Paste", "FASTA");
184 } catch (Exception ex)
187 if (al != null && al.getHeight() > 0)
189 str = jalview.analysis.AlignSeq.extractGaps(
190 jalview.util.Comparison.GapChars, al.getSequenceAt(0)
191 .getSequenceAsString());
193 textfield.setText(str);