JAL-2360 structure viewers now using ColourMenuHelper, obsolete methods
[jalview.git] / src / jalview / schemes / ResidueColourScheme.java
index 38ab622..57f7d57 100755 (executable)
@@ -29,7 +29,6 @@ import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceI;
 import jalview.util.ColorUtils;
 import jalview.util.Comparison;
-import jalview.util.MessageManager;
 
 import java.awt.Color;
 import java.util.Map;
@@ -37,10 +36,12 @@ import java.util.Map;
 /**
  * Base class for residue-based colour schemes
  */
-public class ResidueColourScheme implements ColourSchemeI
+public abstract class ResidueColourScheme implements ColourSchemeI
 {
   public static final String NONE = "None";
 
+  public static final String USER_DEFINED = "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
@@ -117,6 +118,7 @@ public class ResidueColourScheme implements ColourSchemeI
   @Override
   public Color findColour()
   {
+    // TODO delete this method in favour of ColorUtils.parseColourString()?
     return findColour('A');
   }
 
@@ -346,24 +348,9 @@ public class ResidueColourScheme implements ColourSchemeI
   {
   }
 
-  @Override
-  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
-          Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
-  {
-    try
-    {
-      return getClass().newInstance();
-    } catch (Exception q)
-    {
-      throw new Error(MessageManager.formatMessage(
-              "error.implementation_error_cannot_duplicate_colour_scheme",
-              new String[] { getClass().getName() }), q);
-    }
-  }
-
   /**
    * Answers false if the colour scheme is nucleotide or peptide specific, and
-   * the data does not match, else false. Override to modify or extend this test
+   * the data does not match, else true. Override to modify or extend this test
    * as required.
    */
   @Override
@@ -375,12 +362,16 @@ public class ResidueColourScheme implements ColourSchemeI
     }
 
     /*
-     * inspect the data context (alignment dataset) for residue type
+     * inspect the data context (alignment) for residue type
      */
     boolean nucleotide = false;
-    AnnotatedCollectionI context = ac.getContext();
-    if (context != null)
+    if (ac instanceof AlignmentI)
     {
+      nucleotide = ((AlignmentI) ac).isNucleotide();
+    }
+    else
+    {
+      AnnotatedCollectionI context = ac.getContext();
       if (context instanceof AlignmentI)
       {
         nucleotide = ((AlignmentI) context).isNucleotide();
@@ -391,14 +382,6 @@ public class ResidueColourScheme implements ColourSchemeI
         return true;
       }
     }
-    else if (ac instanceof AlignmentI)
-    {
-      nucleotide = ((AlignmentI) ac).isNucleotide();
-    }
-    else
-    {
-      return true;
-    }
 
     /*
      * does data type match colour scheme type?
@@ -427,9 +410,13 @@ public class ResidueColourScheme implements ColourSchemeI
     return false;
   }
 
+  /**
+   * Default method returns true. Override this to return false in colour
+   * schemes that are not determined solely by the sequence symbol.
+   */
   @Override
-  public String getSchemeName()
+  public boolean isSimple()
   {
-    return "Residue";
+    return true;
   }
 }