char array replaces string for cuts
authoramwaterhouse <Andrew Waterhouse>
Thu, 30 Nov 2006 17:15:19 +0000 (17:15 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 30 Nov 2006 17:15:19 +0000 (17:15 +0000)
src/jalview/commands/EditCommand.java

index 83e4417..72d82aa 100644 (file)
@@ -37,10 +37,10 @@ import jalview.datamodel.*;
  */\r
 public class EditCommand implements CommandI\r
 {\r
-  public static String INSERT_GAP = "InsertGap";\r
-  public static String DELETE_GAP = "DeleteGap";\r
-  public static String CUT = "Cut";\r
-  public static String PASTE = "Paste";\r
+  public static final int INSERT_GAP = 0;\r
+  public static final int DELETE_GAP = 1;\r
+  public static final int CUT = 2;\r
+  public static final int PASTE = 3;\r
 \r
   Edit[] edits;\r
 \r
@@ -55,7 +55,7 @@ public class EditCommand implements CommandI
   }\r
 \r
   public EditCommand(String description,\r
-                     String command,\r
+                     int command,\r
                      SequenceI[] seqs,\r
                      int position,\r
                      int number,\r
@@ -63,8 +63,7 @@ public class EditCommand implements CommandI
   {\r
     this.description = description;\r
 \r
-    if (command.equalsIgnoreCase(INSERT_GAP)\r
-        || command.equalsIgnoreCase(DELETE_GAP))\r
+    if (command==INSERT_GAP || command==DELETE_GAP)\r
     {\r
       edits = new Edit[] { new Edit(command, seqs, position, number, gapChar)};\r
     }\r
@@ -73,14 +72,14 @@ public class EditCommand implements CommandI
   }\r
 \r
   public EditCommand( String description,\r
-                      String command,\r
+                      int command,\r
                       SequenceI[] seqs,\r
                       int position,\r
                       int number,\r
                       AlignmentI al)\r
    {\r
      this.description = description;\r
-     if ( command.equalsIgnoreCase(CUT) || command.equalsIgnoreCase(PASTE))\r
+     if ( command==CUT || command==PASTE)\r
      {\r
        edits = new Edit[]{new Edit(command, seqs, position, number, al)};\r
      }\r
@@ -105,7 +104,7 @@ public class EditCommand implements CommandI
   }\r
 \r
 \r
-  public void appendEdit(String command,\r
+  public void appendEdit(int command,\r
                          SequenceI[] seqs,\r
                          int position,\r
                          int number,\r
@@ -133,19 +132,19 @@ public class EditCommand implements CommandI
     int eSize = edits.length;\r
     for (int e = commandIndex; e < eSize; e++)\r
     {\r
-      if (edits[e].command.equals(INSERT_GAP))\r
+      if (edits[e].command==INSERT_GAP)\r
       {\r
         insertGap(edits[e]);\r
       }\r
-      else if (edits[e].command.equals(DELETE_GAP))\r
+      else if (edits[e].command==DELETE_GAP)\r
       {\r
         deleteGap(edits[e]);\r
       }\r
-      else if(edits[e].command.equals(CUT))\r
+      else if(edits[e].command==CUT)\r
       {\r
         cut(edits[e]);\r
       }\r
-      else if(edits[e].command.equals(PASTE))\r
+      else if(edits[e].command==PASTE)\r
       {\r
         paste(edits[e]);\r
       }\r
@@ -162,19 +161,19 @@ public class EditCommand implements CommandI
     int e = 0, eSize = edits.length;\r
     for (e = eSize-1; e > -1; e--)\r
     {\r
-      if (edits[e].command.equals(INSERT_GAP))\r
+      if (edits[e].command==INSERT_GAP)\r
       {\r
         deleteGap(edits[e]);\r
       }\r
-      else if (edits[e].command.equals(DELETE_GAP))\r
+      else if (edits[e].command==DELETE_GAP)\r
       {\r
         insertGap(edits[e]);\r
       }\r
-      else if (edits[e].command.equals(CUT))\r
+      else if (edits[e].command==CUT)\r
       {\r
         paste(edits[e]);\r
       }\r
-      else if (edits[e].command.equals(PASTE))\r
+      else if (edits[e].command==PASTE)\r
       {\r
         cut(edits[e]);\r
       }\r
@@ -201,14 +200,14 @@ public class EditCommand implements CommandI
 \r
   void cut(Edit command)\r
   {\r
-    command.string = new String [command.seqs.length];\r
+    command.string = new char [command.seqs.length][];\r
 \r
     for(int i=0; i<command.seqs.length; i++)\r
     {\r
       if(command.seqs[i].getLength()>command.position)\r
       {\r
         command.string[i] = command.seqs[i].getSequence(command.position,\r
-            command.position + command.number);\r
+            command.position + command.number).toCharArray();\r
 \r
         command.seqs[i].deleteChars(command.position,\r
                                     command.position + command.number);\r
@@ -263,14 +262,14 @@ public class EditCommand implements CommandI
   class Edit\r
   {\r
     AlignmentI al;\r
-    String command;\r
-    String [] string;\r
+    int command;\r
+    char [][] string;\r
     SequenceI[] seqs;\r
     int [] alIndex;\r
     int position, number;\r
     char gapChar;\r
 \r
-    Edit(String command,\r
+    Edit(int command,\r
          SequenceI[] seqs,\r
          int position,\r
          int number,\r
@@ -284,7 +283,7 @@ public class EditCommand implements CommandI
     }\r
 \r
 \r
-    Edit(String command,\r
+    Edit(int command,\r
          SequenceI[] seqs,\r
          int position,\r
          int number,\r