X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSeqCanvas.java;h=9e8f895bbd512d2990d9ea4cff2027258312a80a;hb=7e129811d6ff01074428462284dffc2a6c2395a4;hp=3202fc44e803b1a56999cbabd7d2b827e0b71edf;hpb=019042a9f87d94260b3060cdf45ab93ca714a46d;p=jalview.git diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index 3202fc4..9e8f895 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 @@ -134,7 +133,7 @@ public class SeqCanvas public void fastPaint(int horizontal, int vertical) { - if (horizontal == 0 && vertical == 0 || gg == null) + if (gg == null) { return; } @@ -242,7 +241,7 @@ public class SeqCanvas if (av.getWrapAlignment()) { - drawWrappedPanel(gg, getSize().width, getSize().height, av.startRes); + drawWrappedPanel(gg, imgWidth, imgHeight, av.startRes); } else { @@ -339,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; @@ -421,97 +412,139 @@ public class SeqCanvas { do { - int oldY = -1; - int i = 0; - boolean inGroup = false; - int top = -1, bottom = -1; - for (i = y1; i < y2; i++) - { - sx = (group.getStartRes() - startx) * av.charWidth; - sy = offset + (i-starty)*av.charHeight; - ex = (group.getEndRes() + 1 - group.getStartRes()) * av.charWidth - 1; + int oldY = -1; + int i = 0; + boolean inGroup = false; + int top = -1; + int bottom = -1; - if (sx < getSize().width - && ex > 0 - && group.sequences.contains(av.alignment.getSequenceAt(i))) + for (i = y1; i < y2; i++) { - if (bottom == -1 && (i == av.alignment.getHeight() - 1 || - !group.sequences.contains(av.alignment. - getSequenceAt(i + 1)))) - { - bottom = sy + av.charHeight; - } + sx = (group.getStartRes() - startx) * av.charWidth; + sy = offset + ((i - starty) * av.charHeight); + ex = (((group.getEndRes() + 1) - group.getStartRes()) * av.charWidth) - + 1; - if (!inGroup) - { - if (top == -1 && i == 0 || - !group.sequences.contains(av.alignment.getSequenceAt(i - 1))) + if(sx+ex<0 || sx>imgWidth) { - top = sy; + continue; } - oldY = sy; - inGroup = true; - if (group == av.getSelectionGroup()) + if ( (sx <= (x2-x1)*av.charWidth) && + group.sequences.contains(av.alignment.getSequenceAt( + i))) { - g.setColor(new Color(255, 0, 0)); + if ((bottom == -1) && + !group.sequences.contains( + av.alignment.getSequenceAt(i + 1))) + { + bottom = sy + av.charHeight; + } + + if (!inGroup) + { + if (((top == -1) && (i == 0)) || + !group.sequences.contains( + av.alignment.getSequenceAt(i - 1))) + { + top = sy; + } + + oldY = sy; + inGroup = true; + + if (group == av.getSelectionGroup()) + { + g.setColor(Color.red); + } + else + { + g.setColor(group.getOutlineColour()); + } + } } else { - g.setColor(group.getOutlineColour()); + if (inGroup) + { + if (sx >= 0 && sx < imgWidth) + g.drawLine(sx, oldY, sx, sy); + + if (sx + ex < imgWidth) + g.drawLine(sx + ex, oldY, sx + ex, sy); + + if (sx < 0) + { + ex += sx; + sx = 0; + } + + if (sx + ex > imgWidth) + ex = imgWidth; + + else if (sx + ex >= (x2 - x1 + 1) * av.charWidth) + ex = (x2 - x1 + 1) * av.charWidth; + + if (top != -1) + { + g.drawLine(sx, top, sx + ex, top); + top = -1; + } + + if (bottom != -1) + { + g.drawLine(sx, bottom, sx + ex, bottom); + bottom = -1; + } + + inGroup = false; + } } - } } - else + + if (inGroup) { - if (inGroup) - { + sy = offset + ( (i - starty) * av.charHeight); + if (sx >= 0 && sx < imgWidth) g.drawLine(sx, oldY, sx, sy); + + if (sx + ex < imgWidth) g.drawLine(sx + ex, oldY, sx + ex, sy); - if (top != -1) - { - g.drawLine(sx, top, sx + ex, top); - top = -1; - } - if (bottom != -1) - { - g.drawLine(sx, bottom, sx + ex, bottom); - bottom = -1; - } + if (sx < 0) + { + ex += sx; + sx = 0; + } - inGroup = false; + if (sx + ex > imgWidth) + ex = imgWidth; + else if (sx + ex >= (x2 - x1 + 1) * av.charWidth) + ex = (x2 - x1 + 1) * av.charWidth; + + if (top != -1) + { + g.drawLine(sx, top, sx + ex, top); + top = -1; } - } - } - if (inGroup) - { + if (bottom != -1) + { + g.drawLine(sx, bottom - 1, sx + ex, bottom - 1); + bottom = -1; + } - if (top != -1) - { - g.drawLine(sx, top, sx + ex, top); - top = -1; + inGroup = false; } - if (bottom != -1) - { - g.drawLine(sx, bottom - 1, sx + ex, bottom - 1); - bottom = -1; - } - sy = offset + (i-starty)*av.charHeight; - g.drawLine(sx, oldY, sx, sy); - g.drawLine(sx + ex, oldY, sx + ex, sy); - inGroup = false; - } - groupIndex++; - if (groupIndex >= groups.size()) - { - break; - } + groupIndex++; - group = (SequenceGroup) groups.elementAt(groupIndex); + if (groupIndex >= groups.size()) + { + break; + } + group = (SequenceGroup) groups.elementAt(groupIndex); } while (groupIndex < groups.size()); }