Merge branch 'develop' into menard
[jalview.git] / src / jalview / renderer / AnnotationRenderer.java
index a46aa92..bfe2156 100644 (file)
@@ -1,4 +1,20 @@
-
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
+ * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ */
 package jalview.renderer;
 
 import jalview.analysis.AAFrequency;
@@ -276,6 +292,7 @@ public class AnnotationRenderer
 
   /**
    * Render the annotation rows associated with an alignment.
+   * 
    * @param annotPanel
    *          container frame
    * @param av
@@ -288,12 +305,14 @@ public class AnnotationRenderer
    *          first column that will be drawn
    * @param endRes
    *          last column that will be drawn
-   * @return true if the fadedImage was used for any alignment annotation rows currently being calculated
+   * @return true if the fadedImage was used for any alignment annotation rows
+   *         currently being calculated
    */
-  public boolean drawComponent(AwtRenderPanelI annotPanel, AlignViewportI av,
-          Graphics g, int activeRow, int startRes, int endRes)
+  public boolean drawComponent(AwtRenderPanelI annotPanel,
+          AlignViewportI av, Graphics g, int activeRow, int startRes,
+          int endRes)
   {
-    boolean usedFaded=false;
+    boolean usedFaded = false;
     // NOTES:
     // AnnotationPanel needs to implement: ImageObserver, access to
     // AlignViewport
@@ -321,7 +340,7 @@ public class AnnotationRenderer
     for (int i = 0; i < aa.length; i++)
     {
       AlignmentAnnotation row = aa[i];
-      Annotation[] row_annotations=row.annotations;
+      Annotation[] row_annotations = row.annotations;
       if (!row.visible)
       {
         continue;
@@ -360,7 +379,7 @@ public class AnnotationRenderer
       if (row.autoCalculated && av.isCalculationInProgress(row))
       {
         y += charHeight;
-        usedFaded=true;
+        usedFaded = true;
         g.drawImage(fadedImage, 0, y - row.height, imgWidth, y, 0, y
                 - row.height, imgWidth, y, annotationPanel);
         g.setColor(Color.black);
@@ -372,22 +391,22 @@ public class AnnotationRenderer
       /*
        * else if (annotationPanel.av.updatingConservation &&
        * aa[i].label.equals("Conservation")) {
-       *
+       * 
        * y += charHeight; g.drawImage(annotationPanel.fadedImage, 0, y -
        * row.height, annotationPanel.imgWidth, y, 0, y - row.height,
        * annotationPanel.imgWidth, y, annotationPanel);
-       *
+       * 
        * g.setColor(Color.black); //
        * g.drawString("Calculating Conservation.....",20, y-row.height/2);
-       *
+       * 
        * continue; } else if (annotationPanel.av.updatingConservation &&
        * aa[i].label.equals("Quality")) {
-       *
+       * 
        * y += charHeight; g.drawImage(annotationPanel.fadedImage, 0, y -
        * row.height, annotationPanel.imgWidth, y, 0, y - row.height,
        * annotationPanel.imgWidth, y, annotationPanel); g.setColor(Color.black);
        * // / g.drawString("Calculating Quality....",20, y-row.height/2);
-       *
+       * 
        * continue; }
        */
       // first pass sets up state for drawing continuation from left-hand column
@@ -789,19 +808,23 @@ public class AnnotationRenderer
               switch (lastSS)
               {
               case 'H':
-                drawHelixAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
-                        column, validRes, validEnd);
+                drawHelixAnnot(g, row_annotations, lastSSX, x, y,
+                        iconOffset, startRes, column, validRes, validEnd);
                 break;
 
               case 'E':
-                drawSheetAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
-                        column, validRes, validEnd);
+                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);
+//              case 'S': // Stem case for RNA secondary structure
+//              case 's': // and opposite direction
+//                drawStemAnnot(g, row_annotations, lastSSX, x, y,
+//                        iconOffset, startRes, column, validRes, validEnd);
                 break;
               case '{':
               case '}':
@@ -917,18 +940,18 @@ public class AnnotationRenderer
         switch (lastSS)
         {
         case 'H':
-          drawHelixAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
-                  column, validRes, validEnd);
+          drawHelixAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
+                  startRes, column, validRes, validEnd);
           break;
 
         case 'E':
-          drawSheetAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
-                  column, validRes, validEnd);
+          drawSheetAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
+                  startRes, column, validRes, validEnd);
           break;
         case 's':
         case 'S': // Stem case for RNA secondary structure
-          drawStemAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
-                  column, validRes, validEnd);
+          drawStemAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
+                  startRes, column, validRes, validEnd);
           break;
         case '{':
         case '}':
@@ -992,8 +1015,8 @@ public class AnnotationRenderer
                     column, validRes, validEnd);
          break;
         default:
-          drawGlyphLine(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
-                  column, validRes, validEnd);
+          drawGlyphLine(g, row_annotations, lastSSX, x, y, iconOffset,
+                  startRes, column, validRes, validEnd);
           break;
         }
       }
@@ -1030,8 +1053,8 @@ public class AnnotationRenderer
             {
               if (aa[gg].graphGroup == row.graphGroup)
               {
-                drawLineGraph(g, aa[gg], aa[gg].annotations, startRes, endRes, y, groupmin,
-                        groupmax, row.graphHeight);
+                drawLineGraph(g, aa[gg], aa[gg].annotations, startRes,
+                        endRes, y, groupmin, groupmax, row.graphHeight);
               }
             }
 
