X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FResidueColourScheme.java;h=34a5daa6ab9dca3ef2c246f1857263dfdf493cbe;hb=94bf79437b377c8da9a9b78757bb6639a8fae2f5;hp=892c3e8a59a1b857f85c90ab589b40da2023924c;hpb=a3fb8ffb6b29504b24717bf1dafc45d8f04abc67;p=jalview.git diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index 892c3e8..34a5daa 100755 --- a/src/jalview/schemes/ResidueColourScheme.java +++ b/src/jalview/schemes/ResidueColourScheme.java @@ -20,11 +20,10 @@ */ package jalview.schemes; -import jalview.datamodel.AlignmentI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; +import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; -import jalview.util.Comparison; import java.awt.Color; import java.util.Map; @@ -36,9 +35,17 @@ public abstract class ResidueColourScheme implements ColourSchemeI { public static final String NONE = "None"; + /* + * default display name for a user defined colour scheme + */ public static final String USER_DEFINED = "User Defined"; /* + * name for (new) "User Defined.." colour scheme menu item + */ + public static final String USER_DEFINED_MENU = "*User Defined*"; + + /* * lookup up by character value e.g. 'G' to the colors array index * e.g. if symbolIndex['K'] = 11 then colors[11] is the colour for K */ @@ -55,8 +62,9 @@ public abstract class ResidueColourScheme implements ColourSchemeI /** * Creates a new ResidueColourScheme object. * - * @param final int[] index table into colors (ResidueProperties.naIndex or - * ResidueProperties.aaIndex) + * @param final + * int[] index table into colors (ResidueProperties.naIndex or + * ResidueProperties.aaIndex) * @param colors * colours for symbols in sequences */ @@ -87,13 +95,11 @@ public abstract class ResidueColourScheme implements ColourSchemeI /** * Find a colour without an index in a sequence */ - @Override public Color findColour(char c) { Color colour = Color.white; - if (!Comparison.isGap(c) && colors != null && symbolIndex != null - && c < symbolIndex.length + if (colors != null && symbolIndex != null && c < symbolIndex.length && symbolIndex[c] < colors.length) { colour = colors[symbolIndex[c]]; @@ -147,30 +153,26 @@ public abstract class ResidueColourScheme implements ColourSchemeI { return true; } - - /* - * inspect the data context (alignment) for residue type - */ - boolean nucleotide = false; - if (ac instanceof AlignmentI) + if (ac == null) { - nucleotide = ((AlignmentI) ac).isNucleotide(); + return true; } - else + /* + * pop-up menu on selection group before group created + * (no alignment context) + */ + // TODO: add nucleotide flag to SequenceGroup? + if (ac instanceof SequenceGroup && ac.getContext() == null) { - AnnotatedCollectionI context = ac.getContext(); - if (context instanceof AlignmentI) - { - nucleotide = ((AlignmentI) context).isNucleotide(); - } - else - { - // not sure what's going on, play safe - return true; - } + return true; } /* + * inspect the data context (alignment) for residue type + */ + boolean nucleotide = ac.isNucleotide(); + + /* * does data type match colour scheme type? */ return (nucleotide && isNucleotideSpecific())