JAL-2371 ensure some colour scheme (may be None) is set on startup
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 9 Feb 2017 10:04:13 +0000 (10:04 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 9 Feb 2017 10:04:13 +0000 (10:04 +0000)
src/jalview/gui/AlignViewport.java

index 69f155b..499faaf 100644 (file)
@@ -44,6 +44,7 @@ import jalview.datamodel.SequenceI;
 import jalview.renderer.ResidueShader;
 import jalview.schemes.ColourSchemeI;
 import jalview.schemes.ColourSchemeProperty;
+import jalview.schemes.ResidueColourScheme;
 import jalview.schemes.UserColourScheme;
 import jalview.structure.CommandListener;
 import jalview.structure.SelectionSource;
@@ -285,29 +286,27 @@ public class AlignViewport extends AlignmentViewport implements
     initAutoAnnotation();
     String colourProperty = alignment.isNucleotide() ? Preferences.DEFAULT_COLOUR_NUC
             : Preferences.DEFAULT_COLOUR_PROT;
-    String propertyValue = Cache.getProperty(colourProperty);
-    if (propertyValue == null)
+    String schemeName = Cache.getProperty(colourProperty);
+    if (schemeName == null)
     {
-      // fall back on this property for backwards compatibility
-      propertyValue = Cache.getProperty(Preferences.DEFAULT_COLOUR);
+      // only DEFAULT_COLOUR available in Jalview before 2.9
+      schemeName = Cache.getDefault(Preferences.DEFAULT_COLOUR,
+              ResidueColourScheme.NONE);
     }
-    if (propertyValue != null)
-    {
-      ColourSchemeI colourScheme = ColourSchemeProperty.getColourScheme(
-              alignment, propertyValue);
-      residueShading = new ResidueShader(colourScheme);
+    ColourSchemeI colourScheme = ColourSchemeProperty.getColourScheme(
+            alignment, schemeName);
+    residueShading = new ResidueShader(colourScheme);
 
-      if (colourScheme instanceof UserColourScheme)
-      {
-        residueShading = new ResidueShader(
-                UserDefinedColours.loadDefaultColours());
-        residueShading.setThreshold(0, isIgnoreGapsConsensus());
-      }
+    if (colourScheme instanceof UserColourScheme)
+    {
+      residueShading = new ResidueShader(
+              UserDefinedColours.loadDefaultColours());
+      residueShading.setThreshold(0, isIgnoreGapsConsensus());
+    }
 
-      if (residueShading != null)
-      {
-        residueShading.setConsensus(hconsensus);
-      }
+    if (residueShading != null)
+    {
+      residueShading.setConsensus(hconsensus);
     }
   }