X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Frenderer%2Fseqfeatures%2FFeatureColourFinder.java;h=57366b9abe13424f23f4dd838c923981291ac5f9;hb=eb190489441b102c7dce1ee0121df7efd3e74b1a;hp=ba63834366cfa39255085207382126a677769af0;hpb=136c0793b90b72b928c4d77dc109dd5c644e00d3;p=jalview.git diff --git a/src/jalview/renderer/seqfeatures/FeatureColourFinder.java b/src/jalview/renderer/seqfeatures/FeatureColourFinder.java index ba63834..57366b9 100644 --- a/src/jalview/renderer/seqfeatures/FeatureColourFinder.java +++ b/src/jalview/renderer/seqfeatures/FeatureColourFinder.java @@ -1,8 +1,29 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * 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 . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ 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; @@ -28,6 +49,8 @@ public class FeatureColourFinder */ private BufferedImage offscreenImage; + private Graphics goff; + /** * Constructor * @@ -37,6 +60,7 @@ public class FeatureColourFinder { featureRenderer = fr; offscreenImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); + goff = offscreenImage.getGraphics(); } /** @@ -74,11 +98,17 @@ public class FeatureColourFinder */ if (featureRenderer.getTransparency() != 1f) { - g = offscreenImage.getGraphics(); - if (defaultColour != null) + g = goff; + 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); @@ -89,8 +119,17 @@ public class FeatureColourFinder if (g != null) { + if (Platform.isJS()) + { + /* + * 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)); } + return c; } @@ -100,7 +139,7 @@ public class FeatureColourFinder * * @return */ - boolean noFeaturesDisplayed() + public boolean noFeaturesDisplayed() { if (featureRenderer == null || !featureRenderer.getViewport().isShowSequenceFeatures())