JAL-2371 CollectionColourScheme wraps ColourSchemeI
[jalview.git] / src / jalview / schemes / PIDColourScheme.java
index 389655c..a6301fa 100755 (executable)
@@ -21,7 +21,6 @@
 package jalview.schemes;
 
 import jalview.datamodel.AnnotatedCollectionI;
-import jalview.datamodel.ProfileI;
 import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
@@ -45,57 +44,47 @@ public class PIDColourScheme extends ResidueColourScheme
   }
 
   @Override
-  public Color findColour(char c, int j, SequenceI seq)
+  public Color findColour(char c, int j, SequenceI seq,
+          String consensusResidue, float pid)
   {
+    /*
+     * make everything uppercase; note this does nothing (fast)
+     * if consensusResidue is already uppercase
+     */
+    consensusResidue = consensusResidue.toUpperCase();
     if ('a' <= c && c <= 'z')
     {
       c -= ('a' - 'A');
     }
 
-    if (consensus == null || consensus.get(j) == null)
-    {
-      return Color.white;
-    }
-
-    if ((threshold != 0) && !aboveThreshold(c, j))
+    if (consensusResidue == null)
     {
       return Color.white;
     }
 
-    Color currentColour = Color.white;
-
-    double sc = 0;
-
+    Color colour = Color.white;
 
     /*
      * test whether this is the consensus (or joint consensus) residue
      */
-    ProfileI profile = consensus.get(j);
-    boolean matchesConsensus = profile.getModalResidue().contains(
+    boolean matchesConsensus = consensusResidue.contains(
             String.valueOf(c));
     if (matchesConsensus)
     {
-      sc = profile.getPercentageIdentity(ignoreGaps);
-
       if (!Comparison.isGap(c))
       {
         for (int i = 0; i < thresholds.length; i++)
         {
-          if (sc > thresholds[i])
+          if (pid > thresholds[i])
           {
-            currentColour = pidColours[i];
+            colour = pidColours[i];
             break;
           }
         }
       }
     }
 
-    if (conservationColouring)
-    {
-      currentColour = applyConservation(currentColour, j);
-    }
-
-    return currentColour;
+    return colour;
   }
 
   @Override