From 39e39119e514275f48786e592cc24c251d212c66 Mon Sep 17 00:00:00 2001 From: jprocter Date: Wed, 7 Nov 2007 11:55:03 +0000 Subject: [PATCH] attempt to make fastPaint method thread safe --- src/jalview/gui/AnnotationPanel.java | 18 +++++++++++------- src/jalview/gui/SeqCanvas.java | 16 +++++++++++----- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index afc09cc..07841d2 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -608,25 +608,30 @@ public class AnnotationPanel drawComponent(gg, av.startRes, av.endRes + 1); g.drawImage(image, 0, 0, this); } - + boolean fpainting=false; /** - * DOCUMENT ME! + * Thread safe repaint * - * @param horizontal DOCUMENT ME! + * @param horizontal repaint with horizontal shift in alignment */ public void fastPaint(int horizontal) { + + if (fpainting) + return; + fpainting=true; + if ( (horizontal == 0) || gg == null || av.alignment.getAlignmentAnnotation() == null || av.alignment.getAlignmentAnnotation().length < 1 || av.updatingConsensus - || av.updatingConservation) + || av.updatingConservation + ) // || fpainting) { repaint(); return; } - gg.copyArea(0, 0, imgWidth, getHeight(), -horizontal * av.charWidth, 0); int sr = av.startRes; @@ -650,9 +655,8 @@ public class AnnotationPanel gg.translate( -transX, 0); fastPaint = true; - repaint(); - + fpainting=false; } /** diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 389da75..cd7c231 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -209,15 +209,20 @@ public class SeqCanvas } } } - + boolean fastpainting=false; /** - * DOCUMENT ME! - * - * @param horizontal DOCUMENT ME! - * @param vertical DOCUMENT ME! + * need to make this thread safe + * move alignment rendering in response to slider adjustment + * @param horizontal shift along + * @param vertical shift up or down in repaint */ public void fastPaint(int horizontal, int vertical) { + if (fastpainting) + { + return; + } + fastpainting=true; if (gg == null) { return; @@ -277,6 +282,7 @@ public class SeqCanvas gg.translate( -transX, -transY); repaint(); + fastpainting=false; } /** -- 1.7.10.2