JAL-2371 correct Clustal, Blosum, PID colouring of consensus logo
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 6 Jan 2017 14:42:40 +0000 (14:42 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 6 Jan 2017 14:42:40 +0000 (14:42 +0000)
src/jalview/renderer/AnnotationRenderer.java

index e30fb0c..5973710 100644 (file)
@@ -29,8 +29,12 @@ import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.Annotation;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.ProfilesI;
+import jalview.schemes.CollectionColourScheme;
+import jalview.schemes.CollectionColourSchemeI;
 import jalview.schemes.ColourSchemeI;
+import jalview.schemes.NucleotideColourScheme;
 import jalview.schemes.ResidueProperties;
+import jalview.schemes.ZappoColourScheme;
 import jalview.util.Platform;
 
 import java.awt.BasicStroke;
@@ -70,7 +74,7 @@ public class AnnotationRenderer
   boolean av_renderHistogram = true, av_renderProfile = true,
           av_normaliseProfile = false;
 
-  ColourSchemeI profcolour = null;
+  CollectionColourSchemeI profcolour = null;
 
   private ColumnSelection columnSelection;
 
@@ -312,13 +316,17 @@ public class AnnotationRenderer
     av_renderHistogram = av.isShowConsensusHistogram();
     av_renderProfile = av.isShowSequenceLogo();
     av_normaliseProfile = av.isNormaliseSequenceLogo();
-    profcolour = av.getGlobalColourScheme();
-    if (profcolour == null)
+    profcolour = av.getViewportColourScheme();
+    if (profcolour == null || profcolour.getColourScheme() == null)
     {
-      // Set the default colour for sequence logo if the alignment has no
-      // colourscheme set
-      profcolour = av.getAlignment().isNucleotide() ? new jalview.schemes.NucleotideColourScheme()
-              : new jalview.schemes.ZappoColourScheme();
+      /*
+       * Use default colour for sequence logo if 
+       * the alignment has no colourscheme set
+       * (would like to use user preference but n/a for applet)
+       */
+      ColourSchemeI col = av.getAlignment().isNucleotide() ? new NucleotideColourScheme()
+              : new ZappoColourScheme();
+      profcolour = new CollectionColourScheme(col);
     }
     columnSelection = av.getColumnSelection();
     hconsensus = av.getSequenceConsensusHash();
@@ -1423,11 +1431,12 @@ hconsensus.get(column),
             {
               final String codonTranslation = ResidueProperties
                       .codonTranslate(new String(dc));
-              colour = profcolour.findColour(codonTranslation.charAt(0));
+              colour = profcolour.findColour(codonTranslation.charAt(0),
+                      column, null);
             }
             else
             {
-              colour = profcolour.findColour(dc[0]);
+              colour = profcolour.findColour(dc[0], column, null);
             }
             g.setColor(colour == Color.white ? Color.lightGray : colour);