From: kiramt Date: Wed, 7 Jun 2017 08:14:37 +0000 (+0100) Subject: JAL-2591 Overview window update interrupts X-Git-Tag: Release_2_10_3b1~132^2~21^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=63059e2e3f0f36f329c2c1fea59362cdd4391c72;p=jalview.git JAL-2591 Overview window update interrupts --- 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; + } + } }