checks for negative start column in restrict
authorjprocter <Jim Procter>
Wed, 2 May 2007 12:19:55 +0000 (12:19 +0000)
committerjprocter <Jim Procter>
Wed, 2 May 2007 12:19:55 +0000 (12:19 +0000)
src/jalview/datamodel/AlignmentAnnotation.java

index cc4308d..3ed84a3 100755 (executable)
@@ -357,12 +357,18 @@ Loading...
    */
   public void restrict(int startRes, int endRes)
   {
+    if (startRes<0)
+      startRes=0;
+    if (startRes>=annotations.length)
+      startRes = annotations.length-1;
+    if (endRes>=annotations.length)
+      endRes = annotations.length-1;
     if (annotations==null)
       return;
     Annotation[] temp = new Annotation[endRes-startRes+1];
     if (startRes<annotations.length)
     {
-      System.arraycopy(annotations, startRes, temp, 0, Math.min(endRes, annotations.length-1)-startRes+1);
+      System.arraycopy(annotations, startRes, temp, 0, endRes-startRes+1);
     }
     if (sequenceRef!=null) {
       // Clip the mapping, if it exists.