From: kiramt Date: Tue, 29 Aug 2017 10:59:54 +0000 (+0100) Subject: JAL-2665 OOM checks just in case X-Git-Tag: Release_2_10_2b1~11^2~9^2~4^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fbug%2FJAL-2665-2.10.2b;p=jalview.git JAL-2665 OOM checks just in case --- diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 8d8aef3..3d8b8aa 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -461,20 +461,34 @@ public class SeqCanvas extends JComponent implements ViewportListenerI int canvasHeight, int startRes) { SequenceGroup group = av.getSelectionGroup(); - BufferedImage selectImage = new BufferedImage(canvasWidth, canvasHeight, - BufferedImage.TYPE_INT_ARGB); // ARGB so alpha compositing works + + drawWrappedPanel(g, canvasWidth, canvasHeight, startRes); if (group != null) { - Graphics2D g2 = selectImage.createGraphics(); - setupSelectionGroup(g2, selectImage); - drawWrappedSelection(g2, group, canvasWidth, canvasHeight, - startRes); - drawWrappedPanel(g, canvasWidth, canvasHeight, startRes); - g2.setComposite( - AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); - g.drawImage(selectImage, 0, 0, this); - g2.dispose(); + BufferedImage selectImage = null; + try + { + selectImage = new BufferedImage(canvasWidth, canvasHeight, + BufferedImage.TYPE_INT_ARGB); // ARGB so alpha compositing works + } catch (OutOfMemoryError er) + { + System.gc(); + System.err.println("Print image OutOfMemory Error.\n" + er); + new OOMWarning("Creating wrapped alignment image for printing", er); + } + if (selectImage != null) + { + Graphics2D g2 = selectImage.createGraphics(); + setupSelectionGroup(g2, selectImage); + drawWrappedSelection(g2, group, canvasWidth, canvasHeight, + startRes); + + g2.setComposite( + AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); + g.drawImage(selectImage, 0, 0, this); + g2.dispose(); + } } }