From: jprocter Date: Thu, 4 Oct 2007 16:32:06 +0000 (+0000) Subject: refactored invertColumnSelection as an object method X-Git-Tag: Release_2_4~252 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2fd908578cc00b0315504af557adf1366e4ac34a;p=jalview.git refactored invertColumnSelection as an object method --- diff --git a/src/jalview/datamodel/ColumnSelection.java b/src/jalview/datamodel/ColumnSelection.java index 73b7899..6cba6b3 100644 --- a/src/jalview/datamodel/ColumnSelection.java +++ b/src/jalview/datamodel/ColumnSelection.java @@ -962,10 +962,15 @@ public class ColumnSelection blockEnd = end; } - if (end > blockStart) + if (end >= blockStart) { - annels.addElement(els = new Annotation[end-blockStart]); - System.arraycopy(alignmentAnnotation.annotations, blockStart, els, 0, els.length); + annels.addElement(els = new Annotation[end-blockStart+1]); + if (end-blockStart+1<=alignmentAnnotation.annotations.length) + { + System.arraycopy(alignmentAnnotation.annotations, blockStart, els, 0, els.length); + } else { + System.arraycopy(alignmentAnnotation.annotations, blockStart, els, 0, (end-blockStart+1)); + } w+=els.length; } if (w==0) @@ -979,6 +984,33 @@ public class ColumnSelection System.arraycopy(chnk, 0, alignmentAnnotation.annotations, w, chnk.length); w+=chnk.length; } + } else { + alignmentAnnotation.restrict(start, end); + } + } + + /** + * Invert the column selection from first to end-1. + * leaves hiddenColumns untouched (and unselected) + * @param first + * @param end + */ + public void invertColumnSelection(int first, int width) + { + boolean hasHidden = hiddenColumns!=null && hiddenColumns.size()>0; + for(int i=first; i