JAL-2674 Simplify locateVisibleBoundsOfSequence
[jalview.git] / src / jalview / renderer / ScaleRenderer.java
index d310705..6d4edd9 100644 (file)
@@ -68,17 +68,23 @@ public class ScaleRenderer
     int scalestartx = (startx / 10) * 10;
 
     SequenceI refSeq = av.getAlignment().getSeqrep();
-    int refSp = 0, refStartI = 0, refEndI = -1;
+    int refSp = 0;
+    int refStartI = 0;
+    int refEndI = -1;
     if (refSeq != null)
     {
-      // find bounds and set origin appopriately
+      // find bounds and set origin appropriately
       // locate first visible position for this sequence
-      int[] refbounds = av.getAlignment().getHiddenColumns()
+      refSp = av.getAlignment().getHiddenColumns()
               .locateVisibleBoundsOfSequence(refSeq);
 
-      refSp = refbounds[0];
-      refStartI = refbounds[1];
-      refEndI = refbounds[2];
+      refStartI = refSeq.findIndex(refSeq.getStart()) - 1;
+
+      int seqlength = refSeq.getLength();
+      // get sequence position past the end of the sequence
+      int pastEndPos = refSeq.findPosition(seqlength + 1);
+      refEndI = refSeq.findIndex(pastEndPos - 1) - 1;
+
       scalestartx = refSp + ((scalestartx - refSp) / 10) * 10;
     }