+ int[] visible = visibleRegions.hasNext() ? visibleRegions.next() : null;
+ if (visible == null)
+ {
+ columnIndex = seqColEnd + 1;
+ return null;
+ }
+ seqColStart = Math.max(seqColStart, visible[0]);
+ seqColEnd = Math.min(seqColEnd, visible[1]);
+
+ /*
+ * restrict search to selected region if there is one
+ */
+ SequenceGroup selection = viewport.getSelectionGroup();
+ if (selection != null)
+ {
+ int selectionStart = selection.getStartRes();
+ int selectionEnd = selection.getEndRes();
+ if (selectionStart > seqColEnd || selectionEnd < seqColStart)
+ {
+ /*
+ * sequence region doesn't overlap selection region
+ */
+ columnIndex = seqColEnd + 1;
+ return null;
+ }
+ seqColStart = Math.max(seqColStart, selectionStart);
+ seqColEnd = Math.min(seqColEnd, selectionEnd);
+ }
+
+ return new Range(seqColStart, seqColEnd);