JAL-2360 refactoring for JalviewColourScheme enum,
[jalview.git] / src / jalview / schemes / TCoffeeColourScheme.java
index bc56281..19c92a0 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9)
- * Copyright (C) 2015 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
@@ -86,6 +86,10 @@ public class TCoffeeColourScheme extends ResidueColourScheme
     seqMap = new IdentityHashMap<SequenceI, Color[]>();
     AnnotatedCollectionI alcontext = alignment instanceof AlignmentI ? alignment
             : alignment.getContext();
+    if (alcontext == null)
+    {
+      return;
+    }
     int w = 0;
     for (AlignmentAnnotation al : alcontext
             .findAnnotation(TCoffeeScoreFile.TCOFFEE_SCORE))
@@ -137,4 +141,35 @@ public class TCoffeeColourScheme extends ResidueColourScheme
   {
     return new TCoffeeColourScheme(sg);
   }
+
+  /**
+   * Answers true if the annotated data has TCoffee score annotation
+   */
+  @Override
+  public boolean isApplicableTo(AnnotatedCollectionI ac)
+  {
+    if (ac.getContext() != null)
+    {
+      ac = ac.getContext();
+    }
+    AlignmentAnnotation[] anns = ac.getAlignmentAnnotation();
+    if (anns == null)
+    {
+      return false;
+    }
+    for (AlignmentAnnotation ann : anns)
+    {
+      if (TCoffeeScoreFile.TCOFFEE_SCORE.equals(ann.getCalcId()))
+      {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  @Override
+  public String getSchemeName()
+  {
+    return JalviewColourScheme.TCoffee.toString();
+  }
 }