patch to fix occasional arrayoutofbounds exception when working with hidden columns...
[jalview.git] / src / jalview / datamodel / ColumnSelection.java
index ca54570..9dbaced 100644 (file)
@@ -998,15 +998,17 @@ public class ColumnSelection
       if (end > blockStart)\r
       {\r
         annels.addElement(els = new Annotation[end - blockStart + 1]);\r
-        if (end - blockStart + 1 <= alignmentAnnotation.annotations.length)\r
+        if ((els.length+blockStart)<= alignmentAnnotation.annotations.length)\r
         {\r
+          // copy just the visible segment of the annotation row\r
           System.arraycopy(alignmentAnnotation.annotations, blockStart,\r
                   els, 0, els.length);\r
         }\r
         else\r
         {\r
+          // copy to the end of the annotation row\r
           System.arraycopy(alignmentAnnotation.annotations, blockStart,\r
-                  els, 0, (end - blockStart + 1));\r
+                  els, 0, (alignmentAnnotation.annotations.length - blockStart));\r
         }\r
         w += els.length;\r
       }\r