}
try
{
- long tries = 1000;
- while (structureViewer.isBusy() && tries > 0)
+ int tries = 0;
+ int maxTries = 1000;
+ while (structureViewer.isBusy() && tries < maxTries)
{
- Thread.sleep(25);
- if (structureViewer.isBusy())
+ if (tries % 100 == 0)
{
- tries--;
Console.debug(
"Waiting for viewer for " + structureFilepath);
}
+ Thread.sleep(10);
+ tries++;
}
- if (tries == 0 && structureViewer.isBusy())
+ if (tries >= maxTries && structureViewer.isBusy())
{
addWarn("Gave up waiting for structure viewer to load file '"
+ structureFile
// we can do this with every viewer
//
+ boolean doContinue = false;
try
{
// We don't expect class cast exception
addError(
"Unexpected error when restoring structure viewer session after custom view operations.");
isError = true;
- continue;
+ doContinue = true;
} finally
{
try
{
+ // restore colour scheme
this.colourAlignFrame(af, originalColourScheme);
} catch (Exception t)
{
"Unexpected error when restoring colourscheme to alignment after temporary change for export.",
t);
}
+ if (doContinue)
+ {
+ continue;
+ }
}
}
}
// The main application logger
log = JLoggerLog4j.getLogger(Cache.JALVIEW_LOGGER_NAME, logLevel);
+
+ // Jmol logging. Reduce logging level for INFO.
+ int jmolLogLevel = org.jmol.util.Logger.LEVEL_INFO;
+ switch (logLevel)
+ {
+ case FATAL:
+ jmolLogLevel = org.jmol.util.Logger.LEVEL_FATAL;
+ break;
+ case ERROR:
+ jmolLogLevel = org.jmol.util.Logger.LEVEL_ERROR;
+ break;
+ case WARN:
+ jmolLogLevel = org.jmol.util.Logger.LEVEL_ERROR;
+ break;
+ case INFO:
+ jmolLogLevel = org.jmol.util.Logger.LEVEL_ERROR;
+ break;
+ case DEBUG:
+ jmolLogLevel = org.jmol.util.Logger.LEVEL_INFO;
+ break;
+ case TRACE:
+ jmolLogLevel = org.jmol.util.Logger.LEVEL_DEBUGHIGH;
+ break;
+ case ALL:
+ jmolLogLevel = org.jmol.util.Logger.LEVEL_MAX;
+ break;
+ }
+ org.jmol.util.Logger.setLogLevel(jmolLogLevel);
+ // org.jmol.util.Logger.setLogLevel(org.jmol.util.Logger.LEVEL_ERROR);
} catch (NoClassDefFoundError e)
{
jalview.bin.Console
import jalview.api.AlignmentViewPanel;
import jalview.bin.Console;
+import jalview.bin.Jalview;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.datamodel.StructureViewerModel;
float usescale = bis.scale();
int usewidth = bis.width();
int useheight = bis.height();
-
ImageWriterI writer = new ImageWriterI()
{
@Override
final Throwable[] exceptions = new Throwable[1];
exceptions[0] = null;
final AppJmol us = this;
+ Runnable exportRunnable = () -> {
+ try
+ {
+ exporter.doExport(file, us, width, height, view, renderer, userBis);
+ } catch (Throwable t)
+ {
+ Console.debug("Problem when exporting structure image", t);
+ exceptions[0] = t;
+ }
+ };
try
{
- Thread runner = Executors.defaultThreadFactory()
- .newThread(new Runnable()
- {
- @Override
- public void run()
- {
- try
- {
- exporter.doExport(file, us, width, height, view,
- renderer, userBis);
- } catch (Throwable t)
- {
- exceptions[0] = t;
- }
- }
- });
- runner.start();
- long time = 0;
- do
+ if (Jalview.isHeadlessMode())
{
- Thread.sleep(25);
- } while (runner.isAlive() && time++ < 4000);
- if (time >= 4000)
+ exportRunnable.run();
+ }
+ else
{
- runner.interrupt();
- throw new ImageOutputException(
- "Jmol took too long to export. Waited for 100 seconds.");
+ Thread runner = Executors.defaultThreadFactory()
+ .newThread(exportRunnable);
+ runner.start();
+ long time = 0;
+ do
+ {
+ Thread.sleep(25);
+ } 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)
{