From: hansonr Date: Thu, 28 Jun 2018 13:30:54 +0000 (+0100) Subject: Dialogs JAL-3032 X-Git-Tag: Develop-2_11_2_0-d20201215~24^2~68^2~619 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a61382b4118460b7891100b195d2aed1a42f6e10;hp=f0658706f2f846e5f776908b1df18c4d15318008;p=jalview.git Dialogs JAL-3032 --- diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 74af104..73a4dc6 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -89,7 +89,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI private int wrappedVisibleWidths; // number of wrapped widths displayed - private Graphics2D gg; + // Don't do this! Graphics handles are supposed to be transient + //private Graphics2D gg; /** * Creates a new SeqCanvas object. @@ -150,6 +151,7 @@ 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; @@ -196,6 +198,9 @@ public class SeqCanvas extends JPanel implements ViewportListenerI int yPos = ypos + charHeight; int startX = startx; int endX = endx; + + //System.out.println("v " + startx + " " + endx + " " + ypos); + if (av.hasHiddenColumns()) { @@ -240,7 +245,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) { /* @@ -254,6 +259,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); + } } } @@ -278,7 +286,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI */ public void fastPaint(int horizontal, int vertical) { - if (fastpainting || gg == null || img == null) + if (fastpainting || img == null) { return; } @@ -298,6 +306,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI int transX = 0; int transY = 0; + Graphics gg = img.getGraphics(); gg.copyArea(horizontal * charWidth, vertical * charHeight, img.getWidth(), img.getHeight(), -horizontal * charWidth, -vertical * charHeight); @@ -338,7 +347,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI gg.translate(transX, transY); drawPanel(gg, startRes, endRes, startSeq, endSeq, 0); gg.translate(-transX, -transY); - + gg.dispose(); + // Call repaint on alignment panel so that repaints from other alignment // panel components can be aggregated. Otherwise performance of the // overview window and others may be adversely affected. @@ -352,24 +362,23 @@ public class SeqCanvas extends JPanel implements ViewportListenerI @Override public void paintComponent(Graphics g) { - super.paintComponent(g); - + super.paintComponent(g); + int charHeight = av.getCharHeight(); int charWidth = av.getCharWidth(); - + ViewportRanges ranges = av.getRanges(); - + int width = getWidth(); int height = getHeight(); - + width -= (width % charWidth); height -= (height % charHeight); - + // selectImage is the selection group outline image - BufferedImage selectImage = drawSelectionGroup( - ranges.getStartRes(), ranges.getEndRes(), - ranges.getStartSeq(), ranges.getEndSeq()); - + BufferedImage selectImage = drawSelectionGroup(ranges.getStartRes(), + ranges.getEndRes(), ranges.getStartSeq(), ranges.getEndSeq()); + if ((img != null) && (fastPaint || (getVisibleRect().width != g.getClipBounds().width) || (getVisibleRect().height != g.getClipBounds().height))) @@ -390,19 +399,21 @@ public class SeqCanvas extends JPanel implements ViewportListenerI { return; } - gg = (Graphics2D) img.getGraphics(); - gg.setFont(av.getFont()); } - + + + Graphics2D gg = (Graphics2D) img.getGraphics(); + gg.setFont(av.getFont()); + if (av.antiAlias) { gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } - + gg.setColor(Color.white); gg.fillRect(0, 0, img.getWidth(), img.getHeight()); - + if (av.getWrapAlignment()) { drawWrappedPanel(gg, getWidth(), getHeight(), ranges.getStartRes()); @@ -412,7 +423,10 @@ public class SeqCanvas extends JPanel implements ViewportListenerI drawPanel(gg, ranges.getStartRes(), ranges.getEndRes(), ranges.getStartSeq(), ranges.getEndSeq(), 0); } - + + + gg.dispose(); + // lcimg is a local *copy* of img which we'll draw selectImage on top of BufferedImage lcimg = buildLocalImage(selectImage); g.drawImage(lcimg, 0, 0, this); @@ -851,6 +865,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI if (av.getScaleRightWrapped()) { int x = labelWidthWest + viewportWidth * charWidth; + + //System.out.println("shifting " + x); g.translate(x, 0); drawVerticalScale(g, startCol, endColumn, ypos, false); g.translate(-x, 0); @@ -1630,7 +1646,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI */ protected boolean drawMappedPositions(SearchResultsI results) { - if ((results == null) || (gg == null)) // JAL-2784 check gg is not null + if ((results == null) || (img == null)) // JAL-2784 check gg is not null { return false; } @@ -1702,9 +1718,11 @@ public class SeqCanvas extends JPanel implements ViewportListenerI } int transX = (firstCol - ranges.getStartRes()) * av.getCharWidth(); int transY = (firstSeq - ranges.getStartSeq()) * av.getCharHeight(); + Graphics gg = img.getGraphics(); gg.translate(transX, transY); drawPanel(gg, firstCol, lastCol, firstSeq, lastSeq, 0); gg.translate(-transX, -transY); + gg.dispose(); } return matchFound; @@ -1825,7 +1843,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI return; } - if (fastpainting || gg == null) + if (fastpainting || img == null) { return; } @@ -1835,6 +1853,9 @@ public class SeqCanvas extends JPanel implements ViewportListenerI try { + + Graphics gg = img.getGraphics(); + calculateWrappedGeometry(getWidth(), getHeight()); /* @@ -1863,6 +1884,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI */ drawWrappedDecorators(gg, ranges.getStartRes()); + gg.dispose(); + repaint(); } finally { @@ -1886,6 +1909,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI return; } + Graphics gg = img.getGraphics(); + ViewportRanges ranges = av.getRanges(); int viewportWidth = ranges.getViewportWidth(); int charWidth = av.getCharWidth(); @@ -1912,6 +1937,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI /* * white fill first to erase annotations */ + + gg.translate(xOffset, 0); gg.setColor(Color.white); gg.fillRect(labelWidthWest, ypos, @@ -1919,6 +1946,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI gg.translate(-xOffset, 0); drawWrappedWidth(gg, ypos, startRes, endRes, canvasHeight); + } /* @@ -1962,7 +1990,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI gg.setColor(Color.white); gg.fillRect(0, canvasHeight - heightBelow, getWidth(), heightBelow); } - } + gg.dispose(); + } /** * Shifts the visible alignment by the specified number of columns - left if @@ -1978,6 +2007,9 @@ public class SeqCanvas extends JPanel implements ViewportListenerI { return; } + + Graphics gg = img.getGraphics(); + int charWidth = av.getCharWidth(); int canvasHeight = getHeight(); @@ -2044,11 +2076,11 @@ public class SeqCanvas extends JPanel implements ViewportListenerI * charWidth, heightToCopy, widthToCopy, -wrappedRepeatHeightPx); } - y += wrappedRepeatHeightPx; xpos += viewportWidth; } } + gg.dispose(); } @@ -2064,7 +2096,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI */ protected boolean drawMappedPositionsWrapped(SearchResultsI results) { - if ((results == null) || (gg == null)) // JAL-2784 check gg is not null + if ((results == null) || (img == null)) // JAL-2784 check gg is not null { return false; } @@ -2099,6 +2131,9 @@ public class SeqCanvas extends JPanel implements ViewportListenerI int gapHeight = charHeight * (av.getScaleAboveWrapped() ? 2 : 1); + + Graphics gg = img.getGraphics(); + for (int seqNo = ranges.getStartSeq(); seqNo <= ranges .getEndSeq(); seqNo++) { @@ -2169,6 +2204,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI } } + gg.dispose(); + return matchFound; } diff --git a/swingjs/SwingJS-site.zip b/swingjs/SwingJS-site.zip index d409fac..144cfdb 100644 Binary files a/swingjs/SwingJS-site.zip and b/swingjs/SwingJS-site.zip differ