X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FColumnSelection.java;h=9dbaced7e003f24275d064d64b6b274298649dfe;hb=eb5197242ba17fcff4ce0e18419ca81a63418f7a;hp=6b448320f0aa225a53a266ab9f75bfec1203163c;hpb=d4f6172fff9d39d2cf3bd1a8d0260521615a5993;p=jalview.git diff --git a/src/jalview/datamodel/ColumnSelection.java b/src/jalview/datamodel/ColumnSelection.java index 6b44832..9dbaced 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 (Version 2.4) + * Copyright (C) 2008 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]