From: gmungoc Date: Thu, 16 Jan 2020 14:00:33 +0000 (+0000) Subject: JAL-3502 improved fast paint of wrapped scales X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=75b8a1f5fc598fce03b4304c5e165c2ef6855389;p=jalview.git JAL-3502 improved fast paint of wrapped scales --- diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 2832796..9689d5c 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -194,24 +194,34 @@ public class SeqCanvas extends JComponent implements ViewportListenerI void drawVerticalScale(Graphics g, final int startx, final int endx, final int ypos, final boolean left) { - int charHeight = av.getCharHeight(); - int charWidth = av.getCharWidth(); + final int charHeight = av.getCharHeight(); + final int charWidth = av.getCharWidth(); - int yPos = ypos + charHeight; + final int yPos = ypos + charHeight; int startX = startx; int endX = endx; + AlignmentI alignment = av.getAlignment(); if (av.hasHiddenColumns()) { - HiddenColumns hiddenColumns = av.getAlignment().getHiddenColumns(); + HiddenColumns hiddenColumns = alignment.getHiddenColumns(); startX = hiddenColumns.visibleToAbsoluteColumn(startx); endX = hiddenColumns.visibleToAbsoluteColumn(endx); } FontMetrics fm = getFontMetrics(av.getFont()); - for (int i = 0; i < av.getAlignment().getHeight(); i++) + /* + * white fill the space for the scale for correct 'fast paint' + * (repainting only changed regions of the image) + * (fillRect origin is top left of rectangle) + */ + g.setColor(Color.white); + g.fillRect(0, ypos, left ? labelWidthWest : labelWidthEast, + (alignment.getHeight() * charHeight)); + + for (int i = 0; i < alignment.getHeight(); i++) { - SequenceI seq = av.getAlignment().getSequenceAt(i); + SequenceI seq = alignment.getSequenceAt(i); /* * find sequence position of first non-gapped position - @@ -236,15 +246,6 @@ public class SeqCanvas extends JComponent implements ViewportListenerI } } - /* - * white fill the space for the scale - */ - g.setColor(Color.white); - int y = (yPos + (i * charHeight)) - (charHeight / 5); - // fillRect origin is top left of rectangle - g.fillRect(0, y - charHeight, left ? labelWidthWest : labelWidthEast, - charHeight + 1); - if (value != -1) { /* @@ -257,6 +258,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI int labelLength = fm.stringWidth(valueAsString); int xOffset = labelSpace - labelLength; g.setColor(Color.black); + int y = (yPos + (i * charHeight)) - (charHeight / 5); g.drawString(valueAsString, xOffset, y); } }