package jalview.gui; import jalview.datamodel.*; import jalview.schemes.*; import jalview.analysis.*; import jalview.util.*; import java.awt.*; import java.util.*; public class BlockRenderer implements RendererI { protected Color color = Color.black; protected Color maroon = new Color(200,0,50); protected Color purple = new Color(255,100,255); 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.white; Vector kmers = av.getKmers(); g.setColor(Color.black); int prev = -1; int seqno = -1; for (int ii = 0; ii < av.getAlignment().getHeight(); ii++) { if (av.getSelection().contains(av.getAlignment().getSequenceAt(ii))) { seqno = ii; } } int blstart = start - 20; int blend = end + 20; if (blstart < 0) { blstart = 0; } if (blend > av.getAlignment().getWidth()) { blend = av.getAlignment().getWidth(); } Hashtable blocks = AAFrequency.findBlocks(av.getAlignment().getSequences(), blstart, blend, av.getSelection().asVector()); Hashtable hkmer = AlignmentUtil.findKmers(seq,blstart,blend,kmers); boolean inblock = false; int bstart = -1; int blen = -1; int klen = -1; int block_end = -1; Color bc; // System.out.println("Rendering " + start + " " + end); while (i <= blend && i < length) { boolean foundblock = false; if (blocks.get(new Integer(i-blstart)) != null) { blen = ((Integer)blocks.get(new Integer(i-blstart))).intValue(); foundblock = true; block_end = i + blen-1; g.setColor(getColor(blen)); g.fillRect(x1+(int)(width*(i-start)),y1, (int)width+1, height/2); } boolean foundKmer = false; if (hkmer.get(new Integer(i-blstart)) != null) { klen = ((Integer)hkmer.get(new Integer(i-blstart))).intValue(); // System.out.println("Got kmer " + i + " " + start + " kength " + klen); foundKmer = true; g.setColor(Color.lightGray); if ((int)width> 5) { g.fillRect(x1+(int)(width*(i-start)),y1+height/2, (int)(width*klen)+1, height/2); } else { g.fillRect(x1+(int)(width*(i-start)),y1+height/2, (int)(width*klen)+1, height/2); } } if (width > 5) { g.setColor(Color.black); g.drawString(seq.getSequence().substring(i,i+1),x1+(int)(width*(i-start)),y1+height); } i++; }*/ } public Color getColor(int blen) { Color bc; if (blen > 20 ) { bc = Color.yellow; }else if (blen > 10) { bc = Color.red; } else if (blen > 5) { bc = Color.blue; } else if (blen > 2) { bc = purple; } else if (blen == 2) { bc = Color.orange; } else { bc = Color.lightGray; } return bc; } }