From 454161705924ab7eed29286b0d619577b38b7729 Mon Sep 17 00:00:00 2001 From: hansonr Date: Sun, 22 Jul 2018 13:11:46 -0500 Subject: [PATCH] PAL-3026 missing vertical numbers for wrapped pane --- src/jalview/gui/SeqCanvas.java | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) 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); -- 1.7.10.2