JAL-2361 Blosum is enabled for peptide
[jalview.git] / src / jalview / schemes / Blosum62ColourScheme.java
index 90f90f0..d68791c 100755 (executable)
@@ -30,11 +30,25 @@ import java.util.Map;
 
 public class Blosum62ColourScheme extends ResidueColourScheme
 {
+  private static final Color LIGHT_BLUE = new Color(204, 204, 255);
+  private static final Color DARK_BLUE = new Color(154, 154, 255);
+
   public Blosum62ColourScheme()
   {
     super();
   }
 
+  /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new Blosum62ColourScheme();
+  }
+
   @Override
   public Color findColour(char res, int j, SequenceI seq)
   {
@@ -44,7 +58,7 @@ public class Blosum62ColourScheme extends ResidueColourScheme
       res -= ('a' - 'A');
     }
 
-    if (consensus == null || j >= consensus.length || consensus[j] == null
+    if (consensus == null || consensus.get(j) == null
             || (threshold != 0 && !aboveThreshold(res, j)))
     {
       return Color.white;
@@ -54,12 +68,14 @@ public class Blosum62ColourScheme extends ResidueColourScheme
 
     if (!Comparison.isGap(res))
     {
-      String max = consensus[j].getModalResidue();
+      /*
+       * test if this is the consensus (or joint consensus) residue
+       */
+      String max = consensus.get(j).getModalResidue();
 
       if (max.indexOf(res) > -1)
       {
-        // TODO use a constant here?
-        currentColour = new Color(154, 154, 255);
+        currentColour = DARK_BLUE;
       }
       else
       {
@@ -74,8 +90,7 @@ public class Blosum62ColourScheme extends ResidueColourScheme
 
         if (c > 0)
         {
-          // TODO use a constant here?
-          currentColour = new Color(204, 204, 255);
+          currentColour = LIGHT_BLUE;
         }
         else
         {
@@ -97,10 +112,14 @@ public class Blosum62ColourScheme extends ResidueColourScheme
   }
 
   @Override
-  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
-          Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
+  public boolean isPeptideSpecific()
+  {
+    return true;
+  }
+
+  @Override
+  public String getSchemeName()
   {
-    ColourSchemeI newcs = super.applyTo(sg, hiddenRepSequences);
-    return newcs;
+    return JalviewColourScheme.Blosum62.toString();
   }
 }