From: kiramt Date: Fri, 3 Nov 2017 10:50:57 +0000 (+0000) Subject: JAL-2778 Changed local repaint to alignment repaint for fastpaints X-Git-Tag: Release_2_10_4~67^2~12 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2131bbe62dd921c47cf5f117fa4e441c9be0f554;p=jalview.git JAL-2778 Changed local repaint to alignment repaint for fastpaints --- diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 3a1dbe8..8d0fefb 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -874,18 +874,9 @@ public class AlignmentPanel extends GAlignmentPanel implements @Override public void paintComponent(Graphics g) { - invalidate(); - Dimension d = getIdPanel().getIdCanvas().getPreferredSize(); idPanelHolder.setPreferredSize(d); hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12)); - validate(); - - /* - * set scroll bar positions - */ - ViewportRanges ranges = av.getRanges(); - setScrollValues(ranges.getStartRes(), ranges.getStartSeq()); } /** diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index abe92bb..0d86b07 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -961,7 +961,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, gg.fillRect(0, 0, imgWidth, image.getHeight()); imageFresh = true; } - + drawComponent(gg, av.getRanges().getStartRes(), av.getRanges().getEndRes() + 1); imageFresh = false; @@ -1014,7 +1014,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, gg.translate(-transX, 0); fastPaint = true; - repaint(); + + av.getAlignPanel().alignFrame.repaint(); } private volatile boolean lastImageGood = false; diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index ae13444..1ee281a 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -204,7 +204,8 @@ public class IdCanvas extends JPanel implements ViewportListenerI gg.translate(0, -transY); fastPaint = true; - repaint(); + + av.getAlignPanel().alignFrame.repaint(); } /** @@ -220,39 +221,39 @@ public class IdCanvas extends JPanel implements ViewportListenerI g.setColor(Color.white); g.fillRect(0, 0, getWidth(), getHeight()); - + if (fastPaint) { fastPaint = false; g.drawImage(image, 0, 0, this); - + return; } - + int oldHeight = imgHeight; - + imgHeight = getHeight(); imgHeight -= (imgHeight % av.getCharHeight()); - + if (imgHeight < 1) { return; } - + if (oldHeight != imgHeight || image.getWidth(this) != getWidth()) { image = new BufferedImage(getWidth(), imgHeight, BufferedImage.TYPE_INT_RGB); } - + gg = (Graphics2D) image.getGraphics(); - + // Fill in the background gg.setColor(Color.white); gg.fillRect(0, 0, getWidth(), imgHeight); - + drawIds(av.getRanges().getStartSeq(), av.getRanges().getEndSeq()); - + g.drawImage(image, 0, 0, this); } diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 76611a1..e9cb04f 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -555,7 +555,7 @@ public class ScalePanel extends JPanel || evt.getPropertyName().equals(ViewportRanges.STARTRESANDSEQ)) { // scroll event, repaint panel - repaint(); + av.getAlignPanel().alignFrame.repaint(); } } diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 7724592..a717a17 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -337,7 +337,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI drawPanel(gg, startRes, endRes, startSeq, endSeq, 0); gg.translate(-transX, -transY); - repaint(); + av.getAlignPanel().alignFrame.repaint(); } finally { fastpainting = false; @@ -351,20 +351,20 @@ public class SeqCanvas extends JComponent implements ViewportListenerI int charHeight = av.getCharHeight(); int charWidth = av.getCharWidth(); - + ViewportRanges ranges = av.getRanges(); - + int width = getWidth(); int height = getHeight(); - + width -= (width % charWidth); height -= (height % charHeight); - + // selectImage is the selection group outline image BufferedImage selectImage = drawSelectionGroup( ranges.getStartRes(), ranges.getEndRes(), ranges.getStartSeq(), ranges.getEndSeq()); - + if ((img != null) && (fastPaint || (getVisibleRect().width != g.getClipBounds().width) || (getVisibleRect().height != g.getClipBounds().height))) @@ -388,16 +388,16 @@ public class SeqCanvas extends JComponent implements ViewportListenerI gg = (Graphics2D) img.getGraphics(); gg.setFont(av.getFont()); } - + if (av.antiAlias) { gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } - + gg.setColor(Color.white); gg.fillRect(0, 0, img.getWidth(), img.getHeight()); - + if (av.getWrapAlignment()) { drawWrappedPanel(gg, getWidth(), getHeight(), ranges.getStartRes()); @@ -407,7 +407,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI drawPanel(gg, ranges.getStartRes(), ranges.getEndRes(), ranges.getStartSeq(), ranges.getEndSeq(), 0); } - + // lcimg is a local *copy* of img which we'll draw selectImage on top of BufferedImage lcimg = buildLocalImage(selectImage); g.drawImage(lcimg, 0, 0, this);