@@ -1039,14 +1062,14 @@ public class AnnotationRenderer
           }
           else
           {
-            drawLineGraph(g, row, row_annotations, startRes, endRes, y, row.graphMin,
-                    row.graphMax, row.graphHeight);
+            drawLineGraph(g, row, row_annotations, startRes, endRes, y,
+                    row.graphMin, row.graphMax, row.graphHeight);
           }
         }
         else if (row.graph == AlignmentAnnotation.BAR_GRAPH)
         {
-          drawBarGraph(g, row, row_annotations, startRes, endRes, row.graphMin,
-                  row.graphMax, y);
+          drawBarGraph(g, row, row_annotations, startRes, endRes,
+                  row.graphMin, row.graphMax, y);
         }
       }
 
@@ -1073,22 +1096,21 @@ public class AnnotationRenderer
   
   private  Color sdNOTCANONICAL_COLOUR;
 
-  public void drawGlyphLine(Graphics g, Annotation[] row,
-          int lastSSX, int x, int y, int iconOffset, int startRes,
-          int column, boolean validRes, boolean validEnd)
+  public void drawGlyphLine(Graphics g, Annotation[] row, int lastSSX,
+          int x, int y, int iconOffset, int startRes, int column,
+          boolean validRes, boolean validEnd)
   {
     g.setColor(GLYPHLINE_COLOR);
     g.fillRect(lastSSX, y + 6 + iconOffset, (x * charWidth) - lastSSX, 2);
   }
 
-  public void drawSheetAnnot(Graphics g, Annotation[] row,
-
-          int lastSSX, int x, int y, int iconOffset, int startRes,
-          int column, boolean validRes, boolean validEnd)
+  public void drawSheetAnnot(Graphics g, Annotation[] row, int lastSSX,
+          int x, int y, int iconOffset, int startRes, int column,
+          boolean validRes, boolean validEnd)
   {
     g.setColor(SHEET_COLOUR);
 
-    if (!validEnd || !validRes || row==null || row[column] == null
+    if (!validEnd || !validRes || row == null || row[column] == null
             || row[column].secondaryStructure != 'E')
     {
       g.fillRect(lastSSX, y + 4 + iconOffset,
@@ -1107,9 +1129,9 @@ public class AnnotationRenderer
 
   }
 
-  public void drawHelixAnnot(Graphics g, Annotation[] row,
-          int lastSSX, int x, int y, int iconOffset, int startRes,
-          int column, boolean validRes, boolean validEnd)
+  public void drawHelixAnnot(Graphics g, Annotation[] row, int lastSSX,
+          int x, int y, int iconOffset, int startRes, int column,
+          boolean validRes, boolean validEnd)
   {
     g.setColor(HELIX_COLOUR);
 
@@ -1167,8 +1189,9 @@ public class AnnotationRenderer
     g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 8);
   }
 
-  public void drawLineGraph(Graphics g, AlignmentAnnotation _aa, Annotation[] aa_annotations, int sRes,
-          int eRes, int y, float min, float max, int graphHeight)
+  public void drawLineGraph(Graphics g, AlignmentAnnotation _aa,
+          Annotation[] aa_annotations, int sRes, int eRes, int y,
+          float min, float max, int graphHeight)
   {
     if (sRes > aa_annotations.length)
     {
@@ -1256,8 +1279,9 @@ public class AnnotationRenderer
     }
   }
 
-  public void drawBarGraph(Graphics g, AlignmentAnnotation _aa, Annotation[] aa_annotations, int sRes,
-          int eRes, float min, float max, int y)
+  public void drawBarGraph(Graphics g, AlignmentAnnotation _aa,
+          Annotation[] aa_annotations, int sRes, int eRes, float min,
+          float max, int y)
   {
     if (sRes > aa_annotations.length)
     {
@@ -1393,7 +1417,7 @@ public class AnnotationRenderer
               // g.drawRect(x*av.charWidth, (int)ht, av.charWidth,
               // (int)(scl));
               // g.setColor(profcolour.findColour(dc[0]).darker());
-              g.setColor(profcolour.findColour(dc[0], column,null));
+              g.setColor(profcolour.findColour(dc[0], column, null));
 
               hght = (ht + (scl - lm.getDescent() - lm.getBaselineOffsets()[lm
                       .getBaselineIndex()]));
@@ -1414,15 +1438,16 @@ public class AnnotationRenderer
               BasicStroke.JOIN_ROUND, 3f, new float[]
               { 5f, 3f }, 0f));
 
-      y2 = (int) (y - ((_aa.threshold.value - min) / range) * _aa.graphHeight);
+      y2 = (int) (y - ((_aa.threshold.value - min) / range)
+              * _aa.graphHeight);
       g.drawLine(0, y2, (eRes - sRes) * charWidth, y2);
       g2.setStroke(new BasicStroke());
     }
   }
 
   // used by overview window
-  public void drawGraph(Graphics g, AlignmentAnnotation _aa, Annotation[] aa_annotations, int width,
-          int y, int sRes, int eRes)
+  public void drawGraph(Graphics g, AlignmentAnnotation _aa,
+          Annotation[] aa_annotations, int width, int y, int sRes, int eRes)
   {
     eRes = Math.min(eRes, aa_annotations.length);
     g.setColor(Color.white);