X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSequenceRenderer.java;h=57cd0fc93c2b0aaa5188066818cf668517c49d69;hb=c24071f7b9e6b70c94743214677871ae2dc88499;hp=e36160a939d13b843aa20a86dbad19a2116a7115;hpb=efc31b4a8d5cee63555586804a2b79c06bdb5a14;p=jalview.git diff --git a/src/jalview/gui/SequenceRenderer.java b/src/jalview/gui/SequenceRenderer.java index e36160a..57cd0fc 100755 --- a/src/jalview/gui/SequenceRenderer.java +++ b/src/jalview/gui/SequenceRenderer.java @@ -24,7 +24,6 @@ import jalview.schemes.*; import java.awt.*; - /** * DOCUMENT ME! * @@ -61,22 +60,27 @@ public class SequenceRenderer renderGaps = b; } - /** - * DOCUMENT ME! - * - * @param cs DOCUMENT ME! - * @param seq DOCUMENT ME! - * @param i DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public Color getResidueBoxColour(ColourSchemeI cs, SequenceI seq, int i) + + public Color getResidueBoxColour(SequenceI seq, int i) { - getBoxColour(cs, seq, i); + allGroups = av.alignment.findAllGroups(seq); + + if (inCurrentSequenceGroup(i)) + { + if (currentSequenceGroup.getDisplayBoxes()) + { + getBoxColour(currentSequenceGroup.cs, seq, i); + } + } + else if (av.getShowBoxes()) + { + getBoxColour(av.globalColourScheme, seq, i); + } - return resBoxColour; + return resBoxColour; } + /** * DOCUMENT ME! * @@ -133,63 +137,62 @@ public class SequenceRenderer * @param width DOCUMENT ME! * @param height DOCUMENT ME! */ - public void drawBoxes(SequenceI seq, int start, int end, int x1, int y1, + public synchronized 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) && (i < length)) + while (i <= end) + { + resBoxColour = Color.white; + + if (i < length) { - if (inCurrentSequenceGroup(i)) - { - if (currentSequenceGroup.getDisplayBoxes()) - { - getBoxColour(currentSequenceGroup.cs, seq, i); - } - else - { - resBoxColour = Color.white; - } - } - else if (av.getShowBoxes()) + if (inCurrentSequenceGroup(i)) + { + if (currentSequenceGroup.getDisplayBoxes()) { - getBoxColour(av.getGlobalColourScheme(), seq, i); - } - else - { - resBoxColour = Color.white; + getBoxColour(currentSequenceGroup.cs, seq, i); } + } + else if (av.getShowBoxes()) + { + getBoxColour(av.globalColourScheme, seq, i); + } - if (resBoxColour != tempColour) - { - if (tempColour != null) - { - graphics.fillRect(x1 + (width * (curStart - start)), 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; + } + + i++; + } + + graphics.fillRect(x1 + (width * (curStart - start)), y1, curWidth, + height); - graphics.fillRect(x1 + (width * (curStart - start)), y1, curWidth, - height); } /** @@ -210,21 +213,18 @@ public class SequenceRenderer int charOffset = 0; char s; + // Need to find the sequence position here. String sequence = seq.getSequence(); + if(end+1>=seq.getLength()) + end = seq.getLength()-1; + for (int i = start; i <= end; i++) { graphics.setColor(Color.black); - if (i < sequence.length()) - { - s = sequence.charAt(i); - } - else - { - s = ' '; - } + s = sequence.charAt(i); if (!renderGaps && jalview.util.Comparison.isGap(s)) { @@ -253,7 +253,7 @@ public class SequenceRenderer if (av.getColourText()) { - getBoxColour(av.getGlobalColourScheme(), seq, i); + getBoxColour(av.globalColourScheme, seq, i); if (av.getShowBoxes()) { @@ -268,7 +268,8 @@ public class SequenceRenderer charOffset = (width - fm.charWidth(s)) / 2; graphics.drawString(String.valueOf(s), - charOffset + x1 + (width * (i - start)), (y1 + height) - pady); + charOffset + x1 + (int)(width * (i - start)), (y1 + height) - pady); + } }