From: hansonr Date: Tue, 1 Oct 2019 21:36:04 +0000 (+0200) Subject: JAL-3444 SwingJS-site.zip fix and renderer.seqfeatures fixes X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=45b405507491a3d15d2b6b2c4f115a840945b28f;p=jalview.git JAL-3444 SwingJS-site.zip fix and renderer.seqfeatures fixes - BufferedImage implements Image.flush() to clear pixel cache; - JSGraphics2D check for opacity 1 before clearing HTML5 canvas AlphaComposite - FeatureColourFinder applies ifJS() { g.setColor(Color.white); g.fillRect(0, 0, 1, 1); } so as to clear the HTML5 canvas image before applying any other color. Also applies if (Platform.isJS()) { offscreenImage.flush(); } just before offscreenImage.getRGB(0,0) to force the image to recreate its cached pixel from the HTML5 canvas, which is drawn to directly. --- diff --git a/src/jalview/renderer/seqfeatures/FeatureColourFinder.java b/src/jalview/renderer/seqfeatures/FeatureColourFinder.java index 703f220..712c9f4 100644 --- a/src/jalview/renderer/seqfeatures/FeatureColourFinder.java +++ b/src/jalview/renderer/seqfeatures/FeatureColourFinder.java @@ -23,10 +23,12 @@ 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; import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.image.BufferedImage; /** @@ -117,6 +119,53 @@ public class FeatureColourFinder return c; } + public int findFeatureColourInt(int defaultColour, SequenceI seq, + int column) + { + // if (noFeaturesDisplayed()) + // { + // return defaultColour; + // } + + Graphics2D g = null; + + /* + * if transparency applies, provide a notional 1x1 graphics context + * that has been primed with the default colour + */ + if (featureRenderer.getTransparency() != 1f) + { + g = (Graphics2D) goff; + if (Platform.isJS()) + { + // Clear the HTML5 canvas color. + // otherwise we get a smearing. + // For whatever reason, this is necessary BH 2019.10.01. + g.setColor(Color.white); + g.fillRect(0, 0, 1, 1); + } + if (defaultColour != 0) + { + offscreenImage.setRGB(0, 0, defaultColour); + } + } + Color c = featureRenderer.findFeatureColour(seq, column + 1, g); + if (c == null) + { + return defaultColour; + } + if (g == null) + { + return c.getRGB(); + } + if (Platform.isJS()) + { + // BH 2019.10.01 because for JavaScript the pixel itself + // is a resource that needs to be recreated in getRGB(0,0) + offscreenImage.flush(); + } + return offscreenImage.getRGB(0, 0); + } /** * Answers true if feature display is turned off, or there are no features * configured to be visible diff --git a/swingjs/SwingJS-site.zip b/swingjs/SwingJS-site.zip index 72900a8..f0c74ee 100644 Binary files a/swingjs/SwingJS-site.zip and b/swingjs/SwingJS-site.zip differ diff --git a/swingjs/timestamp b/swingjs/timestamp index 9b20eae..cb055f8 100644 --- a/swingjs/timestamp +++ b/swingjs/timestamp @@ -1 +1 @@ -20191001111303 +20191001230605 diff --git a/swingjs/ver/3.2.4/SwingJS-site.zip b/swingjs/ver/3.2.4/SwingJS-site.zip index 72900a8..f0c74ee 100644 Binary files a/swingjs/ver/3.2.4/SwingJS-site.zip and b/swingjs/ver/3.2.4/SwingJS-site.zip differ diff --git a/swingjs/ver/3.2.4/timestamp b/swingjs/ver/3.2.4/timestamp index 9b20eae..cb055f8 100644 --- a/swingjs/ver/3.2.4/timestamp +++ b/swingjs/ver/3.2.4/timestamp @@ -1 +1 @@ -20191001111303 +20191001230605