X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSequenceRenderer.java;h=5022050ab72a3f83bb6dd98f439127ee63da9b3f;hb=8af8289df86798d5e283e1d0aa275b8f98e563dc;hp=7df91496894483b6ceec6c5f50602345162a6a45;hpb=1ecf6419aba86993b3c223bf5ec0fa79427baf85;p=jalview.git diff --git a/src/jalview/gui/SequenceRenderer.java b/src/jalview/gui/SequenceRenderer.java index 7df9149..5022050 100755 --- a/src/jalview/gui/SequenceRenderer.java +++ b/src/jalview/gui/SequenceRenderer.java @@ -2,41 +2,51 @@ package jalview.gui; import jalview.datamodel.*; import jalview.schemes.*; - import java.awt.*; import java.util.*; public class SequenceRenderer implements RendererI { - FontMetrics fm; AlignViewport av; + FontMetrics fm; + boolean renderGaps = true; + SequenceGroup currentSequenceGroup = null; + Color color; + + public SequenceRenderer(AlignViewport av) + { + this.av = av; + } + - public Color getResidueBoxColour(ColourSchemeI cs, SequenceI seq, int i) { - Color c = Color.WHITE; + public void renderGaps(boolean b) + { + renderGaps = b; + } - try{ - if (cs != null) - c = cs.findColour(seq, seq.getSequence(i, i + 1), i, null); - }catch(Exception ex) - { } + 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,ColourSchemeI cs,SequenceI seq,int start, int end, int x1, int y1, double width, int height,boolean showScores, boolean displayBoxes, boolean displayText,Vector freq, int seqnum,AlignViewport av) { + 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); - this.av = av; + fm = g.getFontMetrics(); + drawText(g,seq,start,end,x1,y1,(int)width,height); - if (displayBoxes == true) { - drawBoxes(g,cs,seq,start,end,x1,y1,(int)width, height,freq); - } - if (displayText == true) { - fm = g.getFontMetrics(); - drawText(g,cs,seq,start,end,x1,y1,(int)width,height); - } } - public void drawBoxes(Graphics g,ColourSchemeI cs, SequenceI seq,int start, int end, int x1, int y1, int width, int height,Vector freq) { + 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(); @@ -45,45 +55,25 @@ public class SequenceRenderer implements RendererI int curStart = x1; int curWidth = width; - // int threshold = 80; + while (i <= end && i < length) + { + color = color.white; - while (i <= end && i < length) { - Color c = getResidueBoxColour(cs,seq,i); + 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 (c != currentColor || c != null) + if (color != currentColor || color != null) { g.fillRect(x1+width*(curStart-start),y1,curWidth,height); - currentColor = c; - g.setColor(c); + currentColor = color; + g.setColor(color); curStart = i; curWidth = width; @@ -96,35 +86,77 @@ public class SequenceRenderer implements RendererI g.fillRect(x1+width*(curStart-start),y1,curWidth,height); } - public void drawText(Graphics g, ColourSchemeI cs, SequenceI seq,int start, int end, int x1, int y1, int width, int 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); - boolean colourText = av.getColourText(); - Color c; + char s; // Need to find the sequence position here. for (int i = start; i <= end; i++) { - if (i < end && i < seq.getLength()) - s = seq.getSequence().charAt(i); - else 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