+ annels.addElement(els = new Annotation[blockEnd - blockStart]);\r
+ System.arraycopy(alignmentAnnotation.annotations, blockStart, els,\r
+ 0, els.length);\r
+ w += els.length;\r
+ blockStart = hideEnd + 1;\r
+ blockEnd = end;\r
+ }\r
+\r
+ if (end > blockStart)\r
+ {\r
+ annels.addElement(els = new Annotation[end - blockStart + 1]);\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,\r
+ (alignmentAnnotation.annotations.length - blockStart));\r
+ }\r
+ w += els.length;\r
+ }\r
+ if (w == 0)\r
+ return;\r
+ Enumeration e = annels.elements();\r
+ alignmentAnnotation.annotations = new Annotation[w];\r
+ w = 0;\r
+ while (e.hasMoreElements())\r
+ {\r
+ Annotation[] chnk = (Annotation[]) e.nextElement();\r
+ System.arraycopy(chnk, 0, alignmentAnnotation.annotations, w,\r
+ chnk.length);\r
+ w += chnk.length;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ alignmentAnnotation.restrict(start, end);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Invert the column selection from first to end-1. leaves hiddenColumns\r
+ * untouched (and unselected)\r
+ * \r
+ * @param first\r
+ * @param end\r
+ */\r
+ public void invertColumnSelection(int first, int width)\r
+ {\r
+ boolean hasHidden = hiddenColumns != null && hiddenColumns.size() > 0;\r
+ for (int i = first; i < width; i++)\r
+ {\r
+ if (contains(i))\r
+ {\r
+ removeElement(i);\r
+ }\r
+ else\r
+ {\r
+ if (!hasHidden || isVisible(i))\r
+ {\r
+ addElement(i);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * add in any unselected columns from the given column selection, excluding\r
+ * any that are hidden.\r
+ * \r
+ * @param colsel\r
+ */\r
+ public void addElementsFrom(ColumnSelection colsel)\r
+ {\r
+ if (colsel != null && colsel.size() > 0)\r
+ {\r
+ Enumeration e = colsel.getSelected().elements();\r
+ while (e.hasMoreElements())\r
+ {\r
+ Object eo = e.nextElement();\r
+ if (hiddenColumns != null && isVisible(((Integer) eo).intValue()))\r
+ {\r
+ if (!selected.contains(eo))\r