From 3771e24b8898aacbf9ad8b87727972cd4604e3db Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 15 Mar 2017 11:49:39 +0000 Subject: [PATCH] JAL-2438 handle null FeatureRenderer in FeatureColourFinder --- .../renderer/seqfeatures/FeatureColourFinder.java | 3 ++- .../seqfeatures/FeatureColourFinderTest.java | 21 +++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/jalview/renderer/seqfeatures/FeatureColourFinder.java b/src/jalview/renderer/seqfeatures/FeatureColourFinder.java index d4a545b..1db2004 100644 --- a/src/jalview/renderer/seqfeatures/FeatureColourFinder.java +++ b/src/jalview/renderer/seqfeatures/FeatureColourFinder.java @@ -102,7 +102,8 @@ public class FeatureColourFinder */ boolean noFeaturesDisplayed() { - if (!featureRenderer.getViewport().isShowSequenceFeatures()) + if (featureRenderer == null + || !featureRenderer.getViewport().isShowSequenceFeatures()) { return true; } diff --git a/test/jalview/renderer/seqfeatures/FeatureColourFinderTest.java b/test/jalview/renderer/seqfeatures/FeatureColourFinderTest.java index a7f2289..59566ed 100644 --- a/test/jalview/renderer/seqfeatures/FeatureColourFinderTest.java +++ b/test/jalview/renderer/seqfeatures/FeatureColourFinderTest.java @@ -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()); } } -- 1.7.10.2