From 48e7970c595ea8dbaa11e2244ac1b67d6c40d4aa Mon Sep 17 00:00:00 2001 From: kiramt Date: Wed, 7 Jun 2017 08:14:48 +0100 Subject: [PATCH] JAL-2591 Increased granularity of overview panel update checks --- src/jalview/gui/OverviewCanvas.java | 8 +++++++- src/jalview/renderer/OverviewRenderer.java | 29 ++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/jalview/gui/OverviewCanvas.java b/src/jalview/gui/OverviewCanvas.java index 6f9fbbf..27f9c3f 100644 --- a/src/jalview/gui/OverviewCanvas.java +++ b/src/jalview/gui/OverviewCanvas.java @@ -53,6 +53,8 @@ public class OverviewCanvas extends JComponent private OverviewDimensions od; + private OverviewRenderer or = null; + private AlignViewportI av; public OverviewCanvas(OverviewDimensions overviewDims, @@ -89,6 +91,10 @@ public class OverviewCanvas extends JComponent if (updaterunning) { restart = true; + if (or != null) + { + or.setRedraw(true); + } } else { @@ -120,7 +126,7 @@ public class OverviewCanvas extends JComponent setPreferredSize(new Dimension(od.getWidth(), od.getHeight())); - OverviewRenderer or = new OverviewRenderer(sr, fr, od); + or = new OverviewRenderer(sr, fr, od); miniMe = or.draw(od.getRows(av.getAlignment()), od.getColumns(av.getAlignment())); diff --git a/src/jalview/renderer/OverviewRenderer.java b/src/jalview/renderer/OverviewRenderer.java index 9291ca6..913c870 100644 --- a/src/jalview/renderer/OverviewRenderer.java +++ b/src/jalview/renderer/OverviewRenderer.java @@ -48,12 +48,14 @@ public class OverviewRenderer // raw number of pixels to allocate to each row private float pixelsPerSeq; + // flag to indicate whether to halt drawing + private boolean redraw = false; + public OverviewRenderer(jalview.api.SequenceRenderer seqRenderer, FeatureRenderer fr, OverviewDimensions od) - // FeatureColourFinder colfinder, OverviewDimensions od) { sr = seqRenderer; - finder = new FeatureColourFinder(fr); // colfinder; + finder = new FeatureColourFinder(fr); pixelsPerCol = od.getPixelsPerCol(); pixelsPerSeq = od.getPixelsPerSeq(); @@ -76,8 +78,14 @@ public class OverviewRenderer int rgbcolor = Color.white.getRGB(); int seqIndex = 0; int pixelRow = 0; + for (int alignmentRow : rows) { + if (redraw) + { + break; + } + // get details of this alignment row boolean hidden = rows.isHidden(alignmentRow); SequenceI seq = rows.getSequence(alignmentRow); @@ -90,6 +98,11 @@ public class OverviewRenderer int pixelCol = 0; for (int alignmentCol : cols) { + if (redraw) + { + break; + } + // calculate where this column extends to in pixels int endCol = Math.min( Math.round((colIndex + 1) * pixelsPerCol) - 1, @@ -171,6 +184,10 @@ public class OverviewRenderer int pixelCol = 0; for (int alignmentCol : cols) { + if (redraw) + { + break; + } if (alignmentCol >= annotations.length) { break; // no more annotations to draw here @@ -205,4 +222,12 @@ public class OverviewRenderer } } } + + public void setRedraw(boolean b) + { + synchronized (this) + { + redraw = b; + } + } } -- 1.7.10.2