From: kiramt Date: Thu, 17 Aug 2017 14:16:28 +0000 (+0100) Subject: JAL-2665 Fixed wrapped mode group over >1 panel; and hidden cols X-Git-Tag: Release_2_10_3b1~140^2~10 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8f6c457162137583ec6885d2f43d28052dd22dd9;p=jalview.git JAL-2665 Fixed wrapped mode group over >1 panel; and hidden cols --- diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index bd214f5..646ecf8 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -827,8 +827,6 @@ public class SeqCanvas extends JComponent implements ViewportListenerI } - // int startRes, int endRes, int startSeq, int endSeq, int x, int y, - // int x1, int x2, int y1, int y2, int startx, int starty, private void draw(Graphics g, int startRes, int endRes, int startSeq, int endSeq, int offset) { @@ -930,7 +928,8 @@ public class SeqCanvas extends JComponent implements ViewportListenerI sx = (group.getStartRes() - startRes) * charWidth; sy = offset + ((i - startSeq) * charHeight); // width of group in pixels - ex = (((group.getEndRes() + 1) - group.getStartRes()) * charWidth) - 1; + ex = (((group.getEndRes() + 1) - group.getStartRes()) * charWidth) + - 1; if (sx + ex < 0 || sx > visWidth) { @@ -992,7 +991,6 @@ public class SeqCanvas extends JComponent implements ViewportListenerI { ex = visWidth; } - else if (sx + ex >= (endRes - startRes + 1) * charWidth) { ex = (endRes - startRes + 1) * charWidth; @@ -1098,12 +1096,6 @@ public class SeqCanvas extends JComponent implements ViewportListenerI // nothing to draw return null; } - - /*if (!av.getWrapAlignment()) - { - LABEL_EAST = 0; - LABEL_WEST = 0; - }*/ // set up drawing colour Graphics2D g = (Graphics2D) selectionImage.getGraphics(); @@ -1163,7 +1155,6 @@ public class SeqCanvas extends JComponent implements ViewportListenerI blockEnd = hideStart - 1; g.translate(screenY * charWidth, 0); - drawSelectionGroupPart(g, group, blockStart, blockEnd, startSeq, endSeq, offset); @@ -1189,7 +1180,6 @@ public class SeqCanvas extends JComponent implements ViewportListenerI g.translate(-screenY * charWidth, 0); } } - // g.translate(-LABEL_WEST, 0); } /* @@ -1199,32 +1189,6 @@ public class SeqCanvas extends JComponent implements ViewportListenerI int startRes, int endRes, int startSeq, int endSeq, int verticalOffset) { - // set up values in case the alignment is wrapped - /*int verticalOffset = 0; - int horizontalOffset = 0; - if (av.getWrapAlignment()) - { - int hgap = charHeight; - if (av.getScaleAboveWrapped()) - { - hgap += charHeight; - } - - // get the start res of the group and work out the offsets for it in the wrapped alignment - int groupstart = group.getStartRes(); - int cWidth = (getWidth() - LABEL_EAST - LABEL_WEST) / charWidth; - - // group is in which slice of alignment? res position / width in residues - int slice = groupstart / cWidth; - // vertical offset is increased by slice number * number of sequences * height of each sequence - verticalOffset = slice * (av.getAlignment().getHeight() * charHeight - + getAnnotationHeight() + hgap) + hgap; - - // horizontal offset is number of residues to subtract from group residue - // position - horizontalOffset = (slice * cWidth); - }*/ - int visWidth = (endRes - startRes + 1) * charWidth; int oldY = -1; @@ -1235,20 +1199,20 @@ public class SeqCanvas extends JComponent implements ViewportListenerI int sx = -1; int sy = -1; - int ex = -1; - - // position of start residue of group relative to startRes, in pixels - sx = (group.getStartRes() - startRes) * charWidth; - - // width of group in pixels - ex = (((group.getEndRes() + 1) - group.getStartRes()) - * charWidth) - 1; + int xwidth = -1; for (i = startSeq; i <= endSeq; i++) { + // position of start residue of group relative to startRes, in pixels + sx = (group.getStartRes() - startRes) * charWidth; + + // width of group in pixels + xwidth = (((group.getEndRes() + 1) - group.getStartRes()) * charWidth) + - 1; + sy = verticalOffset + (i - startSeq) * charHeight; - if (sx + ex < 0 || sx > visWidth) + if (sx + xwidth < 0 || sx > visWidth) { continue; } @@ -1288,38 +1252,33 @@ public class SeqCanvas extends JComponent implements ViewportListenerI // if end position is visible, draw vertical line to right of // group - if (sx + ex < visWidth) + if (sx + xwidth < visWidth) { - g.drawLine(sx + ex, oldY, sx + ex, sy); + g.drawLine(sx + xwidth, oldY, sx + xwidth, sy); } if (sx < 0) { - ex += sx; + xwidth += sx; sx = 0; } - if (sx + ex > visWidth) - { - ex = visWidth; - } - - else if (sx + ex >= (endRes - startRes + 1) * charWidth) + if (sx + xwidth >= (endRes - startRes + 1) * charWidth) { - ex = (endRes - startRes + 1) * charWidth; + xwidth = (endRes - startRes + 1) * charWidth - sx; } - + // draw horizontal line at top of group if (top != -1) { - g.drawLine(sx, top, sx + ex, top); + g.drawLine(sx, top, sx + xwidth, top); top = -1; } // draw horizontal line at bottom of group if (bottom != -1) { - g.drawLine(sx, bottom, sx + ex, bottom); + g.drawLine(sx, bottom, sx + xwidth, bottom); bottom = -1; } @@ -1336,35 +1295,35 @@ public class SeqCanvas extends JComponent implements ViewportListenerI g.drawLine(sx, oldY, sx, sy); } - if (sx + ex < visWidth) + if (sx + xwidth < visWidth) { - g.drawLine(sx + ex, oldY, sx + ex, sy); + g.drawLine(sx + xwidth, oldY, sx + xwidth, sy); } if (sx < 0) { - ex += sx; + xwidth += sx; sx = 0; } - if (sx + ex > visWidth) + if (sx + xwidth > visWidth) { - ex = visWidth; + xwidth = visWidth; } - else if (sx + ex >= (endRes - startRes + 1) * charWidth) + else if (sx + xwidth >= (endRes - startRes + 1) * charWidth) { - ex = (endRes - startRes + 1) * charWidth; + xwidth = (endRes - startRes + 1) * charWidth; } if (top != -1) { - g.drawLine(sx, top, sx + ex, top); + g.drawLine(sx, top, sx + xwidth, top); top = -1; } if (bottom != -1) { - g.drawLine(sx, bottom - 1, sx + ex, bottom - 1); + g.drawLine(sx, bottom - 1, sx + xwidth, bottom - 1); bottom = -1; }