From 8359bd8f5bae0bfc1a63ba114b7a4d67fbb62efe Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 10 Nov 2005 11:04:37 +0000 Subject: [PATCH] Return accurate RGB for transparent residues --- src/jalview/gui/FeatureRenderer.java | 45 +++++++++++++++++++++++++++------ src/jalview/gui/SequenceRenderer.java | 18 +++++++++++++ 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java index 829bafb..fcd952b 100755 --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@ -24,6 +24,8 @@ import java.awt.*; import java.util.*; +import java.awt.image.*; + /** * DOCUMENT ME! @@ -41,6 +43,7 @@ public class FeatureRenderer float transparency = 1.0f; FontMetrics fm; int charOffset; + boolean drawText = true; // The following vector holds the features which are // to be added, in the correct order or rendering @@ -58,6 +61,29 @@ public class FeatureRenderer } /** + * This is used by the Molecule Viewer to get the accurate colour + * of the rendered sequence + */ + BufferedImage bi; + public Color findFeatureColour(Color initialCol, SequenceI seq, int i) + { + if(!av.showSequenceFeatures) + return initialCol; + + if(bi==null) + bi = new BufferedImage(1,1,BufferedImage.TYPE_INT_RGB); + + drawText = false; + bi.getGraphics().setColor(initialCol); + bi.getGraphics().fillRect(0, 0, 1, 1); + drawSequence(bi.getGraphics(), seq, i, i, 0, 0, 1, 1); + drawText = true; + + return new Color(bi.getRGB(0, 0)); + } + + + /** * DOCUMENT ME! * * @param g DOCUMENT ME! @@ -74,7 +100,8 @@ public class FeatureRenderer int start, int end, int x1, int y1, int width, int height) { - if (seq.getDatasetSequence().getSequenceFeatures() == null) + if (seq.getDatasetSequence().getSequenceFeatures() == null + || seq.getDatasetSequence().getSequenceFeatures().size()==0) return; fm = g.getFontMetrics(); @@ -89,7 +116,7 @@ public class FeatureRenderer String type; SequenceFeature sf; - if (featuresDisplayed == null || featuresDisplayed.size()==0) + if (featuresDisplayed == null) findAllFeatures(); Enumeration e = featuresDisplayed.elements(), e2; @@ -171,12 +198,14 @@ public class FeatureRenderer g.fillRect( (i - start) * width, y1, width, height); - g.setColor(Color.white); - - charOffset = (width - fm.charWidth(s)) / 2; - g.drawString(String.valueOf(s), - charOffset + x1 + (width * (i - start)), - (y1 + height) - height/5);//pady = height / 5; + if(drawText) + { + g.setColor(Color.white); + charOffset = (width - fm.charWidth(s)) / 2; + g.drawString(String.valueOf(s), + charOffset + x1 + (width * (i - start)), + (y1 + height) - height / 5); //pady = height / 5; + } } } } diff --git a/src/jalview/gui/SequenceRenderer.java b/src/jalview/gui/SequenceRenderer.java index b961b2c..c431e7c 100755 --- a/src/jalview/gui/SequenceRenderer.java +++ b/src/jalview/gui/SequenceRenderer.java @@ -23,6 +23,7 @@ import jalview.datamodel.*; import jalview.schemes.*; import java.awt.*; +import java.awt.image.BufferedImage; /** @@ -77,6 +78,23 @@ public class SequenceRenderer return resBoxColour; } + BufferedImage bi; + public Color findSequenceColour(Color initialCol, SequenceI seq, int i) + { + if (bi == null) + bi = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); + + bi.getGraphics().setColor(initialCol); + bi.getGraphics().fillRect(0, 0, 1, 1); + allGroups = null; + graphics = bi.getGraphics(); + + drawBoxes(seq, i,i, 0, 0, 1,1); + + return new Color(bi.getRGB(0, 0)); + } + + /** * DOCUMENT ME! * -- 1.7.10.2