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{ c = cs.findColour(seq, seq.getSequence(i, i + 1), i, null); }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; // int threshold = 80; 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); // Hashtable hash = (Hashtable)freq.elementAt(i-start); // String s = (String)hash.get("maxResidue"); // int count = ((Integer)hash.get("maxCount")).intValue(); // int max = ((Integer)hash.get("size")).intValue(); // int nongap = ((Integer)hash.get("nongap")).intValue(); // float frac = (float)(count*1.0/(1.0*nongap)); //System.out.println("Frac/count/nongap " + frac + " " + count + " " + nongap); /* if (!seq.getSequence().substring(i,i+1).equals(s) || s.equals("-") || s.equals(".") || s.equals(" ")) { c = Color.white; } else { if (frac > 0.9) { c = Color.red; } else if (frac > 0.8) { c = Color.orange; } else if (frac > 0.7) { c = Color.pink; } else if (frac > 0.5) { c = Color.yellow; } else if (frac> 0.3) { c = Color.lightGray; } }*/ 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