/*\r
- * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
- *\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)\r
+ * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * \r
* This program is free software; you can redistribute it and/or\r
* modify it under the terms of the GNU General Public License\r
* as published by the Free Software Foundation; either version 2\r
* of the License, or (at your option) any later version.\r
- *\r
+ * \r
* This program is distributed in the hope that it will be useful,\r
* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
* GNU General Public License for more details.\r
- *\r
+ * \r
* You should have received a copy of the GNU General Public License\r
* along with this program; if not, write to the Free Software\r
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
\r
if (end > blockStart)\r
{\r
- annels.addElement(els = new Annotation[end-blockStart]);\r
- System.arraycopy(alignmentAnnotation.annotations, blockStart, els, 0, els.length);\r
+ annels.addElement(els = new Annotation[end-blockStart+1]);\r
+ if (end-blockStart+1<=alignmentAnnotation.annotations.length)\r
+ {\r
+ System.arraycopy(alignmentAnnotation.annotations, blockStart, els, 0, els.length);\r
+ } else {\r
+ System.arraycopy(alignmentAnnotation.annotations, blockStart, els, 0, (end-blockStart+1));\r
+ }\r
w+=els.length;\r
}\r
if (w==0)\r
System.arraycopy(chnk, 0, alignmentAnnotation.annotations, w, chnk.length);\r
w+=chnk.length;\r
}\r
+ } else {\r
+ alignmentAnnotation.restrict(start, end);\r
}\r
}\r
+\r
+ /**\r
+ * Invert the column selection from first to end-1.\r
+ * leaves hiddenColumns untouched (and unselected)\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