Formatted source
[jalview.git] / src / jalview / gui / RedundancyPanel.java
index e4ef46e..44aa447 100755 (executable)
@@ -1,30 +1,31 @@
 /*\r
-* Jalview - A Sequence Alignment Editor and Viewer\r
-* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
-*\r
-* This program is free software; you can redistribute it and/or\r
-* modify it under the terms of the GNU General Public License\r
-* as published by the Free Software Foundation; either version 2\r
-* of the License, or (at your option) any later version.\r
-*\r
-* This program is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with this program; if not, write to the Free Software\r
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
-*/\r
-\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
+ */\r
 package jalview.gui;\r
 \r
-import jalview.jbgui.*;\r
-import jalview.datamodel.*;\r
-import java.awt.event.*;\r
 import java.util.*;\r
+\r
+import java.awt.event.*;\r
 import javax.swing.event.*;\r
 \r
+import jalview.datamodel.*;\r
+import jalview.jbgui.*;\r
+\r
 public class RedundancyPanel\r
     extends GSliderPanel\r
 {\r
@@ -49,7 +50,6 @@ public class RedundancyPanel
     slider.setMinimum(0);\r
     slider.setMaximum(100);\r
     slider.setValue(100);\r
-\r
   }\r
 \r
   public void applyButton_actionPerformed(ActionEvent e)\r
@@ -57,19 +57,24 @@ public class RedundancyPanel
     float threshold = slider.getValue();\r
     Vector del;\r
     HistoryItem it;\r
-    historyList.push(it=new HistoryItem("Remove redundancy",\r
-                                      ap.av.alignment, HistoryItem.HIDE));\r
-    if (historyList.size()==1\r
-        || !af.historyList.contains(historyList.firstElement())) {\r
-      af.addHistoryItem((HistoryItem) historyList.firstElement());\r
+    historyList.push(it = new HistoryItem("Remove redundancy",\r
+                                          ap.av.alignment, HistoryItem.HIDE));\r
+\r
+    if ( (historyList.size() == 1) ||\r
+        !af.historyList.contains(historyList.firstElement()))\r
+    {\r
+      af.addHistoryItem( (HistoryItem) historyList.firstElement());\r
       af.updateEditMenuBar();\r
     }\r
+\r
     undoButton.setEnabled(true);\r
+\r
     SequenceGroup sg = ap.av.getSelectionGroup();\r
-    if (sg != null && sg.getSize() >= 1)\r
-    {\r
 \r
+    if ( (sg != null) && (sg.getSize() >= 1))\r
+    {\r
       del = ap.av.alignment.removeRedundancy(threshold, sg.sequences);\r
+\r
       for (int i = 0; i < del.size(); i++)\r
       {\r
         if (sg.sequences.contains( (SequenceI) del.elementAt(i)))\r
@@ -77,32 +82,36 @@ public class RedundancyPanel
           sg.deleteSequence( (SequenceI) del.elementAt(i));\r
         }\r
       }\r
-\r
     }\r
     else\r
     {\r
       Vector s = new Vector();\r
       int i = 0;\r
+\r
       while (i < ap.av.alignment.getHeight())\r
       {\r
         s.addElement(ap.av.alignment.getSequenceAt(i));\r
         i++;\r
       }\r
+\r
       del = ap.av.alignment.removeRedundancy(threshold, s);\r
     }\r
 \r
     // This has to be done before the restoreHistoryItem method of alignFrame will\r
     // actually restore these sequences.\r
-\r
-    if (del.size()>0)\r
-      for (int i=0,j=del.size(); i<j; i++) {\r
+    if (del.size() > 0)\r
+    {\r
+      for (int i = 0, j = del.size(); i < j; i++)\r
+      {\r
         SequenceI sq = (SequenceI) del.elementAt(i);\r
-        sq.deleteChars(0,sq.getLength());\r
+        sq.deleteChars(0, sq.getLength());\r
       }\r
+    }\r
 \r
     ap.av.firePropertyChange("alignment", null,\r
                              ap.av.getAlignment().getSequences());\r
     ap.av.resetSeqLimits(ap.seqPanel.seqCanvas.getHeight());\r
+\r
     if (ap.av.getAlignment().getHeight() < 1)\r
     {\r
       try\r
@@ -110,22 +119,25 @@ public class RedundancyPanel
         af.setClosed(true);\r
       }\r
       catch (Exception ex)\r
-      {}\r
+      {\r
+      }\r
     }\r
+\r
     ap.av.updateConservation();\r
     ap.av.updateConsensus();\r
     af.updateEditMenuBar();\r
     ap.repaint();\r
-\r
   }\r
 \r
   public void undoButton_actionPerformed(ActionEvent e)\r
   {\r
     HistoryItem hi = (HistoryItem) historyList.pop();\r
     af.restoreHistoryItem(hi);\r
+\r
     if (historyList.size() == 0)\r
     {\r
       undoButton.setEnabled(false);\r
+\r
       if (af.historyList.contains(hi))\r
       {\r
         af.historyList.remove(hi);\r
@@ -133,6 +145,7 @@ public class RedundancyPanel
       }\r
     }\r
   }\r
+\r
   public void valueField_actionPerformed(ActionEvent e)\r
   {\r
     try\r