From: amwaterhouse Date: Thu, 16 Mar 2006 15:15:05 +0000 (+0000) Subject: Selection Group rendering updated X-Git-Tag: Root_VamJalview_2_07b+~61 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=dc086b020537a18c3ce575fbb220033979270a65 Selection Group rendering updated --- diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index ac5ff89..5afbe23 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -152,21 +152,34 @@ public class SeqCanvas } - public void fastPaint(int horizontal, int vertical) + int lastsr=0; + void fastPaint(int horizontal, int vertical) { - if (fastPaint || gg == null) + if ( fastPaint || gg == null) { - repaint(); return; } + + // Its possible on certain browsers that the call to fastpaint + // is faster than it can paint, so this check here catches + // this possibility + if(lastsr + horizontal != av.startRes) + { + horizontal = av.startRes - lastsr; + } + + lastsr = av.startRes; + fastPaint = true; gg.copyArea(horizontal * av.charWidth, vertical * av.charHeight, - imgWidth, - imgHeight, + imgWidth - horizontal * av.charWidth, + imgHeight - vertical * av.charHeight, -horizontal * av.charWidth, - -vertical * av.charHeight); + -vertical * av.charHeight); + + int sr = av.startRes, er = av.endRes, ss = av.startSeq, es = av.endSeq, transX = 0, transY = 0; @@ -424,7 +437,7 @@ public class SeqCanvas return annotations.adjustPanelHeight(); } - synchronized public void drawPanel(Graphics g, int startRes, int endRes, int startSeq, int endSeq, int offset) + void drawPanel(Graphics g, int startRes, int endRes, int startSeq, int endSeq, int offset) { g.setFont(av.getFont()); @@ -438,15 +451,12 @@ public class SeqCanvas nextSeq = av.alignment.getSequenceAt(i); sr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq), startRes, endRes, - (startRes - startRes) * av.charWidth, - offset + - (i - startSeq) * av.charHeight, - av.charWidth, av.charHeight); + offset + ( (i - startSeq) * av.charHeight)); if (av.showSequenceFeatures) { fr.drawSequence(g, nextSeq, startRes, endRes, - offset +(i - startSeq) * av.charHeight, + offset + ((i - startSeq) * av.charHeight), av.charWidth, av.charHeight); } /// Highlight search Results once all sequences have been drawn @@ -466,162 +476,163 @@ public class SeqCanvas } } - ///////////////////////////////////// + // + ///////////////////////////////////// + // Now outline any areas if necessary + ///////////////////////////////////// + SequenceGroup group = av.getSelectionGroup(); - // Now outline any areas if necessary - ///////////////////////////////////// - SequenceGroup group = av.getSelectionGroup(); - java.util.Vector groups = av.alignment.getGroups(); + int sx = -1; + int sy = -1; + int ex = -1; + int groupIndex = -1; - int sx = -1, sy = -1, ex = -1; - int groupIndex = -1; - if (group == null && groups.size() > 0) - { - group = (SequenceGroup) groups.elementAt(0); + if ((group == null) && (av.alignment.getGroups().size() > 0)) + { + group = (SequenceGroup) av.alignment.getGroups().elementAt(0); groupIndex = 0; - } - if (group != null) - { - do - { - int oldY = -1; - int i = 0; - boolean inGroup = false; - int top = -1; - int bottom = -1; + } - for (i = startSeq; i < endSeq; i++) - { - sx = (group.getStartRes() - startRes) * av.charWidth; - sy = offset + ((i - startSeq) * av.charHeight); - ex = (((group.getEndRes() + 1) - group.getStartRes()) * av.charWidth) - - 1; + if ( group != null) + { + do + { + int oldY = -1; + int i = 0; + boolean inGroup = false; + int top = -1; + int bottom = -1; + + for (i = startSeq; i < endSeq; i++) + { + sx = (group.getStartRes() - startRes) * av.charWidth; + sy = offset + ((i - startSeq) * av.charHeight); + ex = (((group.getEndRes() + 1) - group.getStartRes()) * av.charWidth) - + 1; + + if(sx+ex<0 || sx>imgWidth) + { + continue; + } - if(sx+ex<0 || sx>imgWidth) + if ( (sx <= (endRes-startRes)*av.charWidth) && + group.sequences.contains(av.alignment.getSequenceAt( + i))) + { + if (bottom == -1) { - continue; + if(i == endSeq-1 || // Dont check for i+1 if on the bottom row + !group.sequences.contains(av.alignment.getSequenceAt(i+1 ))) + + bottom = sy + av.charHeight; } - if ( (sx <= (endRes-startRes)*av.charWidth) && - group.sequences.contains(av.alignment.getSequenceAt( - i))) + 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 + { + if (inGroup) { + if (sx >= 0 && sx < imgWidth) + g.drawLine(sx, oldY, sx, sy); - if (bottom == -1) - { - if(i == endSeq-1 || // Dont check for i+1 if on the bottom row - !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 - { - if (inGroup) + if (sx + ex < imgWidth) + g.drawLine(sx + ex, oldY, sx + ex, sy); + + if (sx < 0) { - 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 >= (endRes - startRes + 1) * av.charWidth) - ex = (endRes - startRes + 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; - } - } - } + ex += sx; + sx = 0; + } - if (inGroup) - { - sy = offset + ( (i - startSeq) * av.charHeight); - if (sx >= 0 && sx < imgWidth) - g.drawLine(sx, oldY, sx, sy); + if (sx + ex > imgWidth) + ex = imgWidth; - if (sx + ex < imgWidth) - g.drawLine(sx + ex, oldY, sx + ex, sy); + else if (sx + ex >= (endRes - startRes + 1) * av.charWidth) + ex = (endRes - startRes + 1) * av.charWidth; - if (sx < 0) - { - ex += sx; - sx = 0; - } + if (top != -1) + { + g.drawLine(sx, top, sx + ex, top); + top = -1; + } - if (sx + ex > imgWidth) - ex = imgWidth; - else if (sx + ex >= (endRes - startRes + 1) * av.charWidth) - ex = (endRes - startRes + 1) * av.charWidth; + if (bottom != -1) + { + g.drawLine(sx, bottom, sx + ex, bottom); + 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; - } + if (inGroup) + { + sy = offset + ( (i - startSeq) * 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); - inGroup = false; + if (sx < 0) + { + ex += sx; + sx = 0; } - groupIndex++; + if (sx + ex > imgWidth) + ex = imgWidth; + else if (sx + ex >= (endRes - startRes + 1) * av.charWidth) + ex = (endRes - startRes + 1) * av.charWidth; - if (groupIndex >= groups.size()) + if (top != -1) { - break; + g.drawLine(sx, top, sx + ex, top); + top = -1; } - group = (SequenceGroup) groups.elementAt(groupIndex); - } - while (groupIndex < groups.size()); + if (bottom != -1) + { + g.drawLine(sx, bottom - 1, sx + ex, bottom - 1); + bottom = -1; + } + + inGroup = false; + } + + groupIndex++; + + if (groupIndex >= av.alignment.getGroups().size()) + { + break; + } + + group = (SequenceGroup) av.alignment.getGroups().elementAt(groupIndex); + } + while (groupIndex < av.alignment.getGroups().size()); } }