X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAppJmol.java;h=0aa4878d9263504541fa8bacf8f8a5ea6a76d328;hb=HEAD;hp=5b935b7d6c18dc70ea019df099d8eedef5e03d20;hpb=14488926488f05f802480c508da1cc4ed53c5b1a;p=jalview.git diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index 5b935b7..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,10 +439,17 @@ 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, - BitmapImageSizing.defaultBitmapImageSizing(), null); + BitmapImageSizing.defaultBitmapImageSizing()); } catch (ImageOutputException ioex) { Console.error("Unexpected error whilst writing " + type.toString(), @@ -443,8 +458,7 @@ public class AppJmol extends StructureViewerBase } public void makePDBImage(File file, ImageMaker.TYPE type, String renderer, - BitmapImageSizing userBis, List extraCommands) - throws ImageOutputException + BitmapImageSizing userBis) throws ImageOutputException { int width = getWidth(); int height = getHeight(); @@ -473,24 +487,8 @@ public class AppJmol extends StructureViewerBase } } - String saveStateNameTemp = "JalviewSaveStateTemp"; - jmb.executeCommand( - new StructureCommand("save STATE " + saveStateNameTemp), - false); - - if (extraCommands != null) - { - for (String cmd : extraCommands) - { - jmb.executeCommand(new StructureCommand(cmd), false); - } - } - jmb.jmolViewer.requestRepaintAndWait("image export"); jmb.jmolViewer.renderScreenImage(ig2, usewidth, useheight); - jmb.executeCommand( - new StructureCommand("restore STATE " + saveStateNameTemp), - false); } }; String view = MessageManager.getString("action.view") @@ -520,10 +518,17 @@ public class AppJmol extends StructureViewerBase } }); runner.start(); + long time = 0; do { Thread.sleep(25); - } while (runner.isAlive()); + } while (runner.isAlive() && time++ < 4000); + if (time >= 4000) + { + runner.interrupt(); + throw new ImageOutputException( + "Jmol took too long to export. Waited for 100 seconds."); + } } catch (Throwable e) { throw new ImageOutputException( @@ -637,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