X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FRedundancyPanel.java;h=daee8623f3469e5939ec69d276fa06433e9d7643;hb=4ebc6d5b362bc093c39312aa1a69836e3dd6ae84;hp=5d266f87a06d7c7503d7a8bc5f3efc91268cd897;hpb=b6c0570ea7dc3c805ead26348f849fe69daaf917;p=jalview.git diff --git a/src/jalview/gui/RedundancyPanel.java b/src/jalview/gui/RedundancyPanel.java index 5d266f8..daee862 100755 --- a/src/jalview/gui/RedundancyPanel.java +++ b/src/jalview/gui/RedundancyPanel.java @@ -1,11 +1,31 @@ +/* + * 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.gui; -import jalview.jbgui.*; -import jalview.datamodel.*; -import java.awt.event.*; import java.util.*; + +import java.awt.event.*; import javax.swing.event.*; +import jalview.datamodel.*; +import jalview.jbgui.*; + public class RedundancyPanel extends GSliderPanel { @@ -30,7 +50,6 @@ public class RedundancyPanel slider.setMinimum(0); slider.setMaximum(100); slider.setValue(100); - } public void applyButton_actionPerformed(ActionEvent e) @@ -38,52 +57,61 @@ public class RedundancyPanel float threshold = slider.getValue(); Vector del; HistoryItem it; - historyList.push(it=new HistoryItem("Remove redundancy", - ap.av.alignment, HistoryItem.HIDE)); - if (historyList.size()==1 - || !af.historyList.contains(historyList.firstElement())) { - af.addHistoryItem((HistoryItem) historyList.firstElement()); + historyList.push(it = new HistoryItem("Remove redundancy", + ap.av.alignment, HistoryItem.HIDE)); + + if ( (historyList.size() == 1) || + !af.historyList.contains(historyList.firstElement())) + { + af.addHistoryItem( (HistoryItem) historyList.firstElement()); af.updateEditMenuBar(); } + undoButton.setEnabled(true); + SequenceGroup sg = ap.av.getSelectionGroup(); - if (sg != null && sg.getSize() >= 1) - { + 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)); + sg.deleteSequence( (SequenceI) del.elementAt(i), true); } } - } 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); } // This has to be done before the restoreHistoryItem method of alignFrame will // actually restore these sequences. - - if (del.size()>0) - for (int i=0,j=del.size(); i 0) + { + for (int i = 0, j = del.size(); i < j; i++) + { SequenceI sq = (SequenceI) del.elementAt(i); - sq.deleteChars(0,sq.getLength()); + sq.deleteChars(0, sq.getLength()); } + } ap.av.firePropertyChange("alignment", null, ap.av.getAlignment().getSequences()); ap.av.resetSeqLimits(ap.seqPanel.seqCanvas.getHeight()); + if (ap.av.getAlignment().getHeight() < 1) { try @@ -91,22 +119,25 @@ public class RedundancyPanel af.setClosed(true); } catch (Exception ex) - {} + { + } } + ap.av.updateConservation(); ap.av.updateConsensus(); af.updateEditMenuBar(); ap.repaint(); - } public void undoButton_actionPerformed(ActionEvent e) { HistoryItem hi = (HistoryItem) historyList.pop(); af.restoreHistoryItem(hi); + if (historyList.size() == 0) { undoButton.setEnabled(false); + if (af.historyList.contains(hi)) { af.historyList.remove(hi); @@ -114,6 +145,7 @@ public class RedundancyPanel } } } + public void valueField_actionPerformed(ActionEvent e) { try