X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSequenceRenderer.java;h=9dbb05ccb75a749e2211e02bc39b8f848b3067ad;hb=2ac5b6423fe366e093c8f12b0935aefc9aafbe5f;hp=0fa8b2ede8673a65f3088030f566ed55f063ff3a;hpb=443f778768843153de0da7fd1ddbedd6e054f339;p=jalview.git diff --git a/src/jalview/appletgui/SequenceRenderer.java b/src/jalview/appletgui/SequenceRenderer.java index 0fa8b2e..9dbb05c 100755 --- a/src/jalview/appletgui/SequenceRenderer.java +++ b/src/jalview/appletgui/SequenceRenderer.java @@ -84,33 +84,33 @@ public class SequenceRenderer public Color findSequenceColour(SequenceI seq, int i) { allGroups = av.alignment.findAllGroups(seq); - drawBoxes(seq, i,i, 0, 0, 1,1); + drawBoxes(seq, i,i, 0); return resBoxColour; } public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg, - int start, int end, int x1, int y1, int width, - int height) + int start, int end, int y1) { allGroups = sg; graphics = g; - drawBoxes(seq, start, end, x1, y1, (int) width, height); - - fm = g.getFontMetrics(); - drawText(seq, start, end, x1, y1, (int) width, height); + drawBoxes(seq, start, end, y1); + if(av.validCharWidth) + { + fm = g.getFontMetrics(); + drawText(seq, start, end, y1); + } } - public void drawBoxes(SequenceI seq, int start, int end, int x1, int y1, - int width, int height) + public void drawBoxes(SequenceI seq, int start, int end, int y1) { int i = start; int length = seq.getLength(); int curStart = -1; - int curWidth = width; + int curWidth = av.charWidth; Color tempColour = null; while (i <= end) @@ -136,32 +136,31 @@ public class SequenceRenderer { if (tempColour != null) { - graphics.fillRect(x1 + width * (curStart - start), y1, curWidth, - height); + graphics.fillRect(av.charWidth * (curStart - start), y1, curWidth, + av.charHeight); } graphics.setColor(resBoxColour); curStart = i; - curWidth = width; + curWidth = av.charWidth; tempColour = resBoxColour; } else { - curWidth += width; + curWidth += av.charWidth; } i++; } - graphics.fillRect(x1 + width * (curStart - start), y1, curWidth, height); + graphics.fillRect(av.charWidth * (curStart - start), y1, curWidth, av.charHeight); } - public void drawText(SequenceI seq, int start, int end, int x1, int y1, - int width, int height) + public void drawText(SequenceI seq, int start, int end, int y1) { - y1 += height - height / 5; // height/5 replaces pady + y1 += av.charHeight - av.charHeight / 5; // height/5 replaces pady int charOffset = 0; @@ -215,9 +214,9 @@ public class SequenceRenderer } } - charOffset = (width - fm.charWidth(s)) / 2; + charOffset = (av.charWidth - fm.charWidth(s)) / 2; graphics.drawString(String.valueOf(s), - charOffset + x1 + width * (i - start), + charOffset + av.charWidth * (i - start), y1 ); } @@ -253,18 +252,42 @@ public class SequenceRenderer char s = '~'; // Need to find the sequence position here. - for (int i = start; i <= end; i++) + if(av.validCharWidth) { - if (i < seq.getLength()) + for (int i = start; i <= end; i++) { - s = seq.getSequence().charAt(i); + if (i < seq.getLength()) + { + s = seq.getSequence().charAt(i); + } + + charOffset = (width - fm.charWidth(s)) / 2; + graphics.drawString(String.valueOf(s), + charOffset + x1 + width * (i - start), + y1 + height - pady); } + } + } + + public void drawCursor(SequenceI seq, int res, int x1, int y1) + { + int pady = av.charHeight / 5; + int charOffset = 0; + graphics.setColor(Color.black); + graphics.fillRect(x1, y1, av.charWidth, av.charHeight); + graphics.setColor(Color.white); + + graphics.setColor(Color.white); + + char s = seq.getCharAt(res); + if (av.validCharWidth) + { - charOffset = (width - fm.charWidth(s)) / 2; + charOffset = (av.charWidth - fm.charWidth(s)) / 2; graphics.drawString(String.valueOf(s), - charOffset + x1 + width * (i - start), - y1 + height - pady); + charOffset + x1, + (y1 + av.charHeight) - pady); + } } - } }