JAL-2664 Updates following review
[jalview.git] / src / jalview / renderer / OverviewRenderer.java
index 709816c..1fb2d89 100644 (file)
@@ -84,9 +84,6 @@ public class OverviewRenderer
     int seqIndex = 0;
     int pixelRow = 0;
 
-    BufferedImage hiddenImage = buildHiddenImage(rows, cols,
-            miniMe.getWidth(), miniMe.getHeight());
-
     for (int alignmentRow : rows)
     {
       if (redraw)
@@ -141,11 +138,20 @@ public class OverviewRenderer
       seqIndex++;
     }
 
-    return applyMask(hiddenImage, miniMe);
+    overlayHiddenRegions(rows, cols);
+    return miniMe;
   }
 
-  /*
+  /**
    * Find the colour of a sequence at a specified column position
+   * 
+   * @param seq
+   *          sequence to get colour for
+   * @param lastcol
+   *          column position to get colour for
+   * @param fcfinder
+   *          FeatureColourFinder to use
+   * @return colour of sequence at this position, as RGB
    */
   private int getColumnColourFromSequence(jalview.datamodel.SequenceI seq,
           int lastcol, FeatureColourFinder fcfinder)
@@ -160,23 +166,42 @@ public class OverviewRenderer
     return color.getRGB();
   }
 
-  /*
-   * Overlay a buffered image (mask) onto another image (image) where mask 
-   * has some transparency so image shows through from below
+  /**
+   * Overlay the hidden regions on the overview image
+   * 
+   * @param rows
+   *          collection of rows the overview is built over
+   * @param cols
+   *          collection of columns the overview is built over
    */
-  private BufferedImage applyMask(BufferedImage mask, BufferedImage image)
+  private void overlayHiddenRegions(AlignmentRowsCollectionI rows,
+          AlignmentColsCollectionI cols)
   {
-    Graphics2D g = (Graphics2D) image.getGraphics();
-    g.setComposite(
-            AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
-                    TRANSPARENCY));
-    g.drawImage(mask, 0, 0, image.getWidth(), image.getHeight(), null);
-    return image;
+    if (cols.hasHidden() || rows.hasHidden())
+    {
+      BufferedImage mask = buildHiddenImage(rows, cols, miniMe.getWidth(),
+              miniMe.getHeight());
+
+      Graphics2D g = (Graphics2D) miniMe.getGraphics();
+      g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
+              TRANSPARENCY));
+      g.drawImage(mask, 0, 0, miniMe.getWidth(), miniMe.getHeight(), null);
+    }
   }
 
-  /*
-   * Build a masking image of hidden columns and rows to be applied on top
-   * of the main overview image.
+  /**
+   * Build a masking image of hidden columns and rows to be applied on top of
+   * the main overview image.
+   * 
+   * @param rows
+   *          collection of rows the overview is built over
+   * @param cols
+   *          collection of columns the overview is built over
+   * @param width
+   *          width of overview in pixels
+   * @param height
+   *          height of overview in pixels
+   * @return BufferedImage containing mask of hidden regions
    */
   private BufferedImage buildHiddenImage(AlignmentRowsCollectionI rows,
           AlignmentColsCollectionI cols, int width, int height)
@@ -316,6 +341,13 @@ public class OverviewRenderer
     }
   }
 
+  /**
+   * Allows redraw flag to be set
+   * 
+   * @param b
+   *          value to set redraw to: true = redraw is occurring, false = no
+   *          redraw
+   */
   public void setRedraw(boolean b)
   {
     synchronized (this)