} catch (OutOfMemoryError er)
{
System.gc();
- System.err.println("SeqCanvas OutOfMemory Redraw Error.\n" + er);
- new OOMWarning("Creating alignment image for display", er);
-
- return;
+ 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();
}
}
+ }
- if (av.antiAlias)
+ /*
+ * Make a local image by combining the cached image img
+ * with any selection
+ */
+ private BufferedImage buildLocalImage(BufferedImage selectImage)
+ {
+ // clone the cached image
+ BufferedImage lcimg = new BufferedImage(img.getWidth(), img.getHeight(),
+ img.getType());
+ Graphics2D g2d = lcimg.createGraphics();
+ g2d.drawImage(img, 0, 0, null);
+
+ // overlay selection group on lcimg
+ if (selectImage != null)
{
- gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setComposite(
+ AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
+ g2d.drawImage(selectImage, 0, 0, this);
}
+ g2d.dispose();
- gg.setColor(Color.white);
- gg.fillRect(0, 0, imgWidth, imgHeight);
+ return lcimg;
+ }
- ViewportRanges ranges = av.getRanges();
- if (av.getWrapAlignment())
+ /*
+ * Set up a buffered image of the correct height and size for the sequence canvas
+ */
+ private BufferedImage setupImage()
+ {
+ BufferedImage lcimg = null;
+
+ int charWidth = av.getCharWidth();
+ int charHeight = av.getCharHeight();
-
++
+ int width = getWidth();
+ int height = getHeight();
+
+ width -= (width % charWidth);
+ height -= (height % charHeight);
+
+ if ((width < 1) || (height < 1))
{
- drawWrappedPanel(gg, getWidth(), getHeight(), ranges.getStartRes());
+ return null;
}
- else
+
+ try
{
- drawPanel(gg, ranges.getStartRes(), ranges.getEndRes(),
- ranges.getStartSeq(), ranges.getEndSeq(), 0);
- }
+ lcimg = new BufferedImage(width, height,
+ BufferedImage.TYPE_INT_ARGB); // ARGB so alpha compositing works
+ } catch (OutOfMemoryError er)
+ {
+ System.gc();
+ System.err.println(
+ "Group image OutOfMemory Redraw Error.\n" + er);
+ new OOMWarning("Creating alignment image for display", er);
- g.drawImage(lcimg, 0, 0, this);
+ return null;
+ }
+ return lcimg;
}
/**