From 729a8c88cedd23238c8370d12d4adbd8db78cde8 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 3 Sep 2018 14:42:17 +0100 Subject: [PATCH] JAL-3079 drop use of clip region while drawing wrapped alignment --- src/jalview/gui/SeqCanvas.java | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index dd87128..7606ee6 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -39,7 +39,6 @@ import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; -import java.awt.Shape; import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; import java.util.Iterator; @@ -418,6 +417,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI ranges.getEndRes(), ranges.getStartSeq(), ranges.getEndSeq()); g.drawImage(img, 0, 0, this); + gg.dispose(); } if (av.cursorMode) @@ -681,35 +681,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI + ((startColumn - ranges.getStartRes()) % viewportWidth) * charWidth; - // BH 2018 note: I have switched to using Graphics.create() here because it is - // more reliable (and simpler) to reset. The difference seems to be that SwingJS - // automatically sets a clipping region on an image to be the image dimensions, whereas - // Java sets no clip for an image. (A bug? Go figure!) - // Since we are using an off-screen BufferedImage here, the result is that g.getClip() - // returns non-null in JavaScript but not Java. - // - // Anyway, this works and, I suggest, is better design anyway. - // - // Graphics g = gg.create(); - // mc 30/08/18 undone because gnu.jpdf.PDFGraphics doesn't handle - // get/setTransform - g.translate(xOffset, 0); - // When printing we have an extra clipped region, - // the Printable page which we need to account for here - Shape clip = g.getClip(); - if (clip == null) - { - g.setClip(0, 0, viewportWidth * charWidth, canvasHeight); - } - else - { - g.setClip(0, (int) clip.getBounds().getY(), - viewportWidth * charWidth, (int) clip.getBounds().getHeight()); - } - - /* * white fill the region to be drawn (so incremental fast paint doesn't * scribble over an existing image) @@ -735,9 +708,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI startColumn, endx + 1); g.translate(0, -cHeight - ypos - 3); } - // g.dispose(); g.translate(-xOffset, 0); -// g.setClip(clip); } /** -- 1.7.10.2