From: kiramt Date: Tue, 29 Aug 2017 08:40:08 +0000 (+0100) Subject: JAL-2665 ported fix to 2.10.3. Doesn't work. X-Git-Tag: Release_2_10_3b1~140^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=daf0320a63cf578d009076b2c3c3c788f7c153af;p=jalview.git JAL-2665 ported fix to 2.10.3. Doesn't work. --- diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index b45ddef..49750a8 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -1100,7 +1100,7 @@ public class AlignmentPanel extends GAlignmentPanel implements * single graphics context), then reset to (0, scale height) */ alignmentGraphics.translate(alignmentGraphicsOffset, scaleHeight); - getSeqPanel().seqCanvas.drawPanelForPrint(alignmentGraphics, startRes, + getSeqPanel().seqCanvas.drawPanelForPrinting(alignmentGraphics, startRes, endRes, startSeq, endSeq); alignmentGraphics.translate(-alignmentGraphicsOffset, 0); @@ -1228,7 +1228,8 @@ public class AlignmentPanel extends GAlignmentPanel implements pg.translate(idWidth, 0); - getSeqPanel().seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, + getSeqPanel().seqCanvas.drawWrappedPanelForPrinting(pg, + pwidth - idWidth, totalHeight, 0); if ((pi * pheight) < totalHeight) diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 04ffc09..8004cac 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -426,7 +426,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI * @param endSeq * end sequence of print area */ - public void drawPanelForPrint(Graphics g1, int startRes, int endRes, + public void drawPanelForPrinting(Graphics g1, int startRes, int endRes, int startSeq, int endSeq) { BufferedImage selectImage = drawSelectionGroup(startRes, endRes, @@ -437,6 +437,37 @@ public class SeqCanvas extends JComponent implements ViewportListenerI g1.drawImage(selectImage, 0, 0, this); } + /** + * Draw a wrapped alignment panel for printing + * + * @param g + * Graphics object to draw with + * @param canvasWidth + * width of drawing area + * @param canvasHeight + * height of drawing area + * @param startRes + * start residue of print area + */ + public void drawWrappedPanelForPrinting(Graphics g, int canvasWidth, + int canvasHeight, int startRes) + { + SequenceGroup group = av.getSelectionGroup(); + BufferedImage selectImage = new BufferedImage(canvasWidth, canvasHeight, + BufferedImage.TYPE_INT_ARGB); // ARGB so alpha compositing works + + 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(); + } + } + /* * Make a local image by combining the cached image img * with any selection @@ -568,7 +599,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI * @param startRes * DOCUMENT ME! */ - public void drawWrappedPanel(Graphics g, int canvasWidth, + private void drawWrappedPanel(Graphics g, int canvasWidth, int canvasHeight, int startRes) { updateViewport(); @@ -1022,16 +1053,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI // set up drawing colour Graphics2D g = (Graphics2D) selectionImage.getGraphics(); - // set background to transparent - g.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f)); - g.fillRect(0, 0, selectionImage.getWidth(), selectionImage.getHeight()); - - // set up foreground to draw red dashed line - g.setComposite(AlphaComposite.Src); - g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, - BasicStroke.JOIN_ROUND, 3f, new float[] - { 5f, 3f }, 0f)); - g.setColor(Color.RED); + setupSelectionGroup(g, selectionImage); if (!av.getWrapAlignment()) { @@ -1049,6 +1071,24 @@ public class SeqCanvas extends JComponent implements ViewportListenerI } /* + * Set up graphics for selection group + */ + private void setupSelectionGroup(Graphics2D g, + BufferedImage selectionImage) + { + // set background to transparent + g.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f)); + g.fillRect(0, 0, selectionImage.getWidth(), selectionImage.getHeight()); + + // set up foreground to draw red dashed line + g.setComposite(AlphaComposite.Src); + g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, + BasicStroke.JOIN_ROUND, 3f, new float[] + { 5f, 3f }, 0f)); + g.setColor(Color.RED); + } + + /* * Draw a selection group over an unwrapped alignment * @param g graphics object to draw with * @param group selection group