package jalview.gui; import jalview.datamodel.*; import jalview.schemes.*; import java.awt.*; import java.util.*; public class SequenceRenderer implements RendererI { AlignViewport av; FontMetrics fm; boolean renderGaps = true; SequenceGroup currentSequenceGroup = null; Color color; public SequenceRenderer(AlignViewport av) { this.av = av; } public void renderGaps(boolean b) { renderGaps = b; } public Color getResidueBoxColour(ColourSchemeI cs, SequenceI seq, int i) { Color c = Color.white; try{ if (cs != null) c = cs.findColour(seq.getSequence(i, i + 1), i, av.getConsensus(false)); }catch(Exception ex){} return c; } 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; drawBoxes(g, seq, start, end, x1, y1, (int) width, height, pid); fm = g.getFontMetrics(); drawText(g,seq,start,end,x1,y1,(int)width,height); } public void drawBoxes(Graphics g, SequenceI seq,int start, int end, int x1, int y1, int width, int height,Vector freq) { int i = start; int length = seq.getLength(); Color currentColor = Color.WHITE; int curStart = x1; int curWidth = width; while (i <= end && i < length) { color = color.white; if(inCurrentSequenceGroup(i)) { if( currentSequenceGroup.getDisplayBoxes()) color = getResidueBoxColour(currentSequenceGroup.cs, seq, i); } else if(av.getShowBoxes()) color = getResidueBoxColour(av.getGlobalColourScheme(), seq, i); if (color != currentColor || color != null) { g.fillRect(x1+width*(curStart-start),y1,curWidth,height); currentColor = color; g.setColor(color); curStart = i; curWidth = width; } else curWidth += width; i++; } g.fillRect(x1+width*(curStart-start),y1,curWidth,height); } public void drawText(Graphics g, SequenceI seq,int start, int end, int x1, int y1, int width, int height) { int pady = height/5; int charOffset=0; g.setColor(Color.black); char s; // Need to find the sequence position here. for (int i = start; i <= end; i++) { if(i=res)?true:false; } public void drawHighlightedText(Graphics g, SequenceI seq,int start, int end, int x1, int y1, int width, int height) { int pady = height/5; int charOffset=0; g.setColor(Color.BLACK); g.fillRect(x1,y1,width*(end-start+1),height); g.setColor(Color.white); char s='~'; // Need to find the sequence position here. for (int i = start; i <= end; i++) { if(i