From: hansonr Date: Sun, 22 Jul 2018 18:11:46 +0000 (-0500) Subject: PAL-3026 missing vertical numbers for wrapped pane X-Git-Tag: Release_2_11_4_0~45^2~18^2~517 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=454161705924ab7eed29286b0d619577b38b7729;p=jalview.git PAL-3026 missing vertical numbers for wrapped pane --- diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 7ecedf4..d7d9ccb 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); - } } + } /** @@ -770,7 +765,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI * @param endColumn * @param canvasHeight */ - protected void drawWrappedWidth(Graphics g, int ypos, int startColumn, + protected void drawWrappedWidth(Graphics gg, int ypos, int startColumn, int endColumn, int canvasHeight) { ViewportRanges ranges = av.getRanges(); @@ -787,12 +782,23 @@ 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(); + 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 +809,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 +835,9 @@ public class SeqCanvas extends JPanel implements ViewportListenerI startColumn, endx + 1); g.translate(0, -cHeight - ypos - 3); } - g.setClip(clip); - g.translate(-xOffset, 0); + g.dispose(); +// g.translate(-xOffset, 0); +// g.setClip(clip); } /** @@ -844,6 +852,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 +875,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);