JAL-3148 don't test av.showFeatures in FeatureColourFinder
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 6 Nov 2018 16:03:52 +0000 (16:03 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 6 Nov 2018 16:03:52 +0000 (16:03 +0000)
src/jalview/api/FeatureRenderer.java
src/jalview/renderer/OverviewRenderer.java
src/jalview/renderer/seqfeatures/FeatureColourFinder.java
src/jalview/renderer/seqfeatures/FeatureRenderer.java
test/jalview/renderer/seqfeatures/FeatureColourFinderTest.java

index cf3c8da..dc9b9b9 100644 (file)
@@ -43,6 +43,11 @@ public interface FeatureRenderer
    * taking into account sequence feature locations, feature colour schemes,
    * render ordering, feature and feature group visibility, and transparency.
    * <p>
+   * Does not take into account global feature visibility (show features on or
+   * off). Test for this before calling this method if necessary. This allows,
+   * for example, feature colours to be computed for structures even if not 
+   * shown on the alignment.
+   * <p>
    * The graphics argument should be provided if transparency is applied
    * (getTransparency() < 1). With feature transparency, visible features are
    * written to the graphics context and the composite colour may be read off
index e9b4de4..2441637 100644 (file)
@@ -79,7 +79,8 @@ public class OverviewRenderer
           AlignmentI alignment,
           ResidueShaderI resshader, OverviewResColourFinder colFinder)
   {
-    finder = new FeatureColourFinder(fr);
+    finder = fr.getViewport().isShowSequenceFeatures() ? 
+            new FeatureColourFinder(fr) : null;
     resColFinder = colFinder;
 
     al = alignment;
index cfe2735..99b5fb5 100644 (file)
@@ -83,7 +83,7 @@ public class FeatureColourFinder
   {
     if (noFeaturesDisplayed())
     {
-      return defaultColour;
+ //     return defaultColour;
     }
 
     Graphics g = null;
index 795cd36..73399cc 100644 (file)
@@ -211,11 +211,6 @@ public class FeatureRenderer extends FeatureRendererModel
   @Override
   public Color findFeatureColour(SequenceI seq, int column, Graphics g)
   {
-    if (!av.isShowSequenceFeatures())
-    {
-      return null;
-    }
-
     // column is 'base 1' but getCharAt is an array index (ie from 0)
     if (Comparison.isGap(seq.getCharAt(column - 1)))
     {
index d8b905e..657fcef 100644 (file)
@@ -110,9 +110,14 @@ public class FeatureColourFinderTest
     seq.addSequenceFeature(new SequenceFeature("Metal", "Metal", 2, 12,
             Float.NaN, "MetalGroup"));
     fr.featuresAdded();
+    fr.setColour("Metal",  new FeatureColour(Color.red));
+    
+    /*
+     * global show features flag is _not_ checked by findFeatureColour
+     */
     av.setShowSequenceFeatures(false);
     Color c = finder.findFeatureColour(Color.blue, seq, 10);
-    assertEquals(c, Color.blue);
+    assertEquals(c, Color.red);
   }
 
   @Test(groups = "Functional")