package jalview.gui; import jalview.datamodel.*; import jalview.schemes.*; import java.awt.*; import java.util.*; public class SequenceRenderer { AlignViewport av; FontMetrics fm; boolean renderGaps = true; SequenceGroup currentSequenceGroup = null; SequenceGroup [] allGroups = null; Color resBoxColour; Graphics graphics; public SequenceRenderer(AlignViewport av) { this.av = av; } public void renderGaps(boolean b) { renderGaps = b; } public Color getResidueBoxColour(ColourSchemeI cs, SequenceI seq, int i) { getBoxColour(cs, seq, i); return resBoxColour; } void getBoxColour(ColourSchemeI cs, SequenceI seq, int i) { if (cs != null) resBoxColour = cs.findColour(seq.getSequence(i, i + 1), i); 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) { allGroups = sg; graphics = g; drawBoxes(seq, start, end, x1, y1, (int) width, height); fm = g.getFontMetrics(); drawText(seq,start,end,x1,y1,(int)width,height); } public void drawBoxes(SequenceI seq,int start, int end, int x1, int y1, int width, int height) { int i = start; int length = seq.getLength(); int curStart = -1; int curWidth = width; Color tempColour = null; while (i <= end && i < length) { if(inCurrentSequenceGroup(i)) { if( currentSequenceGroup.getDisplayBoxes()) getBoxColour(currentSequenceGroup.cs, seq, i); } else if(av.getShowBoxes()) getBoxColour(av.getGlobalColourScheme(), seq, i); else resBoxColour = Color.white; if (resBoxColour != tempColour) { if(tempColour!=null) graphics.fillRect(x1+width*(curStart-start),y1,curWidth,height); graphics.setColor(resBoxColour); curStart = i; curWidth = width; tempColour = resBoxColour; } else curWidth += width; i++; } graphics.fillRect(x1+width*(curStart-start),y1,curWidth,height); } public void drawText(SequenceI seq,int start, int end, int x1, int y1, int width, int height) { int pady = height/5; int charOffset=0; char s; // Need to find the sequence position here. graphics.setColor(Color.black); String sequence = seq.getSequence(); for (int i = start; i <= end; i++) { if(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) { int pady = height/5; int charOffset=0; graphics.setColor(Color.BLACK); graphics.fillRect(x1,y1,width*(end-start+1),height); graphics.setColor(Color.white); char s='~'; // Need to find the sequence position here. for (int i = start; i <= end; i++) { if(i