X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSequenceRenderer.java;h=5b5a392f5ed445a6de169df6fe24f77421d3d4e6;hb=e71a5d2b1e0025a8e23eb637f12f6f5665c91feb;hp=82124cef35ffe78efb91fecb77dccfd79d04094d;hpb=c9f0ef34e578218c8ffabaac9c405fd86d1196e2;p=jalview.git diff --git a/src/jalview/gui/SequenceRenderer.java b/src/jalview/gui/SequenceRenderer.java index 82124ce..5b5a392 100755 --- a/src/jalview/gui/SequenceRenderer.java +++ b/src/jalview/gui/SequenceRenderer.java @@ -11,7 +11,9 @@ public class SequenceRenderer implements RendererI FontMetrics fm; boolean renderGaps = true; SequenceGroup currentSequenceGroup = null; - Color color; + SequenceGroup [] allGroups = null; + Color resBoxColour; + Graphics graphics; public SequenceRenderer(AlignViewport av) { @@ -26,93 +28,100 @@ public class SequenceRenderer implements RendererI 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){} + getBoxColour(cs, seq, i); + return resBoxColour; + } - return c; + void getBoxColour(ColourSchemeI cs, SequenceI seq, int i) + { + if (cs != null) + resBoxColour = cs.findColour(seq.getSequence(i, i + 1), i, av.getConsensus(false)); + else + resBoxColour = Color.white; } - 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) + 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; + allGroups = sg; - drawBoxes(g, seq, start, end, x1, y1, (int) width, height, pid); + graphics = g; + + drawBoxes(seq, start, end, x1, y1, (int) width, height, pid); fm = g.getFontMetrics(); - drawText(g,seq,start,end,x1,y1,(int)width,height); + drawText(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) { + public void drawBoxes(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; + Color tempColour = null; while (i <= end && i < length) { - color = color.white; - if(inCurrentSequenceGroup(i)) { if( currentSequenceGroup.getDisplayBoxes()) - color = getResidueBoxColour(currentSequenceGroup.cs, seq, i); + getBoxColour(currentSequenceGroup.cs, seq, i); } else if(av.getShowBoxes()) - color = getResidueBoxColour(av.getGlobalColourScheme(), seq, i); + getBoxColour(av.getGlobalColourScheme(), seq, i); + else + resBoxColour = Color.white; - if (color != currentColor || color != null) + if (resBoxColour != tempColour) { - g.fillRect(x1+width*(curStart-start),y1,curWidth,height); - - currentColor = color; - g.setColor(color); + graphics.fillRect(x1+width*(curStart-start),y1,curWidth,height); + graphics.setColor(resBoxColour); curStart = i; curWidth = width; + tempColour = resBoxColour; + } else curWidth += width; i++; } - g.fillRect(x1+width*(curStart-start),y1,curWidth,height); + graphics.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) + public void drawText(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. + + graphics.setColor(Color.black); + String sequence = seq.getSequence(); for (int i = start; i <= end; i++) { - if(i=res)?true:false; + for(int i=0; i=res) + { + currentSequenceGroup = allGroups[i]; + return true; + } + + return false; } - public void drawHighlightedText(Graphics g, SequenceI seq,int start, int end, int x1, int y1, int width, int height) + public void drawHighlightedText(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); + graphics.setColor(Color.BLACK); + graphics.fillRect(x1,y1,width*(end-start+1),height); + graphics.setColor(Color.white); char s='~'; // Need to find the sequence position here. @@ -153,8 +174,8 @@ try{ if(i