X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FColumnSelection.java;h=5c1707fb9b79b910b1b82fe63377de4914acaf74;hb=4e892da7333869ad8b26d75b25f2c87352ca8c7e;hp=3c1d6f1c1647c527db7de65cad031028fdec6022;hpb=84a5a1ae1a0b6b4817356e06f1d0be4c22ce250b;p=jalview.git diff --git a/src/jalview/datamodel/ColumnSelection.java b/src/jalview/datamodel/ColumnSelection.java index 3c1d6f1..5c1707f 100644 --- a/src/jalview/datamodel/ColumnSelection.java +++ b/src/jalview/datamodel/ColumnSelection.java @@ -1,27 +1,27 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1) + * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ package jalview.datamodel; -import jalview.util.ShiftList; - import java.util.*; +import jalview.util.*; + /** * NOTE: Columns are zero based. */ @@ -29,13 +29,14 @@ public class ColumnSelection { Vector selected = new Vector(); - //Vector of int [] {startCol, endCol} + // Vector of int [] {startCol, endCol} Vector hiddenColumns; /** * Add a column to the selection - * - * @param col index of column + * + * @param col + * index of column */ public void addElement(int col) { @@ -56,8 +57,9 @@ public class ColumnSelection /** * removes col from selection - * - * @param col index of column to be removed + * + * @param col + * index of column to be removed */ public void removeElement(int col) { @@ -71,13 +73,16 @@ public class ColumnSelection /** * removes a range of columns from the selection - * @param start int - first column in range to be removed - * @param end int - last col + * + * @param start + * int - first column in range to be removed + * @param end + * int - last col */ public void removeElements(int start, int end) { Integer colInt; - for(int i=start; istart && start+change>region[1] ) + if (region[0] > start && start + change > region[1]) { - deletedHiddenColumns.addElement( - hiddenColumns.elementAt(i)); + deletedHiddenColumns.addElement(hiddenColumns.elementAt(i)); hiddenColumns.removeElementAt(i); i--; @@ -206,14 +214,16 @@ public class ColumnSelection continue; } - if(region[0]>start) + if (region[0] > start) { region[0] -= change; region[1] -= change; } - if(region[0]<0) + if (region[0] < 0) + { region[0] = 0; + } } @@ -222,11 +232,15 @@ public class ColumnSelection return deletedHiddenColumns; } + /** - * propagate shift in alignment columns to column selection - * special version of compensateForEdit - allowing for edits within hidden regions - * @param start beginning of edit - * @param left shift in edit (+ve for removal, or -ve for inserts) + * propagate shift in alignment columns to column selection special version of + * compensateForEdit - allowing for edits within hidden regions + * + * @param start + * beginning of edit + * @param left + * shift in edit (+ve for removal, or -ve for inserts) */ private void compensateForDelEdits(int start, int change) { @@ -240,175 +254,241 @@ public class ColumnSelection } } - if(hiddenColumns!=null) + if (hiddenColumns != null) { - for(int i=0; i= start) + if (region[0] >= start) { region[0] -= change; } - if (region[1]>= start) { - region[1] -=change; + if (region[1] >= start) + { + region[1] -= change; } - if (region[1]