JAL-2438 unit test, fixes, Javadoc updates
[jalview.git] / src / jalview / renderer / seqfeatures / FeatureColourFinder.java
index 5055ed5..9a1ecf9 100644 (file)
@@ -41,14 +41,16 @@ public class FeatureColourFinder
   /**
    * Answers the feature colour to show for the given sequence and column
    * position. This delegates to the FeatureRenderer to find the colour, which
-   * will depend on feature location, visibility, ordering, and whether or not
-   * transparency is applied. For feature rendering with transparency, this
-   * class provides a dummy 'offscreen' graphics context where multiple feature
-   * colours can be overlaid and the combined colour read back.
+   * will depend on feature location, visibility, ordering, colour scheme, and
+   * whether or not transparency is applied. For feature rendering with
+   * transparency, this class provides a dummy 'offscreen' graphics context
+   * where multiple feature colours can be overlaid and the combined colour read
+   * back.
    * 
    * @param defaultColour
    * @param seq
    * @param column
+   *          alignment column position (base zero)
    * @return
    */
   public Color findFeatureColour(Color defaultColour, SequenceI seq,
@@ -65,11 +67,20 @@ public class FeatureColourFinder
       return defaultColour; // nothing to see here folks
     }
 
-    Graphics g = featureRenderer.getTransparency() == 1f ? null
-            : offscreenImage.getGraphics();
+    Graphics g = null;
+
+    /*
+     * if transparency applies, get colours drawn to a 1x1 pixel
+     * graphics context that has been primed with the default colour
+     */
+    if (featureRenderer.getTransparency() != 1f)
+    {
+      g = offscreenImage.getGraphics();
+      offscreenImage.setRGB(0, 0, defaultColour.getRGB());
+    }
+
+    Color c = featureRenderer.findFeatureColour(seq, column, g);
 
-    Color c = featureRenderer.findFeatureColour(defaultColour, seq, column,
-            g);
     if (c != null && g != null)
     {
       c = new Color(offscreenImage.getRGB(0, 0));