/*\r
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)\r
* Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle\r
* \r
* This file is part of Jalview.\r
}\r
\r
/**\r
- * Use this method to find out where a visible column is in the alignment when\r
- * hidden columns exist\r
+ * Use this method to find out where a column will appear in the visible\r
+ * alignment when hidden columns exist. If the column is not visible, then the\r
+ * left-most visible column will always be returned.\r
* \r
* @param hiddenColumn\r
* int\r
if (hiddenColumns != null)\r
{\r
int index = 0;\r
- int gaps = 0;\r
+ int[] region;\r
do\r
{\r
- int[] region = (int[]) hiddenColumns.elementAt(index);\r
+ region = (int[]) hiddenColumns.elementAt(index++);\r
if (hiddenColumn > region[1])\r
{\r
result -= region[1] + 1 - region[0];\r
}\r
- index++;\r
- } while (index < hiddenColumns.size());\r
-\r
- result -= gaps;\r
+ } while ((hiddenColumn > region[1]) && (index < hiddenColumns.size()));\r
+ if (hiddenColumn > region[0] && hiddenColumn < region[1])\r
+ {\r
+ return region[0] + hiddenColumn - result;\r
+ }\r
}\r
-\r
- return result;\r
+ return result; // return the shifted position after removing hidden columns.\r
}\r
\r
/**\r