X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FVisibleContigsIterator.java;h=9198de8086ebc42f73416554f7b83dc6874efa24;hb=5830d3c07ab8e6597cd38b3370f0c4121348f771;hp=ff060ac2aa56ee88a1261f3592eeca895b310e4a;hpb=fa20ec4effe2fb9205d844fd85befbe785bf1a2e;p=jalview.git
diff --git a/src/jalview/datamodel/VisibleContigsIterator.java b/src/jalview/datamodel/VisibleContigsIterator.java
index ff060ac..9198de8 100644
--- a/src/jalview/datamodel/VisibleContigsIterator.java
+++ b/src/jalview/datamodel/VisibleContigsIterator.java
@@ -1,3 +1,23 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * 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 .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.datamodel;
import java.util.ArrayList;
@@ -5,7 +25,9 @@ import java.util.Iterator;
import java.util.List;
/**
- * An iterator which iterates over visible regions in a range.
+ * An iterator which iterates over visible regions in a range. Provides a
+ * special "endsAtHidden" indicator to allow callers to determine if the final
+ * visible column is adjacent to a hidden region.
*/
public class VisibleContigsIterator implements Iterator
{
@@ -15,8 +37,7 @@ public class VisibleContigsIterator implements Iterator
private boolean endsAtHidden = false;
- VisibleContigsIterator(int start, int end,
- List hiddenColumns)
+ VisibleContigsIterator(int start, int end, List hiddenColumns)
{
if (hiddenColumns != null && hiddenColumns.size() > 0)
{
@@ -37,9 +58,17 @@ public class VisibleContigsIterator implements Iterator
}
if (hideStart > vstart)
{
- int[] contig = new int[] { vstart, hideStart - 1 };
- vcontigs.add(contig);
- endsAtHidden = true;
+ if (end - 1 > hideStart - 1)
+ {
+ int[] contig = new int[] { vstart, hideStart - 1 };
+ vcontigs.add(contig);
+ endsAtHidden = true;
+ }
+ else
+ {
+ int[] contig = new int[] { vstart, end - 1 };
+ vcontigs.add(contig);
+ }
}
vstart = hideEnd + 1;
@@ -83,4 +112,3 @@ public class VisibleContigsIterator implements Iterator
return endsAtHidden;
}
}
-