From 7e441a4a9594821ec56539b29cb3b8a13bfa3c65 Mon Sep 17 00:00:00 2001 From: kiramt Date: Mon, 16 Oct 2017 14:31:39 +0100 Subject: [PATCH] JAL-2775 added repaint clipping --- src/jalview/gui/OverviewCanvas.java | 22 ++++++++++++---------- src/jalview/gui/OverviewPanel.java | 18 +++++++++++++++++- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/jalview/gui/OverviewCanvas.java b/src/jalview/gui/OverviewCanvas.java index 7371eb5..2991889 100644 --- a/src/jalview/gui/OverviewCanvas.java +++ b/src/jalview/gui/OverviewCanvas.java @@ -183,6 +183,8 @@ public class OverviewCanvas extends JComponent @Override public void paintComponent(Graphics g) { + // super.paintComponent(g); + if (restart) { if (lastMiniMe == null) @@ -204,7 +206,8 @@ public class OverviewCanvas extends JComponent && ((getWidth() != od.getWidth()) || (getHeight() != od.getHeight()))) { - // if there is annotation, scale the alignment and annotation separately + // if there is annotation, scale the alignment and annotation + // separately if (od.getGraphHeight() > 0) { BufferedImage topImage = lastMiniMe.getSubimage(0, 0, @@ -235,25 +238,24 @@ public class OverviewCanvas extends JComponent od.setHeight(getHeight()); } - // scale lastMiniMe to the new size - g.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this); - // make sure the box is in the right place od.setBoxPosition(av.getAlignment().getHiddenSequences(), av.getAlignment().getHiddenColumns()); } - else // not a resize - { - // fall back to normal behaviour - g.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this); - } + // fall back to normal behaviour + g.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this); } - + else + { + g.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this); + } + // draw the box g.setColor(Color.red); od.drawBox(g); } + public void dispose() { dispose = true; diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 51d7a84..4145fbf 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -327,6 +327,22 @@ public class OverviewPanel extends JPanel * changed * */ + private void setBoxPositionOnly() + { + if (od != null) + { + int oldX = od.getBoxX(); + int oldY = od.getBoxY(); + int oldWidth = od.getBoxWidth(); + int oldHeight = od.getBoxHeight(); + od.setBoxPosition(av.getAlignment().getHiddenSequences(), + av.getAlignment().getHiddenColumns()); + repaint(oldX - 1, oldY - 1, oldWidth + 2, oldHeight + 2); + repaint(od.getBoxX(), od.getBoxY(), od.getBoxWidth(), + od.getBoxHeight()); + } + } + private void setBoxPosition() { if (od != null) @@ -340,7 +356,7 @@ public class OverviewPanel extends JPanel @Override public void propertyChange(PropertyChangeEvent evt) { - setBoxPosition(); + setBoxPositionOnly(); } /** -- 1.7.10.2