JAL-3444 missed commit of removal of object creation test.
[jalview.git] / src / jalview / renderer / seqfeatures / FeatureColourFinder.java
index 8da880a..57366b9 100644 (file)
@@ -23,6 +23,7 @@ package jalview.renderer.seqfeatures;
 import jalview.api.FeatureRenderer;
 import jalview.api.FeaturesDisplayedI;
 import jalview.datamodel.SequenceI;
+import jalview.util.Platform;
 import jalview.viewmodel.seqfeatures.FeatureRendererModel;
 
 import java.awt.Color;
@@ -98,10 +99,16 @@ public class FeatureColourFinder
     if (featureRenderer.getTransparency() != 1f)
     {
       g = goff;
-      if (defaultColour != null)
+      Color c = (defaultColour == null ? Color.white : defaultColour);
+      if (Platform.isJS())
       {
-        offscreenImage.setRGB(0, 0, defaultColour.getRGB());
+        // Clear the HTML5 canvas color.
+        // otherwise we get a smearing.
+        // For whatever reason, this is necessary BH 2019.10.01.
+        g.setColor(c);
+        g.fillRect(0, 0, 1, 1);
       }
+      offscreenImage.setRGB(0, 0, c.getRGB());
     }
 
     Color c = featureRenderer.findFeatureColour(seq, column + 1, g);
@@ -112,46 +119,20 @@ public class FeatureColourFinder
 
     if (g != null)
     {
-      c = new Color(offscreenImage.getRGB(0, 0));
-    }
-    return c;
-  }
-
-  public int findFeatureColourInt(int defaultColour, SequenceI seq,
-          int column)
-  {
-    // if (noFeaturesDisplayed())
-    // {
-    // return defaultColour;
-    // }
-
-    Graphics g = null;
-
-    /*
-     * if transparency applies, provide a notional 1x1 graphics context 
-     * that has been primed with the default colour
-     */
-    if (featureRenderer.getTransparency() != 1f)
-    {
-      g = goff;
-      if (defaultColour != 0)
+      if (Platform.isJS())
       {
-        offscreenImage.setRGB(0, 0, defaultColour);
+        /*
+         * for JavaScript the pixel itself
+         * is a resource that needs to be recreated in getRGB(0,0)
+         */
+        offscreenImage.flush();
       }
+      c = new Color(offscreenImage.getRGB(0, 0));
     }
 
-    Color c = featureRenderer.findFeatureColour(seq, column + 1, g);
-    if (c == null)
-    {
-      return defaultColour;
-    }
-
-    if (g != null)
-    {
-      return offscreenImage.getRGB(0, 0);
-    }
-    return c.getRGB();
+    return c;
   }
+
   /**
    * Answers true if feature display is turned off, or there are no features
    * configured to be visible