X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSeqCanvas.java;h=b6b0d2971a3f7c416e4b8d4e4fa24ce534080027;hb=2dc113b7f55163a5948375d6965f428276a57593;hp=7ecedf4647772df2f3934e7584b7f419f2813a18;hpb=6f0b432ac19ed1d0d5e01a834586dc81b8a6a72d;p=jalview.git diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 7ecedf4..b6b0d29 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -151,7 +151,6 @@ public class SeqCanvas extends JPanel implements ViewportListenerI for (ScaleMark mark : marks) { int mpos = mark.column; // (i - startx - 1) -// System.out.println("n " + mpos + " " + ypos); if (mpos < 0) { continue; @@ -199,9 +198,6 @@ public class SeqCanvas extends JPanel implements ViewportListenerI int startX = startx; int endX = endx; - //System.out.println("v " + startx + " " + endx + " " + ypos); - - if (av.hasHiddenColumns()) { HiddenColumns hiddenColumns = av.getAlignment().getHiddenColumns(); @@ -237,6 +233,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI } } + /* * white fill the space for the scale */ @@ -245,7 +242,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI // fillRect origin is top left of rectangle g.fillRect(0, y - charHeight, left ? labelWidthWest : labelWidthEast, charHeight + 1); - + if (value != -1) { /* @@ -259,11 +256,9 @@ public class SeqCanvas extends JPanel implements ViewportListenerI int xOffset = labelSpace - labelLength; g.setColor(Color.black); g.drawString(valueAsString, xOffset, y); - - //System.out.println("v " + valueAsString + " " + xOffset + " " + y); - } } + } /** @@ -672,7 +667,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI calculateWrappedGeometry(canvasWidth, canvasHeight); /* - * draw one width at a time (including any scales or annotation shown), + * draw one width at a time (excluding any scales or annotation shown), * until we have run out of either alignment or vertical space available */ int ypos = wrappedSpaceAboveAlignment; @@ -723,7 +718,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI */ wrappedRepeatHeightPx = wrappedSpaceAboveAlignment; // add sequences - wrappedRepeatHeightPx += av.getRanges().getViewportHeight() + wrappedRepeatHeightPx += av.getAlignment().getHeight() * charHeight; // add annotations panel height if shown wrappedRepeatHeightPx += getAnnotationHeight(); @@ -787,12 +782,25 @@ public class SeqCanvas extends JPanel implements ViewportListenerI int xOffset = labelWidthWest + ((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); @@ -803,6 +811,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI viewportWidth * charWidth, (int) clip.getBounds().getHeight()); } + /* * white fill the region to be drawn (so incremental fast paint doesn't * scribble over an existing image) @@ -828,8 +837,9 @@ public class SeqCanvas extends JPanel implements ViewportListenerI startColumn, endx + 1); g.translate(0, -cHeight - ypos - 3); } - g.setClip(clip); + // g.dispose(); g.translate(-xOffset, 0); +// g.setClip(clip); } /** @@ -844,6 +854,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI int charWidth = av.getCharWidth(); g.setFont(av.getFont()); + g.setColor(Color.black); int ypos = wrappedSpaceAboveAlignment; @@ -866,7 +877,6 @@ public class SeqCanvas extends JPanel implements ViewportListenerI { int x = labelWidthWest + viewportWidth * charWidth; - //System.out.println("shifting " + x); g.translate(x, 0); drawVerticalScale(g, startCol, endColumn, ypos, false); g.translate(-x, 0);