From: kiramt Date: Tue, 27 Jun 2017 13:16:56 +0000 (+0100) Subject: JAL-2600 Abandoned fastpaint for resize; now full repaint, single call X-Git-Tag: Release_2_10_3b1~183^2^2~3 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=36c3c5a0883c68bb8b007bb392668977331f9f1a;p=jalview.git JAL-2600 Abandoned fastpaint for resize; now full repaint, single call --- diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 3dee5a8..1ba04b4 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -971,7 +971,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, * @param horizontal * repaint with horizontal shift in alignment */ - public void fastPaint(int horizontal, boolean isresize) + public void fastPaint(int horizontal) { if ((horizontal == 0) || gg == null || av.getAlignment().getAlignmentAnnotation() == null @@ -985,45 +985,20 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, int sr = av.getRanges().getStartRes(); int er = av.getRanges().getEndRes() + 1; int transX = 0; - long stime; - long mtime; - if (isresize) - { - imgWidth = (av.getRanges().getEndRes() - av.getRanges().getStartRes() - + 1) * av.getCharWidth(); - - if (imgWidth > 0) - { - BufferedImage newimage = new BufferedImage(imgWidth, - ap.getAnnotationPanel().getHeight(), - BufferedImage.TYPE_INT_ARGB); + long stime = System.currentTimeMillis(); + gg.copyArea(0, 0, imgWidth, getHeight(), + -horizontal * av.getCharWidth(), 0); + long mtime = System.currentTimeMillis(); - gg = (Graphics2D) newimage.getGraphics(); - gg.setFont(av.getFont()); - gg.drawImage(image, null, 0, 0); - image = newimage; - - transX = (er - horizontal - sr) * av.getCharWidth(); - sr = er - horizontal - sr; - } + if (horizontal > 0) // scrollbar pulled right, image to the left + { + transX = (er - sr - horizontal) * av.getCharWidth(); + sr = er - horizontal; } - else + else if (horizontal < 0) { - stime = System.currentTimeMillis(); - gg.copyArea(0, 0, imgWidth, getHeight(), - -horizontal * av.getCharWidth(), 0); - mtime = System.currentTimeMillis(); - - if (horizontal > 0) // scrollbar pulled right, image to the left - { - transX = (er - sr - horizontal) * av.getCharWidth(); - sr = er - horizontal; - } - else if (horizontal < 0) - { - er = sr - horizontal; - } + er = sr - horizontal; } gg.translate(transX, 0); @@ -1197,12 +1172,11 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, // Respond to viewport range changes (e.g. alignment panel was scrolled) if (evt.getPropertyName().equals("startres")) { - fastPaint((int) evt.getNewValue() - (int) evt.getOldValue(), false); + fastPaint((int) evt.getNewValue() - (int) evt.getOldValue()); } else if (evt.getPropertyName().equals("endres")) { - // resize - fastPaint((int) evt.getNewValue() - (int) evt.getOldValue(), true); + // resize - do nothing } } } diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index cfbc403..a8f3b24 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -153,7 +153,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI * @param vertical * DOCUMENT ME! */ - public void fastPaint(int vertical, boolean isresize) + public void fastPaint(int vertical) { if (gg == null) { @@ -171,37 +171,26 @@ public class IdCanvas extends JPanel implements ViewportListenerI int es = ranges.getEndSeq(); int transY = 0; - if (isresize) + if (vertical > 0) // scroll down { - if (vertical != 0) + ss = es - vertical; + + if (ss < ranges.getStartSeq()) + { // ie scrolling too fast, more than a page at a time + ss = ranges.getStartSeq(); + } + else { transY = imgHeight - ((vertical + 1) * av.getCharHeight()); - ss = es - vertical - ss; } } - else + else if (vertical < 0) // scroll up { - if (vertical > 0) // scroll down - { - ss = es - vertical; + es = ss - vertical; - if (ss < ranges.getStartSeq()) - { // ie scrolling too fast, more than a page at a time - ss = ranges.getStartSeq(); - } - else - { - transY = imgHeight - ((vertical + 1) * av.getCharHeight()); - } - } - else if (vertical < 0) // scroll up + if (es > ranges.getEndSeq()) { - es = ss - vertical; - - if (es > ranges.getEndSeq()) - { - es = ranges.getEndSeq(); - } + es = ranges.getEndSeq(); } } @@ -537,11 +526,11 @@ public class IdCanvas extends JPanel implements ViewportListenerI // Respond to viewport range changes (e.g. alignment panel was scrolled) if (evt.getPropertyName().equals("startseq")) { - fastPaint((int) evt.getNewValue() - (int) evt.getOldValue(), false); + fastPaint((int) evt.getNewValue() - (int) evt.getOldValue()); } else if (evt.getPropertyName().equals("endseq")) { - fastPaint((int) evt.getNewValue() - (int) evt.getOldValue(), true); + // resize - do nothing } } } diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 3cdba8d..9651a87 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -546,7 +546,10 @@ public class ScalePanel extends JPanel implements MouseMotionListener, public void propertyChange(PropertyChangeEvent evt) { // Respond to viewport change events (e.g. alignment panel was scrolled) - repaint(); + if (evt.getPropertyName().equals("startres")) + { + repaint(); + } } } diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index f1b473c..448dc6d 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -277,7 +277,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI * @param vertical * shift up or down in repaint */ - public void fastPaint(int horizontal, int vertical, boolean isresize) + public void fastPaint(int horizontal, int vertical) { if (fastpainting || gg == null) { @@ -295,71 +295,38 @@ public class SeqCanvas extends JComponent implements ViewportListenerI int transX = 0; int transY = 0; - if (isresize) - { - imgWidth = getWidth(); - imgHeight = getHeight(); - - imgWidth -= (imgWidth % charWidth); - imgHeight -= (imgHeight % charHeight); - - if ((imgWidth > 0) && (imgHeight > 0)) - { - BufferedImage newimg = new BufferedImage(imgWidth, imgHeight, - BufferedImage.TYPE_INT_ARGB); - - gg = (Graphics2D) newimg.getGraphics(); - gg.setFont(av.getFont()); - gg.drawImage(img, null, 0, 0); - img = newimg; + gg.copyArea(horizontal * charWidth, vertical * charHeight, imgWidth, + imgHeight, -horizontal * charWidth, -vertical * charHeight); - if (horizontal != 0) - { - transX = (er - horizontal - sr) * charWidth; - sr = er - horizontal - sr; - } - else if (vertical != 0) - { - transY = imgHeight - ((vertical + 1) * charHeight); - ss = es - vertical - ss; - } - } + if (horizontal > 0) // scrollbar pulled right, image to the left + { + transX = (er - sr - horizontal) * charWidth; + sr = er - horizontal; } - else + else if (horizontal < 0) + { + er = sr - horizontal; + } + else if (vertical > 0) // scroll down { - gg.copyArea(horizontal * charWidth, vertical * charHeight, imgWidth, - imgHeight, -horizontal * charWidth, -vertical * charHeight); + ss = es - vertical; - if (horizontal > 0) // scrollbar pulled right, image to the left - { - transX = (er - sr - horizontal) * charWidth; - sr = er - horizontal; + if (ss < ranges.getStartSeq()) + { // ie scrolling too fast, more than a page at a time + ss = ranges.getStartSeq(); } - else if (horizontal < 0) + else { - er = sr - horizontal; + transY = imgHeight - ((vertical + 1) * charHeight); } - else if (vertical > 0) // scroll down - { - ss = es - vertical; + } + else if (vertical < 0) + { + es = ss - vertical; - if (ss < ranges.getStartSeq()) - { // ie scrolling too fast, more than a page at a time - ss = ranges.getStartSeq(); - } - else - { - transY = imgHeight - ((vertical + 1) * charHeight); - } - } - else if (vertical < 0) + if (es > ranges.getEndSeq()) { - es = ss - vertical; - - if (es > ranges.getEndSeq()) - { - es = ranges.getEndSeq(); - } + es = ranges.getEndSeq(); } } @@ -1023,14 +990,14 @@ public class SeqCanvas extends JComponent implements ViewportListenerI { if (!av.getWrapAlignment()) { - if (evt.getPropertyName().equals("startres")) + int scrollX = 0; + if ((evt.getPropertyName().equals("startres")) + || (evt.getPropertyName().equals("endres"))) { - // scroll - startres and endres both change - // Make sure we're not trying to draw a panel // larger than the visible window ViewportRanges vpRanges = av.getRanges(); - int scrollX = (int) evt.getNewValue() - (int) evt.getOldValue(); + scrollX = (int) evt.getNewValue() - (int) evt.getOldValue(); if (scrollX > vpRanges.getEndRes() - vpRanges.getStartRes()) { scrollX = vpRanges.getEndRes() - vpRanges.getStartRes(); @@ -1039,24 +1006,27 @@ public class SeqCanvas extends JComponent implements ViewportListenerI { scrollX = vpRanges.getStartRes() - vpRanges.getEndRes(); } - fastPaint(scrollX, 0, false); + } + + if (evt.getPropertyName().equals("startres")) + { + // scroll - startres and endres both change + fastPaint(scrollX, 0); } else if (evt.getPropertyName().equals("endres")) { // resize - only endres changes - int scrollX = (int) evt.getNewValue() - (int) evt.getOldValue(); - fastPaint(scrollX, 0, true); + } else if (evt.getPropertyName().equals("startseq")) { // scroll - fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue(), false); + fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue()); } else if (evt.getPropertyName().equals("endseq")) { // resize - fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue(), - true); + } } }