From dab7d55392edfa7307e8d7be5f5dde69c9808f30 Mon Sep 17 00:00:00 2001 From: kiramt Date: Mon, 6 Nov 2017 14:12:40 +0000 Subject: [PATCH] JAL-2759 fix getHiddenOffset iterating backwards --- src/jalview/datamodel/HiddenColumns.java | 4 ++-- src/jalview/datamodel/HiddenColumnsCursor.java | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/jalview/datamodel/HiddenColumns.java b/src/jalview/datamodel/HiddenColumns.java index 3710829..b86a1a1 100644 --- a/src/jalview/datamodel/HiddenColumns.java +++ b/src/jalview/datamodel/HiddenColumns.java @@ -268,8 +268,8 @@ public class HiddenColumns { result += cursor.getHiddenOffset(column); - /* - Iterator it = hiddenColumns.iterator(); + + /*Iterator it = hiddenColumns.iterator(); while (it.hasNext()) { int[] region = it.next(); diff --git a/src/jalview/datamodel/HiddenColumnsCursor.java b/src/jalview/datamodel/HiddenColumnsCursor.java index 44ceb2a..7fa96c1 100644 --- a/src/jalview/datamodel/HiddenColumnsCursor.java +++ b/src/jalview/datamodel/HiddenColumnsCursor.java @@ -87,8 +87,8 @@ public class HiddenColumnsCursor return -1; } - int index = getIndex(); - int hiddenCount = getHiddenSoFar(); + int index = regionIndex; + int hiddenCount = hiddenSoFar; if (index == hiddenColumns.size()) { @@ -109,12 +109,13 @@ public class HiddenColumnsCursor index = 0; hiddenCount = 0; } - else if (column > lastColumn) + /*else if (column > lastColumn) { index = hiddenColumns.size(); // TODO resolve here - need full hidden count - } - else if (column > hiddenColumns.get(index)[1]) + }*/ + else if (column > hiddenColumns.get(index)[1]) // includes if column > + // lastColumn { // iterate from where we are now, if we're lucky we'll be close by // (but still better than iterating from 0) @@ -171,7 +172,7 @@ public class HiddenColumnsCursor else if (index < hiddenColumns.size()) { while ((index > 0) - && (hiddenColumns.get(index)[1] > column + hiddenCount)) + && (hiddenColumns.get(index - 1)[1] >= column + hiddenCount)) { index--; int[] region = hiddenColumns.get(index); -- 1.7.10.2