blockEnd = end;\r
}\r
\r
- if (end > blockStart)\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
public void invertColumnSelection()
{
- for(int i=0; i<alignment.getWidth(); i++)
- {
- if(colSel.contains(i))
- {
- colSel.removeElement(i);
- }
- else
- {
- if (!hasHiddenColumns || colSel.isVisible(i))
- {
- colSel.addElement(i);
- }
- }
- }
+ colSel.invertColumnSelection(0,alignment.getWidth());
}
public int adjustForHiddenSeqs(int alignmentIndex)
* derived from the whole alignment or just the current
* selection with start and end points adjusted
* @note if you need references to the actual SequenceI objects in the alignment or currently selected then use getSequenceSelection()
- * @return String[]
+ * @return selection as new sequenceI objects
*/
public SequenceI[] getSelectionAsNewSequence()
{
return sequences;
}
+
/**
* get the currently selected sequence objects or all the sequences in the alignment.
* @return array of references to sequence objects