JAL-2438 handle null FeatureRenderer in FeatureColourFinder
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 15 Mar 2017 11:49:39 +0000 (11:49 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 15 Mar 2017 11:49:39 +0000 (11:49 +0000)
src/jalview/renderer/seqfeatures/FeatureColourFinder.java
test/jalview/renderer/seqfeatures/FeatureColourFinderTest.java

index d4a545b..1db2004 100644 (file)
@@ -102,7 +102,8 @@ public class FeatureColourFinder
    */
   boolean noFeaturesDisplayed()
   {
-    if (!featureRenderer.getViewport().isShowSequenceFeatures())
+    if (featureRenderer == null
+            || !featureRenderer.getViewport().isShowSequenceFeatures())
     {
       return true;
     }
index a7f2289..59566ed 100644 (file)
@@ -16,8 +16,8 @@ import jalview.schemes.FeatureColour;
 
 import java.awt.Color;
 
-import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
 /**
@@ -49,7 +49,7 @@ public class FeatureColourFinderTest
 
   private FeatureRenderer fr;
 
-  @BeforeClass(alwaysRun = true)
+  @BeforeTest(alwaysRun = true)
   public void setUp()
   {
     // aligned column 8 is sequence position 6
@@ -63,7 +63,8 @@ public class FeatureColourFinderTest
   }
 
   /**
-   * Clear down any sequence features before each test
+   * Clear down any sequence features before each test (not as easy as it
+   * sounds...)
    */
   @BeforeMethod(alwaysRun = true)
   public void setUpBeforeTest()
@@ -85,6 +86,9 @@ public class FeatureColourFinderTest
     {
       fr.setGroupVisibility(group, true);
     }
+
+    fr.clearRenderOrder();
+    av.setShowSequenceFeatures(true);
   }
 
   @Test(groups = "Functional")
@@ -397,9 +401,10 @@ public class FeatureColourFinderTest
 
     /*
      * add a feature
-     * it will be automatically set visible but the viewport
-     * is still configured not to show features
+     * it will be automatically set visible but we leave
+     * the viewport configured not to show features
      */
+    av.setShowSequenceFeatures(false);
     seq.addSequenceFeature(new SequenceFeature("Metal", "Metal", 2, 12,
             Float.NaN, "MetalGroup"));
     FeatureColour red = new FeatureColour(Color.red);
@@ -433,5 +438,11 @@ public class FeatureColourFinderTest
      */
     fr.setGroupVisibility("MetalGroup", false);
     assertFalse(finder.noFeaturesDisplayed());
+
+    /*
+     * a finder with no feature renderer
+     */
+    FeatureColourFinder finder2 = new FeatureColourFinder(null);
+    assertTrue(finder2.noFeaturesDisplayed());
   }
 }