From: kiramt Date: Tue, 10 Oct 2017 13:34:50 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/features/JAL-2609fastPaintWrapped' X-Git-Tag: Release_2_10_3b1~91^2~6 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=79d9f7d16d1a5fe58ad2b91a0ee1a0bbe6938373;p=jalview.git Merge remote-tracking branch 'origin/features/JAL-2609fastPaintWrapped' into bug/JAL-2690attemptedmerge Conflicts: src/jalview/gui/SeqCanvas.java --- 79d9f7d16d1a5fe58ad2b91a0ee1a0bbe6938373 diff --cc src/jalview/gui/SeqCanvas.java index 70ac11f,22e2fe4..2eb8c4d --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@@ -478,84 -386,35 +478,84 @@@ public class SeqCanvas extends JCompone } 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; } /**