From: gmungoc Date: Thu, 9 Feb 2017 10:04:13 +0000 (+0000) Subject: JAL-2371 ensure some colour scheme (may be None) is set on startup X-Git-Tag: Release_2_10_3b1~350 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=d93045ad69901a63115168c2a1e2ed2dbe1a92e2;p=jalview.git JAL-2371 ensure some colour scheme (may be None) is set on startup --- diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 69f155b..499faaf 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -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); } }