X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FRedundancyPanel.java;h=8aed73065ab8370e97ecf8b7090a17306c2282f4;hb=ef23c17739a6fba3a8d455b725782bce4607ac9f;hp=735a5790459e23fe66ca837be501531211ec7378;hpb=99c58ee0ae2a848f982552e53feaf6d5cb9925e5;p=jalview.git diff --git a/src/jalview/appletgui/RedundancyPanel.java b/src/jalview/appletgui/RedundancyPanel.java index 735a579..8aed730 100755 --- a/src/jalview/appletgui/RedundancyPanel.java +++ b/src/jalview/appletgui/RedundancyPanel.java @@ -1,36 +1,38 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.appletgui; -import jalview.jbappletgui.*; -import jalview.datamodel.*; -import java.awt.event.*; import java.util.*; -public class RedundancyPanel extends GSliderPanel +import java.awt.event.*; + +import jalview.datamodel.*; +import jalview.jbappletgui.*; + +public class RedundancyPanel + extends GSliderPanel { AlignmentPanel ap; SequenceI[] oldAlignment; - public RedundancyPanel(AlignmentPanel ap) { this.ap = ap; @@ -41,81 +43,87 @@ public class RedundancyPanel extends GSliderPanel { public void adjustmentValueChanged(AdjustmentEvent evt) { - valueField.setText( slider.getValue()+"" ); + valueField.setText(slider.getValue() + ""); } }); slider.setMinimum(0); slider.setMaximum(100); - slider.setValue(100 ); + slider.setValue(100); } public void applyButton_actionPerformed(ActionEvent e) { - float threshold = slider.getValue(); - Vector del; + float threshold = slider.getValue(); + Vector del; + + oldAlignment = new SequenceI[ap.av.alignment.getHeight()]; + for (int i = 0; i < ap.av.alignment.getHeight(); i++) + { + oldAlignment[i] = new Sequence(ap.av.alignment.getSequenceAt(i).getName(), + ap.av.alignment.getSequenceAt(i). + getSequence()); + } + + undoButton.setEnabled(true); + + SequenceGroup sg = ap.av.getSelectionGroup(); + if (sg != null && sg.getSize() > 1) + { - oldAlignment = new SequenceI[ap.av.alignment.getHeight()]; - for (int i = 0; i < ap.av.alignment.getHeight(); i++) + del = ap.av.alignment.removeRedundancy(threshold, sg.sequences); + for (int i = 0; i < del.size(); i++) + { + if (sg.sequences.contains( (SequenceI) del.elementAt(i))) { - oldAlignment[i] = new Sequence(ap.av.alignment.getSequenceAt(i).getName(), - ap.av.alignment.getSequenceAt(i). - getSequence()); + sg.deleteSequence( (SequenceI) del.elementAt(i), true); } + } - undoButton.setEnabled(true); - - SequenceGroup sg = ap.av.getSelectionGroup(); - if (sg != null && sg.getSize() > 1) - { - - del = ap.av.alignment.removeRedundancy(threshold, sg.sequences); - for (int i = 0; i < del.size(); i++) - if (sg.sequences.contains( (SequenceI) del.elementAt(i))) - sg.deleteSequence( (SequenceI) del.elementAt(i)); - - } - else - { - Vector s = new Vector(); - int i=0; - while(i < ap.av.alignment.getHeight()) - { - s.addElement( ap.av.alignment.getSequenceAt(i) ); - i++; - } - del = ap.av.alignment.removeRedundancy(threshold,s); - for (int j=0; j < del.size(); j++) - { - if (sg.sequences.contains((SequenceI)del.elementAt(j))) - sg.deleteSequence((SequenceI)del.elementAt(j)); - - } - } - - ap.repaint(); + } + else + { + Vector s = new Vector(); + int i = 0; + while (i < ap.av.alignment.getHeight()) + { + s.addElement(ap.av.alignment.getSequenceAt(i)); + i++; + } + del = ap.av.alignment.removeRedundancy(threshold, s); + for (int j = 0; j < del.size(); j++) + { + if (sg.sequences.contains( (SequenceI) del.elementAt(j))) + { + sg.deleteSequence( (SequenceI) del.elementAt(j), true); + } + + } + } + + ap.repaint(); } public void undoButton_actionPerformed(ActionEvent e) { - undoButton.setEnabled(false); - ap.av.setAlignment( new Alignment(oldAlignment) ); - oldAlignment = null; - ap.repaint(); + undoButton.setEnabled(false); + ap.av.setAlignment(new Alignment(oldAlignment)); + oldAlignment = null; + ap.repaint(); } - public void valueField_actionPerformed(ActionEvent e) { - try{ + try + { int i = Integer.parseInt(valueField.getText()); slider.setValue(i); } - catch(Exception ex) + catch (Exception ex) { - valueField.setText( slider.getValue()+"" ); + valueField.setText(slider.getValue() + ""); } } }