From 639553df9be00842fb12ad4ddfc39a65cb3a60bd Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Mon, 2 Oct 2023 20:15:30 +0100 Subject: [PATCH] JAL-4289 In fastPaint(), don't render one more than necessary sequence when scrolling up or down. Adjust transY for this one fewer sequence render. Draw group lower boundary within the sequence boundary -- makes things much simple, and also is visible on bottom row. Don't use -1 for lower boundary y-value. --- src/jalview/gui/SeqCanvas.java | 74 +++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 31 deletions(-) diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 537af58..a9bfbf6 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -323,7 +323,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI if (vertical > 0) // scroll down { - startSeq = endSeq - vertical; + startSeq = endSeq - vertical + 1; if (startSeq < ranges.getStartSeq()) { // ie scrolling too fast, more than a page at a time @@ -331,12 +331,12 @@ public class SeqCanvas extends JPanel implements ViewportListenerI } else { - transY = img.getHeight() - ((vertical + 1) * charHeight); + transY = img.getHeight() - (vertical * charHeight); } } - else if (vertical < 0) + else if (vertical < 0) // scroll up { - endSeq = startSeq - vertical; + endSeq = startSeq - vertical - 1; if (endSeq > ranges.getEndSeq()) { @@ -344,7 +344,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI } } - // jalview.bin.Console.errPrintln(">>> FastPaint to " + transX + " " + transY + " " + // jalview.bin.Console.errPrintln(">>> FastPaint to " + transX + " " + + // transY + " " // + horizontal + " " + vertical + " " + startRes + " " + endRes // + " " + startSeq + " " + endSeq); @@ -363,7 +364,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI // Call repaint on alignment panel so that repaints from other alignment // panel components can be aggregated. Otherwise performance of the // overview window and others may be adversely affected. - // jalview.bin.Console.outPrintln("SeqCanvas fastPaint() repaint() request..."); + // jalview.bin.Console.outPrintln("SeqCanvas fastPaint() repaint() + // request..."); av.getAlignPanel().repaint(); } finally { @@ -456,11 +458,12 @@ public class SeqCanvas extends JPanel implements ViewportListenerI if (av.getWrapAlignment()) { - drawWrappedPanel(seqRdr, gg, getWidth(), getHeight(), ranges.getStartRes()); + drawWrappedPanel(seqRdr, gg, getWidth(), getHeight(), + ranges.getStartRes()); } else { - drawPanel(seqRdr,gg, startRes, endRes, startSeq, endSeq, 0); + drawPanel(seqRdr, gg, startRes, endRes, startSeq, endSeq, 0); } drawSelectionGroup(gg, startRes, endRes, startSeq, endSeq); @@ -493,7 +496,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI int startSeq, int endSeq) { SequenceRenderer localSeqR = new jalview.gui.SequenceRenderer(av); - drawPanel(localSeqR,g1, startRes, endRes, startSeq, endSeq, 0); + drawPanel(localSeqR, g1, startRes, endRes, startSeq, endSeq, 0); drawSelectionGroup((Graphics2D) g1, startRes, endRes, startSeq, endSeq); } @@ -611,8 +614,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI * @param startColumn * the first column (0...) of the alignment to draw */ - public void drawWrappedPanel(SequenceRenderer seqRdr, Graphics g, int canvasWidth, - int canvasHeight, final int startColumn) + public void drawWrappedPanel(SequenceRenderer seqRdr, Graphics g, + int canvasWidth, int canvasHeight, final int startColumn) { int wrappedWidthInResidues = calculateWrappedGeometry(canvasWidth, canvasHeight); @@ -733,8 +736,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI * @param endColumn * @param canvasHeight */ - protected void drawWrappedWidth(SequenceRenderer seqRdr, Graphics g, final int ypos, - final int startColumn, final int endColumn, + protected void drawWrappedWidth(SequenceRenderer seqRdr, Graphics g, + final int ypos, final int startColumn, final int endColumn, final int canvasHeight) { ViewportRanges ranges = av.getRanges(); @@ -762,8 +765,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI g.fillRect(0, ypos, (endx - startColumn + 1) * charWidth, wrappedRepeatHeightPx); - drawPanel(seqRdr, g, startColumn, endx, 0, av.getAlignment().getHeight() - 1, - ypos); + drawPanel(seqRdr, g, startColumn, endx, 0, + av.getAlignment().getHeight() - 1, ypos); int cHeight = av.getAlignment().getHeight() * av.getCharHeight(); @@ -966,7 +969,10 @@ public class SeqCanvas extends JPanel implements ViewportListenerI * are hidden column markers in the visible region, then each sub-region * between the markers is drawn separately, followed by the hidden column * marker. - * @param localSeqR - sequence renderer implementation - when null, uses the one used for rendering interactive GUI + * + * @param localSeqR + * - sequence renderer implementation - when null, uses the one used + * for rendering interactive GUI * * @param g1 * the graphics context, positioned at the first residue to be drawn @@ -981,13 +987,14 @@ public class SeqCanvas extends JPanel implements ViewportListenerI * @param yOffset * vertical offset at which to draw (for wrapped alignments) */ - public void drawPanel(SequenceRenderer localSeqR, Graphics g1, final int startRes, final int endRes, - final int startSeq, final int endSeq, final int yOffset) + public void drawPanel(SequenceRenderer localSeqR, Graphics g1, + final int startRes, final int endRes, final int startSeq, + final int endSeq, final int yOffset) { int charHeight = av.getCharHeight(); int charWidth = av.getCharWidth(); - if (localSeqR==null) + if (localSeqR == null) { localSeqR = seqRdr; } @@ -1017,7 +1024,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI */ g1.translate(screenY * charWidth, 0); - draw(localSeqR, g1, blockStart, blockEnd, startSeq, endSeq, yOffset); + draw(localSeqR, g1, blockStart, blockEnd, startSeq, endSeq, + yOffset); /* * draw the downline of the hidden column marker (ScalePanel draws the @@ -1042,7 +1050,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI /** * Draws a region of the visible alignment - * @param seqRdr + * + * @param seqRdr * * @param g1 * @param startRes @@ -1056,8 +1065,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI * @param yOffset * vertical offset at which to draw (for wrapped alignments) */ - private void draw(SequenceRenderer seqRdr, Graphics g, int startRes, int endRes, int startSeq, - int endSeq, int offset) + private void draw(SequenceRenderer seqRdr, Graphics g, int startRes, + int endRes, int startSeq, int endSeq, int offset) { int charHeight = av.getCharHeight(); int charWidth = av.getCharWidth(); @@ -1399,7 +1408,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI else if (inGroup) { drawVerticals(g, sx, xwidth, visWidth, oldY, bottom); - drawHorizontals(g, sx, xwidth, visWidth, top, bottom+1); + drawHorizontals(g, sx, xwidth, visWidth, top, bottom); // reset top and bottom top = -1; @@ -1410,8 +1419,9 @@ public class SeqCanvas extends JPanel implements ViewportListenerI if (inGroup) { sy = verticalOffset + ((i - startSeq) * charHeight); - drawVerticals(g, sx, xwidth, visWidth, oldY, bottom); - drawHorizontals(g, sx, xwidth, visWidth, top, bottom+1); + drawVerticals(g, sx, xwidth, visWidth, oldY, + bottom == -1 ? sy : bottom); + drawHorizontals(g, sx, xwidth, visWidth, top, bottom); } } } @@ -1688,7 +1698,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI public void propertyChange(PropertyChangeEvent evt) { String eventName = evt.getPropertyName(); - // jalview.bin.Console.errPrintln(">>SeqCanvas propertyChange " + eventName); + // jalview.bin.Console.errPrintln(">>SeqCanvas propertyChange " + + // eventName); if (eventName.equals(SequenceGroup.SEQ_GROUP_CHANGED)) { fastPaint = true; @@ -1698,7 +1709,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI else if (eventName.equals(ViewportRanges.MOVE_VIEWPORT)) { fastPaint = false; - // jalview.bin.Console.errPrintln("!!!! fastPaint false from MOVE_VIEWPORT"); + // jalview.bin.Console.errPrintln("!!!! fastPaint false from + // MOVE_VIEWPORT"); repaint(); return; } @@ -1828,7 +1840,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI if (scrollX < 0) { int startRes = ranges.getStartRes(); - drawWrappedWidth(seqRdr,gg, wrappedSpaceAboveAlignment, startRes, + drawWrappedWidth(seqRdr, gg, wrappedSpaceAboveAlignment, startRes, startRes - scrollX - 1, getHeight()); } else @@ -2156,8 +2168,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI { matchFound = true; gg.translate(transX, transY); - drawPanel(seqRdr,gg, displayColumn, displayColumn, seqNo, seqNo, - yOffset); + drawPanel(seqRdr, gg, displayColumn, displayColumn, seqNo, + seqNo, yOffset); gg.translate(-transX, -transY); } } -- 1.7.10.2