JAL-1620 version bump and release notes
[jalview.git] / src / jalview / renderer / AnnotationRenderer.java
index 06014c5..b48d83f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1)
  * Copyright (C) 2014 The Jalview Authors
  * 
  * This file is part of Jalview.
@@ -27,6 +27,7 @@ import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.Annotation;
 import jalview.datamodel.ColumnSelection;
 import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ResidueProperties;
 
 import java.awt.BasicStroke;
 import java.awt.Color;
@@ -77,17 +78,17 @@ public class AnnotationRenderer
     int x2 = (x * charWidth);
     Regex closeparen = new Regex("(\\))");
 
-    String dc = (column == 0 || row_annotations[column - 1] == null) ? ""
-            : row_annotations[column - 1].displayCharacter;
+    char dc = (column == 0 || row_annotations[column - 1] == null) ? ' '
+            : row_annotations[column - 1].secondaryStructure;
 
     boolean diffupstream = sCol == 0 || row_annotations[sCol - 1] == null
-            || !dc.equals(row_annotations[sCol - 1].displayCharacter);
+            || dc != row_annotations[sCol - 1].secondaryStructure;
     boolean diffdownstream = !validRes || !validEnd
             || row_annotations[column] == null
-            || !dc.equals(row_annotations[column].displayCharacter);
+            || dc != row_annotations[column].secondaryStructure;
     // System.out.println("Column "+column+" diff up: "+diffupstream+" down:"+diffdownstream);
     // If a closing base pair half of the stem, display a backward arrow
-    if (column > 0 && closeparen.search(dc))
+    if (column > 0 && ResidueProperties.isCloseParenRNA(dc))
     {
 
       if (diffupstream)
@@ -297,6 +298,7 @@ public class AnnotationRenderer
       profcolour = av.getAlignment().isNucleotide() ? new jalview.schemes.NucleotideColourScheme()
               : new jalview.schemes.ZappoColourScheme();
     }
+    boolean rna = av.getAlignment().isNucleotide();
     columnSelection = av.getColumnSelection();
     hconsensus = av.getSequenceConsensusHash();// hconsensus;
     hStrucConsensus = av.getRnaStructureConsensusHash(); // hStrucConsensus;
@@ -353,6 +355,8 @@ public class AnnotationRenderer
     return null;
   }
 
