X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSeqCanvas.java;h=d7d9ccb7a801a31ac07fc87b4f758ef76c604710;hb=8de672a19aa66c59e84511da1961dd35397c02cb;hp=4861bd5640311d0a2d5fa28ab3af2ff1af5fae4e;hpb=adf7ce928faa801045db27cb7fb998821b5eb5f1;p=jalview.git diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 4861bd5..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); @@ -1567,20 +1575,42 @@ public class SeqCanvas extends JPanel implements ViewportListenerI * Highlights search results in the visible region by rendering as white text * on a black background. Any previous highlighting is removed. Answers true * if any highlight was left on the visible alignment (so status bar should be + * set to match), else false. This method does _not_ set the 'fastPaint' flag, + * so allows the next repaint to update the whole display. + * + * @param results + * @return + */ + public boolean highlightSearchResults(SearchResultsI results) + { + return highlightSearchResults(results, false); + + } + + /** + * Highlights search results in the visible region by rendering as white text + * on a black background. Any previous highlighting is removed. Answers true + * if any highlight was left on the visible alignment (so status bar should be * set to match), else false. *

- * Currently fastPaint is not implemented for wrapped alignments. If a wrapped - * alignment had to be scrolled to show the highlighted region, then it should - * be fully redrawn, otherwise a fast paint can be performed. This argument - * could be removed if fast paint of scrolled wrapped alignment is coded in - * future (JAL-2609). + * Optionally, set the 'fastPaint' flag for a faster redraw if only the + * highlighted regions are modified. This speeds up highlighting across linked + * alignments. + *

+ * Currently fastPaint is not implemented for scrolled wrapped alignments. If + * a wrapped alignment had to be scrolled to show the highlighted region, then + * it should be fully redrawn, otherwise a fast paint can be performed. This + * argument could be removed if fast paint of scrolled wrapped alignment is + * coded in future (JAL-2609). * * @param results - * @param noFastPaint + * @param doFastPaint + * if true, sets a flag so the next repaint only redraws the modified + * image * @return */ public boolean highlightSearchResults(SearchResultsI results, - boolean noFastPaint) + boolean doFastPaint) { if (fastpainting) { @@ -1589,7 +1619,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI boolean wrapped = av.getWrapAlignment(); try { - fastPaint = !noFastPaint; + fastPaint = doFastPaint; fastpainting = fastPaint; /*