From 8220e64aa2718d0f81f39a93df46c3f2265a9fa4 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 13 Jan 2005 18:08:41 +0000 Subject: [PATCH] Send array of groups to renderer --- src/jalview/gui/RendererI.java | 2 +- src/jalview/gui/SequenceRenderer.java | 38 +++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/jalview/gui/RendererI.java b/src/jalview/gui/RendererI.java index 33c4d76..cc72142 100755 --- a/src/jalview/gui/RendererI.java +++ b/src/jalview/gui/RendererI.java @@ -10,6 +10,6 @@ public interface RendererI { // public Color getResidueBoxColour(ColourSchemeI cs, SequenceI seq, int i); - public void drawSequence(Graphics g,SequenceI seq,SequenceGroup sg, int start, int end, int x1, int y1, int width, int height, Vector pid, int seqnum); + public void drawSequence(Graphics g,SequenceI seq,SequenceGroup [] sg, int start, int end, int x1, int y1, int width, int height, Vector pid, int seqnum); } diff --git a/src/jalview/gui/SequenceRenderer.java b/src/jalview/gui/SequenceRenderer.java index 6483e8b..69db54d 100755 --- a/src/jalview/gui/SequenceRenderer.java +++ b/src/jalview/gui/SequenceRenderer.java @@ -11,7 +11,8 @@ public class SequenceRenderer implements RendererI FontMetrics fm; boolean renderGaps = true; SequenceGroup currentSequenceGroup = null; - Color resBoxColour = Color.white; + SequenceGroup [] allGroups = null; + Color resBoxColour; Graphics graphics; public SequenceRenderer(AlignViewport av) @@ -33,16 +34,15 @@ public class SequenceRenderer implements RendererI void getBoxColour(ColourSchemeI cs, SequenceI seq, int i) { - if (cs != null) resBoxColour = cs.findColour(seq.getSequence(i, i + 1), i, av.getConsensus(false)); else resBoxColour = Color.white; } - public void drawSequence(Graphics g,SequenceI seq,SequenceGroup sg, int start, int end, int x1, int y1, int width, int height, Vector pid, int seqnum) + public void drawSequence(Graphics g,SequenceI seq,SequenceGroup [] sg, int start, int end, int x1, int y1, int width, int height, Vector pid, int seqnum) { - currentSequenceGroup = sg; + allGroups = sg; graphics = g; @@ -60,7 +60,7 @@ public class SequenceRenderer implements RendererI int curStart = x1; int curWidth = width; - Color tempColour = Color.red; + Color tempColour = null; while (i <= end && i < length) { if(inCurrentSequenceGroup(i)) @@ -69,7 +69,10 @@ public class SequenceRenderer implements RendererI getBoxColour(currentSequenceGroup.cs, seq, i); } else if(av.getShowBoxes()) - getBoxColour(av.getGlobalColourScheme(), seq, i); + getBoxColour(av.getGlobalColourScheme(), seq, i); + else + resBoxColour = Color.white; + if (resBoxColour != tempColour) { @@ -112,8 +115,11 @@ public class SequenceRenderer implements RendererI if(!currentSequenceGroup.getDisplayText()) continue; - if(currentSequenceGroup.getColourText()) - graphics.setColor(resBoxColour.darker()); + if (currentSequenceGroup.getColourText()) + { + getBoxColour(currentSequenceGroup.cs, seq, i); + graphics.setColor(resBoxColour.darker()); + } } else { @@ -121,7 +127,10 @@ public class SequenceRenderer implements RendererI continue; if(av.getColourText()) - graphics.setColor(resBoxColour.darker()); + { + getBoxColour(av.getGlobalColourScheme(), seq, i); + graphics.setColor(resBoxColour.darker()); + } } charOffset = (width - fm.charWidth(s))/2; @@ -133,10 +142,17 @@ public class SequenceRenderer implements RendererI boolean inCurrentSequenceGroup(int res) { - if(currentSequenceGroup==null) + if(allGroups ==null) return false; - return (currentSequenceGroup.getStartRes()<=res && currentSequenceGroup.getEndRes()>=res)?true:false; + for(int i=0; i=res) + { + currentSequenceGroup = allGroups[i]; + return true; + } + + return false; } public void drawHighlightedText(SequenceI seq,int start, int end, int x1, int y1, int width, int height) -- 1.7.10.2