From 7adf677c44c311f7b45b552f8e1022ad8ae97ac4 Mon Sep 17 00:00:00 2001 From: James Procter Date: Tue, 12 Dec 2023 17:17:17 +0000 Subject: [PATCH] =?utf8?q?JAL-4217=20don=E2=80=99t=20try=20and=20export=20an?= =?utf8?q?=20image=20when=20Jmol=20is=20also=20trying=20to=20repaint?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/gui/AppJmol.java | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index 0aa4878..4d0de1b 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -421,6 +421,14 @@ public class AppJmol extends StructureViewerBase } + public boolean isRepainting() + { + if (renderPanel!=null && renderPanel.isVisible()) + { + return renderPanel.repainting; + } + return false; + } /** * Outputs the Jmol viewer image as an image file, after prompting the user to * choose a file and (for EPS) choice of Text or Lineart character rendering @@ -431,6 +439,13 @@ public class AppJmol extends StructureViewerBase @Override public void makePDBImage(ImageMaker.TYPE type) { + while (!isRepainting()) + { + try { + Thread.sleep(2); + } catch (Exception q) + {} + } try { makePDBImage(null, type, null, @@ -627,10 +642,17 @@ public class AppJmol extends StructureViewerBase } else { - jmb.jmolViewer.renderScreenImage(g, currentSize.width, - currentSize.height); + repainting=true; + synchronized (jmb) + { + jmb.jmolViewer.renderScreenImage(g, currentSize.width, + currentSize.height); + + } + repainting=false; } } + volatile boolean repainting=false; } @Override -- 1.7.10.2