if (image == null || imgWidth != image.getWidth(this)
|| image.getHeight(this) != getHeight())
{
- try
- {
- image = new BufferedImage(imgWidth,
- ap.getAnnotationPanel().getHeight(),
- BufferedImage.TYPE_INT_RGB);
- } catch (OutOfMemoryError oom)
+ boolean tried = false;
+ image = null;
+ while (image == null && !tried)
{
try
{
- System.gc();
- } catch (Exception x)
+ image = new BufferedImage(imgWidth,
+ ap.getAnnotationPanel().getHeight(),
+ BufferedImage.TYPE_INT_RGB);
+ tried = true;
+ } catch (IllegalArgumentException exc)
{
+ System.err.println(
+ "Serious issue with viewport geometry imgWidth requested was "
+ + imgWidth);
+ return;
+ } catch (OutOfMemoryError oom)
+ {
+ try
+ {
+ System.gc();
+ } catch (Exception x)
+ {
+ }
+ ;
+ new OOMWarning(
+ "Couldn't allocate memory to redraw screen. Please restart Jalview",
+ oom);
+ return;
}
- ;
- new OOMWarning(
- "Couldn't allocate memory to redraw screen. Please restart Jalview",
- oom);
- return;
+
}
gg = (Graphics2D) image.getGraphics();