+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ * 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;
*/
private BufferedImage offscreenImage;
+ private Graphics goff;
+
/**
* Constructor
*
{
featureRenderer = fr;
offscreenImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
+ goff = offscreenImage.getGraphics();
}
/**
*/
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);
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;
}
*
* @return
*/
- boolean noFeaturesDisplayed()
+ public boolean noFeaturesDisplayed()
{
if (featureRenderer == null
|| !featureRenderer.getViewport().isShowSequenceFeatures())