+  boolean rna = false;
+
   /**
    * Render the annotation rows associated with an alignment.
    * 
@@ -402,7 +406,7 @@ public class AnnotationRenderer
     AlignmentAnnotation consensusAnnot = av
             .getAlignmentConsensusAnnotation(), structConsensusAnnot = av
             .getAlignmentStrucConsensusAnnotation();
-    boolean renderHistogram = true, renderProfile = true, normaliseProfile = false;
+    boolean renderHistogram = true, renderProfile = true, normaliseProfile = false, isRNA = rna;
 
     BitSet graphGroupDrawn = new BitSet();
     int charOffset = 0; // offset for a label
@@ -416,6 +420,7 @@ public class AnnotationRenderer
     for (int i = 0; i < aa.length; i++)
     {
       AlignmentAnnotation row = aa[i];
+      isRNA = row.isRNA();
       {
         // check if this is a consensus annotation row and set the display
         // settings appropriately
@@ -570,11 +575,15 @@ public class AnnotationRenderer
                 }
               }
             }
-            if (!row.isValidStruc())
+            if (row.getInvalidStrucPos() > x)
             {
               g.setColor(Color.orange);
-              g.fillRect((int) row.getInvalidStrucPos() * charWidth, y,
-                      charWidth, charHeight);
+              g.fillRect(x * charWidth, y, charWidth, charHeight);
+            }
+            else if (row.getInvalidStrucPos() == x)
+            {
+              g.setColor(Color.orange.darker());
+              g.fillRect(x * charWidth, y, charWidth, charHeight);
             }
             if (validCharWidth
                     && validRes
@@ -613,9 +622,13 @@ public class AnnotationRenderer
               charOffset = (int) ((charWidth - fmWidth) / 2f);
 
               if (row_annotations[column].colour == null)
+              {
                 g.setColor(Color.black);
+              }
               else
+              {
                 g.setColor(row_annotations[column].colour);
+              }
 
               if (column == 0 || row.graph > 0)
               {
@@ -696,23 +709,31 @@ public class AnnotationRenderer
                 // System.out.println("\t type :"+lastSS+"\t x :"+x+"\t nbre annot :"+nb_annot);
                 switch (lastSS)
                 {
-
-                case '$':
-                  drawHelixAnnot(g, row_annotations, lastSSX, x, y,
-                          iconOffset, startRes, column, validRes, validEnd);
-                  break;
-
-                case 0xCE:
-                  drawSheetAnnot(g, row_annotations, lastSSX, x, y,
-                          iconOffset, startRes, column, validRes, validEnd);
-                  break;
-
                 case '(': // Stem case for RNA secondary structure
                 case ')': // and opposite direction
                   drawStemAnnot(g, row_annotations, lastSSX, x, y,
                           iconOffset, startRes, column, validRes, validEnd);
                   temp = x;
                   break;
+
+                case 'H':
+                  if (!isRNA)
+                  {
+                    drawHelixAnnot(g, row_annotations, lastSSX, x, y,
+                            iconOffset, startRes, column, validRes,
+                            validEnd);
+                    break;
+                  }
+
+                case 'E':
+                  if (!isRNA)
+                  {
+                    drawSheetAnnot(g, row_annotations, lastSSX, x, y,
+                            iconOffset, startRes, column, validRes,
+                            validEnd);
+                    break;
+                  }
+
                 case '{':
                 case '}':
                 case '[':
@@ -727,13 +748,11 @@ public class AnnotationRenderer
                 case 'c':
                 case 'D':
                 case 'd':
-                case 'E':
                 case 'e':
                 case 'F':
                 case 'f':
                 case 'G':
                 case 'g':
-                case 'H':
                 case 'h':
                 case 'I':
                 case 'i':
@@ -828,17 +847,25 @@ public class AnnotationRenderer
         {
           switch (lastSS)
           {
-          case '$':
-            drawHelixAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
-                    startRes, column, validRes, validEnd);
-            break;
 
-          case '�':
-            drawSheetAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
-                    startRes, column, validRes, validEnd);
-            break;
-          case 's':
-          case 'S': // Stem case for RNA secondary structure
+          case 'H':
+            if (!isRNA)
+            {
+              drawHelixAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
+                      startRes, column, validRes, validEnd);
+              break;
+            }
+
+          case 'E':
+            if (!isRNA)
+            {
+              drawSheetAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
+                      startRes, column, validRes, validEnd);
+              break;
+            }
+
+          case '(':
+          case ')': // Stem case for RNA secondary structure
 
             drawStemAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
                     startRes, column, validRes, validEnd);
@@ -858,13 +885,11 @@ public class AnnotationRenderer
           case 'c':
           case 'D':
           case 'd':
-          case 'E':
           case 'e':
           case 'F':
           case 'f':
           case 'G':
           case 'g':
-          case 'H':
           case 'h':
           case 'I':
           case 'i':
@@ -1008,13 +1033,13 @@ public class AnnotationRenderer
     return !usedFaded;
   }
 
-  private final Color GLYPHLINE_COLOR = Color.gray;
+  public static final Color GLYPHLINE_COLOR = Color.gray;
 
-  private final Color SHEET_COLOUR = Color.green;
+  public static final Color SHEET_COLOUR = Color.green;
 
-  private final Color HELIX_COLOUR = Color.red;
+  public static final Color HELIX_COLOUR = Color.red;
 
-  private final Color STEM_COLOUR = Color.blue;
+  public static final Color STEM_COLOUR = Color.blue;
 
   private Color sdNOTCANONICAL_COLOUR;
 
@@ -1174,9 +1199,13 @@ public class AnnotationRenderer
       }
 
       if (aa_annotations[column].colour == null)
+      {
         g.setColor(Color.black);
+      }
       else
+      {
         g.setColor(aa_annotations[column].colour);
+      }
 
       y1 = y
               - (int) (((aa_annotations[column - 1].value - min) / range) * graphHeight);
@@ -1248,9 +1277,13 @@ public class AnnotationRenderer
         continue;
       }
       if (aa_annotations[column].colour == null)
+      {
         g.setColor(Color.black);
+      }
       else
+      {
         g.setColor(aa_annotations[column].colour);
+      }
 
       y1 = y
               - (int) (((aa_annotations[column].value - min) / (range)) * _aa.graphHeight);
@@ -1368,9 +1401,13 @@ public class AnnotationRenderer
       if (aa_annotations[j] != null)
       {
         if (aa_annotations[j].colour == null)
+        {
           g.setColor(Color.black);
+        }
         else
+        {
           g.setColor(aa_annotations[j].colour);
+        }
 
         height = (int) ((aa_annotations[j].value / _aa.graphMax) * y);
         if (height > y)