package jalview.gui; import jalview.datamodel.*; import jalview.schemes.*; import java.awt.*; import java.util.*; public class FeatureRenderer implements RendererI { public Color getResidueBoxColour(ColourSchemeI cs, SequenceI seq, int i) { Color c = cs.findColour(seq,seq.getSequence(i,i+1),i,null); return c; } public void drawSequence(Graphics g,ColourSchemeI cs,SequenceI seq,int start, int end, int x1, int y1, double width, int height,boolean showScores, boolean displayBoxes, boolean displayText,Vector pid, int seqnum,AlignViewport av) { int i = start; int length = seq.getLength(); Color currentColor = Color.black; int prev = -1; int fstart = 0; char prevc = '-'; g.setColor(Color.magenta); while (i <= end && i < length) { char c = seq.getCharAt(i); if (c != '-') { if (prevc != c) { if (prevc == 'F') { g.setColor(Color.green); } else if (prevc == 'R') { g.setColor(Color.cyan); } else if (prevc == 'M') { g.setColor(Color.magenta); } else if (prevc == 'P') { g.setColor(Color.yellow); } g.fillRect(x1+(int)(width*(i-fstart)),y1+height/4,(int)((prev-fstart+1)*width),height/2); prevc = c; fstart = i; } } else if (prevc != '-') { if (prevc == 'F') { g.setColor(Color.green); } else if (prevc == 'R') { g.setColor(Color.cyan); } else if (prevc == 'M') { g.setColor(Color.magenta); } else if (prevc == 'P') { g.setColor(Color.yellow); } g.fillRect(x1+(int)(width*(fstart-start)),y1+height/4,(int)((i-fstart+1)*width),height/2); prevc = c; } else { fstart = -1; } i++; } if (fstart != -1) { if (prevc == 'F') { g.setColor(Color.green); } else if (prevc == 'R') { g.setColor(Color.cyan); } else if (prevc == 'M') { g.setColor(Color.magenta); } else if (prevc == 'P') { g.setColor(Color.yellow); } //g.fillRect(x1+(int)(width*(fstart-start)),y1+height/4,(int)((end-fstart+1)*width),height/2); } } }