X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSequenceRenderer.java;h=7070e5d0115803174fdbb5736e1729a00813fb36;hb=dea32f71ff7f8a80cc8494864b6605921d81fafa;hp=b961b2c8d894c24b23b38ea4434ec4fa515a2a93;hpb=783520af519c958e10a2af29f1d4242e1ab890a3;p=jalview.git diff --git a/src/jalview/gui/SequenceRenderer.java b/src/jalview/gui/SequenceRenderer.java index b961b2c..7070e5d 100755 --- a/src/jalview/gui/SequenceRenderer.java +++ b/src/jalview/gui/SequenceRenderer.java @@ -23,6 +23,7 @@ import jalview.datamodel.*; import jalview.schemes.*; import java.awt.*; +import java.awt.image.BufferedImage; /** @@ -77,6 +78,23 @@ public class SequenceRenderer return resBoxColour; } + BufferedImage bi; + public Color findSequenceColour(Color initialCol, SequenceI seq, int i) + { + if (bi == null) + bi = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); + + bi.getGraphics().setColor(initialCol); + bi.getGraphics().fillRect(0, 0, 1, 1); + allGroups = av.alignment.findAllGroups(seq); + graphics = bi.getGraphics(); + + drawBoxes(seq, i,i, 0, 0, 1,1); + + return new Color(bi.getRGB(0, 0)); + } + + /** * DOCUMENT ME! * @@ -136,72 +154,59 @@ public class SequenceRenderer public void drawBoxes(SequenceI seq, int start, int end, int x1, int y1, int width, int height) { - int i = start; - int length = seq.getLength(); + int i = start; + int length = seq.getLength(); - int curStart = -1; - int curWidth = width; + int curStart = -1; + int curWidth = width; - Color tempColour = null; + Color tempColour = null; - while (i <= end) - { - resBoxColour = Color.white; + while (i <= end) + { + resBoxColour = Color.white; - if (i < length) + if (i < length) + { + if (inCurrentSequenceGroup(i)) { - if (inCurrentSequenceGroup(i)) + if (currentSequenceGroup.getDisplayBoxes()) { - if (currentSequenceGroup.getDisplayBoxes()) - { - getBoxColour(currentSequenceGroup.cs, seq, i); - } + getBoxColour(currentSequenceGroup.cs, seq, i); } - else if (av.getShowBoxes()) - { - getBoxColour(av.getGlobalColourScheme(), seq, i); - } - + } + else if (av.getShowBoxes()) + { + getBoxColour(av.getGlobalColourScheme(), seq, i); } - if (resBoxColour != tempColour) - { - if (tempColour != null) - { - int xxx = x1 + (int) (av.charWidth * (curStart - start)); - if (width != av.charWidth) - { - xxx = x1 + (int) (av.charWidth * (curStart - start)) / 3; - } - - - graphics.fillRect(xxx, y1, - curWidth, height); - } + } - graphics.setColor(resBoxColour); + if (resBoxColour != tempColour) + { + if (tempColour != null) + { + graphics.fillRect(x1 + (width * (curStart - start)), y1, + curWidth, height); + } - curStart = i; - curWidth = width; - tempColour = resBoxColour; - } - else - { - curWidth += width; - } + graphics.setColor(resBoxColour); - i++; - } + curStart = i; + curWidth = width; + tempColour = resBoxColour; + } + else + { + curWidth += width; + } - int xxx = x1 + (int) (av.charWidth * (curStart - start)); - if (width != av.charWidth) - { - xxx = x1 + (int) (av.charWidth * (curStart - start)) / 3; - } + i++; + } + graphics.fillRect(x1 + (width * (curStart - start)), y1, curWidth, + height); - graphics.fillRect(xxx, y1, curWidth, - height); } /** @@ -276,14 +281,9 @@ public class SequenceRenderer } charOffset = (width - fm.charWidth(s)) / 2; + graphics.drawString(String.valueOf(s), + charOffset + x1 + (int)(width * (i - start)), (y1 + height) - pady); - int xxx = charOffset + x1 + (int)(av.charWidth * (i - start)); - if(width != av.charWidth) - { - xxx = charOffset + x1 + (int)(av.charWidth * (i - start))/3; - } - - graphics.drawString(String.valueOf(s),xxx, (y1 + height) - pady); } }