fix recent file type bug
[jalview.git] / src / jalview / commands / RemoveGapColCommand.java
index dfcfc47..1e9b832 100644 (file)
@@ -1,7 +1,8 @@
 package jalview.commands;\r
-  /*\r
+\r
+/*\r
  * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * Copyright (C) 2007 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
@@ -20,18 +21,20 @@ package jalview.commands;
 \r
 import jalview.datamodel.*;\r
 \r
-public class RemoveGapColCommand  extends EditCommand\r
+public class RemoveGapColCommand\r
+    extends EditCommand\r
 {\r
+  int columnsDeleted;\r
   public RemoveGapColCommand(String description,\r
                              SequenceI[] seqs,\r
-                             int start, int end, char gapChar)\r
+                             int start, int end, AlignmentI al)\r
   {\r
     this.description = description;\r
 \r
     int j, jSize = seqs.length;\r
 \r
     int startCol = -1, endCol = -1;\r
-    int deletedCols = 0;\r
+    columnsDeleted = 0;\r
 \r
     edits = new Edit[0];\r
 \r
@@ -47,7 +50,9 @@ public class RemoveGapColCommand  extends EditCommand
           if (!jalview.util.Comparison.isGap(seqs[j].getCharAt(i)))\r
           {\r
             if (delete)\r
+            {\r
               endCol = i;\r
+            }\r
 \r
             delete = false;\r
             break;\r
@@ -63,12 +68,12 @@ public class RemoveGapColCommand  extends EditCommand
       if (!delete && startCol > -1)\r
       {\r
         this.appendEdit(DELETE_GAP, seqs,\r
-                        startCol - deletedCols,\r
+                        startCol - columnsDeleted,\r
                         endCol - startCol,\r
-                        gapChar,\r
+                        al,\r
                         false);\r
 \r
-        deletedCols += (endCol - startCol);\r
+        columnsDeleted += (endCol - startCol);\r
         startCol = -1;\r
         endCol = -1;\r
       }\r
@@ -76,22 +81,26 @@ public class RemoveGapColCommand  extends EditCommand
 \r
     if (delete && startCol > -1)\r
     {\r
-       //This is for empty columns at the\r
-       //end of the alignment\r
-       int width = end-endCol;\r
-\r
-      if(endCol==-1)\r
-        width = end-start+1;\r
-\r
+      //This is for empty columns at the\r
+      //end of the alignment\r
 \r
       this.appendEdit(DELETE_GAP, seqs,\r
-                        startCol - deletedCols,\r
-                        width,\r
-                        gapChar,\r
-                        false);\r
+                      startCol - columnsDeleted,\r
+                      end - startCol + 1,\r
+                      al,\r
+                      false);\r
+\r
+      columnsDeleted += (end - startCol + 1);\r
     }\r
 \r
     performEdit(0);\r
   }\r
 \r
+  public int getSize()\r
+  {\r
+    //We're interested in the number of columns deleted,\r
+    //Not the number of sequence edits.\r
+    return columnsDeleted;\r
+  }\r
+\r
 }\r