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
20 package jalview.appletgui;
\r
22 import jalview.jbappletgui.*;
\r
23 import jalview.datamodel.*;
\r
24 import java.awt.event.*;
\r
27 public class RedundancyPanel extends GSliderPanel
\r
31 SequenceI[] oldAlignment;
\r
34 public RedundancyPanel(AlignmentPanel ap)
\r
38 label.setText("Enter the redundancy threshold");
\r
40 slider.addAdjustmentListener(new AdjustmentListener()
\r
42 public void adjustmentValueChanged(AdjustmentEvent evt)
\r
44 valueField.setText( slider.getValue()+"" );
\r
48 slider.setMinimum(0);
\r
49 slider.setMaximum(100);
\r
50 slider.setValue(100 );
\r
54 public void applyButton_actionPerformed(ActionEvent e)
\r
56 float threshold = slider.getValue();
\r
59 oldAlignment = new SequenceI[ap.av.alignment.getHeight()];
\r
60 for (int i = 0; i < ap.av.alignment.getHeight(); i++)
\r
62 oldAlignment[i] = new Sequence(ap.av.alignment.getSequenceAt(i).getName(),
\r
63 ap.av.alignment.getSequenceAt(i).
\r
67 undoButton.setEnabled(true);
\r
69 SequenceGroup sg = ap.av.getSelectionGroup();
\r
70 if (sg != null && sg.getSize() > 1)
\r
73 del = ap.av.alignment.removeRedundancy(threshold, sg.sequences);
\r
74 for (int i = 0; i < del.size(); i++)
\r
75 if (sg.sequences.contains( (SequenceI) del.elementAt(i)))
\r
76 sg.deleteSequence( (SequenceI) del.elementAt(i));
\r
81 Vector s = new Vector();
\r
83 while(i < ap.av.alignment.getHeight())
\r
85 s.addElement( ap.av.alignment.getSequenceAt(i) );
\r
88 del = ap.av.alignment.removeRedundancy(threshold,s);
\r
89 for (int j=0; j < del.size(); j++)
\r
91 if (sg.sequences.contains((SequenceI)del.elementAt(j)))
\r
92 sg.deleteSequence((SequenceI)del.elementAt(j));
\r
101 public void undoButton_actionPerformed(ActionEvent e)
\r
103 undoButton.setEnabled(false);
\r
104 ap.av.setAlignment( new Alignment(oldAlignment) );
\r
105 oldAlignment = null;
\r
110 public void valueField_actionPerformed(ActionEvent e)
\r
113 int i = Integer.parseInt(valueField.getText());
\r
114 slider.setValue(i);
\r
116 catch(Exception ex)
\r
118 valueField.setText( slider.getValue()+"" );
\r