check annotation size when cutting
authoramwaterhouse <Andrew Waterhouse>
Fri, 2 Feb 2007 17:34:11 +0000 (17:34 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 2 Feb 2007 17:34:11 +0000 (17:34 +0000)
src/jalview/commands/EditCommand.java

index f3b178f..1f60569 100644 (file)
@@ -357,7 +357,7 @@ public class EditCommand implements CommandI
       if(!insert)\r
         command.deletedAnnotations = new Hashtable();\r
 \r
-      int aSize, tSize;\r
+      int aSize;\r
       Annotation [] temp;\r
       for (int a = 0; a < annotations.length; a++)\r
       {\r
@@ -368,11 +368,14 @@ public class EditCommand implements CommandI
 \r
         aSize = annotations[a].annotations.length;\r
         if(insert)\r
-          tSize = aSize + command.number;\r
+          temp = new Annotation[aSize + command.number];\r
         else\r
-          tSize = aSize - command.number;\r
-\r
-        temp = new Annotation[tSize];\r
+        {\r
+          if(command.position<aSize)\r
+            temp = new Annotation[aSize - command.number + command.position];\r
+          else\r
+            temp = new Annotation[aSize];\r
+        }\r
 \r
         if(insert)\r
         {\r
@@ -406,7 +409,7 @@ public class EditCommand implements CommandI
         }\r
         else\r
         {\r
-          if(command.position < annotations[a].annotations.length)\r
+          if(command.position < aSize)\r
           {\r
             System.arraycopy(annotations[a].annotations,\r
                              0, temp, 0, command.position);\r