X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FColumnSelection.java;h=d0fc9277f5c5bbda923b5b7f0acc4d695c5f11de;hb=797df64fa2a0a30773d0f48f5494d4155e5a8be3;hp=6b448320f0aa225a53a266ab9f75bfec1203163c;hpb=d4f6172fff9d39d2cf3bd1a8d0260521615a5993;p=jalview.git diff --git a/src/jalview/datamodel/ColumnSelection.java b/src/jalview/datamodel/ColumnSelection.java index 6b44832..d0fc927 100644 --- a/src/jalview/datamodel/ColumnSelection.java +++ b/src/jalview/datamodel/ColumnSelection.java @@ -1,27 +1,26 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2006 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 + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) + * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle + * + * This file is part of Jalview. + * + * Jalview 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 3 of the License, or (at your option) any later version. + * + * Jalview 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 Jalview. If not, see . */ package jalview.datamodel; -import jalview.util.ShiftList; - import java.util.*; +import jalview.util.*; + /** * NOTE: Columns are zero based. */ @@ -29,13 +28,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 +56,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 +72,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 +213,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 +231,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 +253,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]