+ try\r
+ {\r
+ // We'll have to draw the full size alignment in chunks, as an image of the\r
+ // whole alignment requires too much memory\r
+ // Max size depends on the font size, the following is a\r
+ // guess at a size which works\r
+ int maxSize = 2000 / av.getFont().getSize();\r
+ BufferedImage block;\r
+ int blockx = 0;\r
+ int blocky = 0;\r
+ int blockw = 0;\r
+ int blockh = 0;\r
+ int eRes = 0;\r
+ int eSeq = 0;\r
+\r
+ av.setRenderGaps(false);\r
+\r
+ for (int sRes = 0, chunkx = 0; sRes < alwidth;\r
+ sRes += maxSize, chunkx++)\r
+ {\r
+ eSeq = 0;\r
+ eRes += maxSize;\r
+\r
+ if (eRes > alwidth)\r
+ {\r
+ eRes = alwidth;\r
+ }\r
+\r
+ for (int sSeq = 0, chunky = 0; sSeq < alheight;\r
+ sSeq += maxSize, chunky++)\r
+ {\r
+ eSeq += maxSize;\r
+\r
+ if (eSeq > alheight)\r
+ {\r
+ eSeq = alheight;\r
+ }\r
+\r
+ blocky = 0;\r
+ blockx = (int) ((float) sRes / (float) alwidth * width);\r
+\r
+ block = new BufferedImage((eRes - sRes) * av.charWidth,\r
+ (eSeq - sSeq) * av.charHeight,\r
+ BufferedImage.TYPE_3BYTE_BGR);\r
+ g = block.getGraphics();\r
+\r
+ ap.seqPanel.seqCanvas.drawPanel(g, sRes, eRes, sSeq, eSeq,\r
+ sRes, sSeq, 0);\r
+\r
+ blockh = (int) ((float) (eSeq - sSeq) / (float) alheight * sequencesHeight) +\r
+ 1;\r
+ blockw = (int) ((float) (eRes - sRes) / (float) alwidth * width) +\r
+ 1;\r
+\r
+ blocky += (int) ((float) sSeq / (float) alheight * sequencesHeight);\r
+\r
+ mg.drawImage(block, blockx, blocky, blockx + blockw,\r
+ blocky + blockh, 0, 0, block.getWidth(),\r
+ block.getHeight(), this);\r
+\r
+ block = null;\r
+ }\r
+ }\r
+ }\r
+ catch (OutOfMemoryError error)\r
+ {\r
+ System.err.println(\r
+ "Out of memory when trying to calculate the overview window image!");\r
+ }\r