}
+ 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
@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(),
}
public void makePDBImage(File file, ImageMaker.TYPE type, String renderer,
- BitmapImageSizing userBis, List<String> extraCommands)
- throws ImageOutputException
+ BitmapImageSizing userBis) throws ImageOutputException
{
int width = getWidth();
int height = getHeight();
}
}
- 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")
}
});
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(
}
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