spike branch updated from latest features/JAL-2446
[jalview.git] / src / jalview / schemes / ResidueColourScheme.java
index 892c3e8..b47b82e 100755 (executable)
  */
 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;
@@ -87,12 +86,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
+    if (colors != null && symbolIndex != null
             && c < symbolIndex.length
             && symbolIndex[c] < colors.length)
     {
@@ -147,30 +145,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())