JAL-3187 draw complement features on alignment / structure
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 21 Jan 2019 15:32:06 +0000 (15:32 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 21 Jan 2019 15:32:06 +0000 (15:32 +0000)
src/jalview/renderer/seqfeatures/FeatureRenderer.java

index d833a19..ac8f6d9 100644 (file)
@@ -275,7 +275,8 @@ public class FeatureRenderer extends FeatureRendererModel
      * if columns are all gapped, or sequence has no features, nothing to do
      */
     Range visiblePositions = seq.findPositions(start+1, end+1);
-    if (visiblePositions == null || !seq.getFeatures().hasFeatures())
+    if (visiblePositions == null || (!seq.getFeatures().hasFeatures()
+            && !av.isShowComplementFeatures()))
     {
       return null;
     }
@@ -396,6 +397,30 @@ public class FeatureRenderer extends FeatureRendererModel
       }
     }
 
+    /*
+     * if configured to do so, find and show complement's features
+     */
+    if (av.isShowComplementFeatures())
+    {
+      AlignViewportI comp = av.getCodingComplement();
+      FeatureRenderer fr2 = Desktop.getAlignFrameFor(comp)
+              .getFeatureRenderer();
+      for (int pos = visiblePositions.start; pos <= visiblePositions.end; pos++)
+      {
+        int column = seq.findIndex(pos);
+        // TODO ensure these are in complement's render order (last on top)
+        List<SequenceFeature> features = fr2
+                .findComplementFeaturesAtResidue(seq, pos);
+        for (SequenceFeature sf : features)
+        {
+          FeatureColourI fc = fr2.getFeatureStyle(sf.getType());
+          Color featureColour = fr2.getColor(sf, fc);
+          renderFeature(g, seq, column - 1, column - 1, featureColour,
+                  start, end, y1, colourOnly);
+        }
+      }
+    }
+
     if (transparency != 1.0f && g != null)
     {
       /*