Formatting
[jalview.git] / src / jalview / commands / TrimRegionCommand.java
index 37518bc..4c1dea0 100644 (file)
@@ -1,6 +1,6 @@
 /*\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
  */\r
 package jalview.commands;\r
 \r
-import jalview.util.ShiftList;\r
+import java.util.*;\r
+\r
 import jalview.datamodel.*;\r
-import java.util.Vector;\r
+import jalview.util.*;\r
 \r
 public class TrimRegionCommand\r
     extends EditCommand\r
@@ -30,7 +31,7 @@ public class TrimRegionCommand
 \r
   public ColumnSelection colSel = null;\r
 \r
-  int [] start;\r
+  int[] start;\r
 \r
   ShiftList shiftList;\r
 \r
@@ -41,45 +42,52 @@ public class TrimRegionCommand
   int columnsDeleted;\r
 \r
   public TrimRegionCommand(String description,\r
-                     String command,\r
-                     SequenceI[] seqs,\r
-                     int column,\r
-                     AlignmentI al,\r
-                     ColumnSelection colSel,\r
-                     SequenceGroup selectedRegion)\r
+                           String command,\r
+                           SequenceI[] seqs,\r
+                           int column,\r
+                           AlignmentI al,\r
+                           ColumnSelection colSel,\r
+                           SequenceGroup selectedRegion)\r
   {\r
     this.description = description;\r
     this.selectionGroup = selectedRegion;\r
     this.colSel = colSel;\r
     if (command.equalsIgnoreCase(TRIM_LEFT))\r
     {\r
-      if(column==0)\r
+      if (column == 0)\r
+      {\r
         return;\r
+      }\r
 \r
       columnsDeleted = column;\r
 \r
-      edits = new Edit[] { new Edit(CUT, seqs, 0, column, al)};\r
+      edits = new Edit[]\r
+          {\r
+          new Edit(CUT, seqs, 0, column, al)};\r
     }\r
     else if (command.equalsIgnoreCase(TRIM_RIGHT))\r
     {\r
-      int width = al.getWidth()-column-1;\r
-      if(width<2)\r
+      int width = al.getWidth() - column - 1;\r
+      if (width < 2)\r
       {\r
         return;\r
       }\r
 \r
-      columnsDeleted = width-1;\r
+      columnsDeleted = width - 1;\r
 \r
       edits = new Edit[]\r
-          { new Edit(CUT, seqs, column+1, width, al)};\r
+          {\r
+          new Edit(CUT, seqs, column + 1, width, al)};\r
     }\r
 \r
     //We need to keep a record of the sequence start\r
     //in order to restore the state after a redo\r
     int i, isize = edits[0].seqs.length;\r
     start = new int[isize];\r
-    for(i=0; i<isize; i++)\r
+    for (i = 0; i < isize; i++)\r
+    {\r
       start[i] = edits[0].seqs[i].getStart();\r
+    }\r
 \r
     performEdit(0);\r
   }\r
@@ -89,7 +97,7 @@ public class TrimRegionCommand
     int column, j, jSize = command.seqs.length;\r
     for (j = 0; j < jSize; j++)\r
     {\r
-      if(command.position==0)\r
+      if (command.position == 0)\r
       {\r
         //This is a TRIM_LEFT command\r
         column = command.seqs[j].findPosition(command.number);\r
@@ -98,7 +106,7 @@ public class TrimRegionCommand
       else\r
       {\r
         //This is a TRIM_RIGHT command\r
-        column = command.seqs[j].findPosition(command.position)-1;\r
+        column = command.seqs[j].findPosition(command.position) - 1;\r
         command.seqs[j].setEnd(column);\r
       }\r
     }\r
@@ -108,14 +116,19 @@ public class TrimRegionCommand
     if (command.position == 0)\r
     {\r
       deletedHiddenColumns = colSel.compensateForEdit(0, command.number);\r
-      if(selectionGroup!=null)\r
+      if (selectionGroup != null)\r
+      {\r
         selectionGroup.adjustForRemoveLeft(command.number);\r
+      }\r
     }\r
     else\r
     {\r
-      deletedHiddenColumns = colSel.compensateForEdit(command.position, command.number);\r
-      if(selectionGroup!=null)\r
+      deletedHiddenColumns = colSel.compensateForEdit(command.position,\r
+          command.number);\r
+      if (selectionGroup != null)\r
+      {\r
         selectionGroup.adjustForRemoveRight(command.position);\r
+      }\r
     }\r
   }\r
 \r
@@ -125,14 +138,14 @@ public class TrimRegionCommand
     int column, j, jSize = command.seqs.length;\r
     for (j = 0; j < jSize; j++)\r
     {\r
-      if(command.position==0)\r
+      if (command.position == 0)\r
       {\r
         command.seqs[j].setStart(start[j]);\r
       }\r
       else\r
       {\r
         column = command.seqs[j]\r
-            .findPosition(command.number+command.position)-1;\r
+            .findPosition(command.number + command.position) - 1;\r
         command.seqs[j].setEnd(column);\r
       }\r
     }\r
@@ -140,8 +153,10 @@ public class TrimRegionCommand
     if (command.position == 0)\r
     {\r
       colSel.compensateForEdit(0, -command.number);\r
-      if(selectionGroup!=null)\r
-        selectionGroup.adjustForRemoveLeft(-command.number);\r
+      if (selectionGroup != null)\r
+      {\r
+        selectionGroup.adjustForRemoveLeft( -command.number);\r
+      }\r
     }\r
 \r
     if (deletedHiddenColumns != null)\r