X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fappletgui%2FSeqCanvas.java;h=8ffad089b1ce96cf2dfdb16a1dec38fef46c8935;hb=8da7acff9214ddaf0e6d28e76219ab51bd38e62d;hp=5aa5d663d84574664fbce7267aa40320dee8bebf;hpb=6e71f42b0a3713ddbc3054e7ea9d8f5088130ec9;p=jalview.git diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index 5aa5d66..8ffad08 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -21,7 +21,6 @@ package jalview.appletgui; import java.awt.*; -import jalview.analysis.*; import jalview.datamodel.*; public class SeqCanvas @@ -36,7 +35,6 @@ public class SeqCanvas AlignViewport av; - boolean showScores = false; boolean displaySearch = false; int[] searchResults = null; @@ -97,7 +95,7 @@ public class SeqCanvas } if (value != -1) { - int x = LABEL_WEST - fm.stringWidth(value + ""); + int x = LABEL_WEST - fm.stringWidth(String.valueOf(value))-av.charWidth/2; g.drawString(value + "", x, ypos + i * av.charHeight - av.charHeight / 5); } @@ -126,7 +124,7 @@ public class SeqCanvas } if (value != -1) { - g.drawString(value + "", 0, + g.drawString(value + "", av.charWidth/2, ypos + i * av.charHeight - av.charHeight / 5); } } @@ -243,7 +241,7 @@ public class SeqCanvas if (av.getWrapAlignment()) { - drawWrappedPanel(gg, getSize().width, getSize().height, av.startRes); + drawWrappedPanel(gg, imgWidth, imgHeight, av.startRes); } else { @@ -258,24 +256,39 @@ public class SeqCanvas int LABEL_WEST, LABEL_EAST; public int getWrappedCanvasWidth(int cwidth) { - FontMetrics fm = getFontMetrics(av.getFont()); + FontMetrics fm = getFontMetrics(av.getFont()); - LABEL_EAST = 0; - LABEL_WEST = 0; + LABEL_EAST = 0; + LABEL_WEST = 0; - if (av.scaleRightWrapped) - { - LABEL_EAST = fm.stringWidth(av.alignment.getWidth() + "000"); - } + if (av.scaleRightWrapped) + { + LABEL_EAST = fm.stringWidth(getMask()+"0"); + } - if (av.scaleLeftWrapped) - { - LABEL_WEST = fm.stringWidth(av.alignment.getWidth() + ""); - } + if (av.scaleLeftWrapped) + { + LABEL_WEST = fm.stringWidth(getMask()); + } - return (cwidth - LABEL_EAST - LABEL_WEST) / av.charWidth; + return (cwidth - LABEL_EAST - LABEL_WEST) / av.charWidth; } + + /** + * Generates a string of zeroes. + * @return String + */ + String getMask() + { + String mask = "0"; + for (int i = av.alignment.getWidth(); i > 0; i /= 10) + { + mask += "0"; + } + return mask; + } + public void drawWrappedPanel(Graphics g, int canvasWidth, int canvasHeight, int startRes) { @@ -283,15 +296,16 @@ public class SeqCanvas FontMetrics fm = getFontMetrics(av.getFont()); - int LABEL_EAST = 0; if (av.scaleRightWrapped) { - LABEL_EAST = fm.stringWidth(al.getWidth() + "000"); + LABEL_EAST = fm.stringWidth(getMask()+"0"); } + int LABEL_WEST = 0; + if (av.scaleLeftWrapped) { - LABEL_WEST = fm.stringWidth(al.getWidth() + "0"); + LABEL_WEST = fm.stringWidth(getMask()); } int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / av.charWidth; @@ -313,9 +327,9 @@ public class SeqCanvas if (av.scaleRightWrapped) { - g.translate(canvasWidth - LABEL_EAST + av.charWidth, 0); + g.translate(canvasWidth - LABEL_EAST, 0); drawEastScale(g, startRes, endx, ypos); - g.translate( - (canvasWidth - LABEL_EAST + av.charWidth), 0); + g.translate( - (canvasWidth - LABEL_EAST), 0); } g.translate(LABEL_WEST, 0); @@ -324,24 +338,16 @@ public class SeqCanvas drawNorthScale(g, startRes, endx, ypos); } - // When printing we have an extra clipped region, - // the Printable page which we need to account for here - Shape clip = g.getClip(); - if (clip == null) - { - g.setClip(0, 0, cWidth * av.charWidth, canvasHeight); - } - else - { - g.setClip(0, - (int) clip.getBounds().y, - cWidth * av.charWidth, - (int) clip.getBounds().height - ); - } - drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos); - g.setClip(clip); + if(g.getClip()==null) + g.setClip(0, 0, cWidth * av.charWidth, canvasHeight); + + if (av.alignment.getWidth() >= av.vconsensus.size()) + { + endx = av.vconsensus.size() - 2; + } + drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos); + g.setClip(null); g.translate( -LABEL_WEST, 0); ypos += cHeight; @@ -374,7 +380,7 @@ public class SeqCanvas sr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq), x1, x2, (x1 - startx) * av.charWidth, offset + - AlignmentUtil.getPixelHeight(starty, i, av.charHeight), + (i-starty)*av.charHeight, av.charWidth, av.charHeight); if (av.showSequenceFeatures) @@ -382,7 +388,7 @@ public class SeqCanvas fr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq), x1, x2, (x1 - startx) * av.charWidth, offset + - AlignmentUtil.getPixelHeight(starty, i, av.charHeight), + (i-starty)*av.charHeight, av.charWidth, av.charHeight); } } @@ -413,7 +419,7 @@ public class SeqCanvas for (i = y1; i < y2; i++) { sx = (group.getStartRes() - startx) * av.charWidth; - sy = offset + AlignmentUtil.getPixelHeight(starty, i, av.charHeight); + sy = offset + (i-starty)*av.charHeight; ex = (group.getEndRes() + 1 - group.getStartRes()) * av.charWidth - 1; if (sx < getSize().width @@ -484,7 +490,7 @@ public class SeqCanvas bottom = -1; } - sy = offset + AlignmentUtil.getPixelHeight(starty, i, av.charHeight); + sy = offset + (i-starty)*av.charHeight; g.drawLine(sx, oldY, sx, sy); g.drawLine(sx + ex, oldY, sx + ex, sy); inGroup = false; @@ -531,9 +537,7 @@ public class SeqCanvas searchEnd, (searchStart - startx) * av.charWidth, offset + - AlignmentUtil.getPixelHeight(starty, - searchSeq, - av.charHeight), + (searchSeq-starty)*av.charHeight, av.charWidth, av.charHeight); }