sequence groups carry their own conservation and consensus annotation rows
[jalview.git] / src / jalview / appletgui / SequenceRenderer.java
index c41c35f..cf4c359 100755 (executable)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
- * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
+ * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -96,7 +96,7 @@ public class SequenceRenderer
     }
 
   }
-
+  
   public Color findSequenceColour(SequenceI seq, int i)
   {
     allGroups = av.alignment.findAllGroups(seq);
@@ -220,6 +220,11 @@ public class SequenceRenderer
           getBoxColour(currentSequenceGroup.cs, seq, i);
           graphics.setColor(resBoxColour.darker());
         }
+        if (currentSequenceGroup.getShowunconserved())
+        {
+          // cheat - use this if we have a consensus for each group: s = getDisplayChar(currentSequenceGroup.getConsensus(), i, s, '.');
+          s = getDisplayChar(av.consensus, i, s, '.');
+        }
       }
       else
       {
@@ -240,6 +245,11 @@ public class SequenceRenderer
             graphics.setColor(resBoxColour);
           }
         }
+        if (av.getShowunconserved())
+        {
+          s = getDisplayChar(av.consensus, i, s, '.');                       
+        }
       }
 
       if (av.upperCasebold)
@@ -261,7 +271,7 @@ public class SequenceRenderer
         }
 
       }
-
+      
       charOffset = (av.charWidth - fm.charWidth(s)) / 2;
       graphics.drawString(String.valueOf(s), charOffset + av.charWidth
               * (i - start), y1);
@@ -269,6 +279,17 @@ public class SequenceRenderer
 
   }
 
+  
+  private char getDisplayChar(AlignmentAnnotation consensus, int position, char s, char c)
+  {
+    char conschar = consensus.annotations[position].displayCharacter.charAt(0);
+    if (conschar!='-' && s==conschar)
+    {
+      s= c;
+    }
+    return s;
+  }
+
   boolean inCurrentSequenceGroup(int res)
   {
     if (allGroups == null)