JAL-2526 correct treatment of contact features only partly visible
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 30 Jun 2017 09:44:37 +0000 (10:44 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 30 Jun 2017 09:44:37 +0000 (10:44 +0100)
src/jalview/renderer/seqfeatures/FeatureRenderer.java

index 541288e..3f44bcc 100644 (file)
@@ -309,10 +309,26 @@ public class FeatureRenderer extends FeatureRendererModel
       for (SequenceFeature sf : overlaps)
       {
         Color featureColour = fc.getColor(sf);
-        int visibleStart = Math.max(sf.getBegin(),
-                visiblePositions.getBegin());
+
+        /*
+         * if feature starts/ends outside the visible range,
+         * restrict to visible positions (or if a contact feature,
+         * to a single position)
+         */
+        int visibleStart = sf.getBegin();
+        if (visibleStart < visiblePositions.getBegin())
+        {
+          visibleStart = sf.isContactFeature() ? sf.getEnd()
+                  : visiblePositions.getBegin();
+        }
+        int visibleEnd = sf.getEnd();
+        if (visibleEnd > visiblePositions.getEnd())
+        {
+          visibleEnd = sf.isContactFeature() ? sf.getBegin()
+                  : visiblePositions.getEnd();
+        }
+
         int featureStartCol = seq.findIndex(visibleStart);
-        int visibleEnd = Math.min(sf.getEnd(), visiblePositions.getEnd());
         int featureEndCol = sf.begin == sf.end ? featureStartCol : seq
                 .findIndex(visibleEnd);