X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSeqCanvas.java;h=a134afa67367e7bd49ecd2428c2dd68cf8eadf65;hb=9ba5a485b66e9c5a86b12dedc7b32616f3ef6db8;hp=d3ba304afd36ef45e66d244010ec2506d843cd02;hpb=27a5d5711de5fe3c324dc3d3ec625cd1596a1b62;p=jalview.git diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index d3ba304..a134afa 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -286,8 +286,6 @@ public class SeqCanvas extends JComponent implements ViewportListenerI fastpainting = true; fastPaint = true; updateViewport(); - gg.copyArea(horizontal * charWidth, vertical * charHeight, imgWidth, - imgHeight, -horizontal * charWidth, -vertical * charHeight); ViewportRanges ranges = av.getRanges(); int sr = ranges.getStartRes(); @@ -297,6 +295,9 @@ public class SeqCanvas extends JComponent implements ViewportListenerI int transX = 0; int transY = 0; + gg.copyArea(horizontal * charWidth, vertical * charHeight, imgWidth, + imgHeight, -horizontal * charWidth, -vertical * charHeight); + if (horizontal > 0) // scrollbar pulled right, image to the left { transX = (er - sr - horizontal) * charWidth; @@ -494,6 +495,9 @@ public class SeqCanvas extends JComponent implements ViewportListenerI FontMetrics fm = getFontMetrics(av.getFont()); + LABEL_EAST = 0; + LABEL_WEST = 0; + if (av.getScaleRightWrapped()) { LABEL_EAST = fm.stringWidth(getMask()); @@ -515,16 +519,16 @@ public class SeqCanvas extends JComponent implements ViewportListenerI av.setWrappedWidth(cWidth); - av.getRanges().setEndRes(av.getRanges().getStartRes() + cWidth - 1); + av.getRanges().setViewportStartAndWidth(startRes, cWidth); int endx; int ypos = hgap; - int maxwidth = av.getAlignment().getWidth() - 1; + int maxwidth = av.getAlignment().getWidth(); if (av.hasHiddenColumns()) { maxwidth = av.getAlignment().getHiddenColumns() - .findColumnPosition(maxwidth) - 1; + .findColumnPosition(maxwidth); } while ((ypos <= canvasHeight) && (startRes < maxwidth)) @@ -987,39 +991,50 @@ public class SeqCanvas extends JComponent implements ViewportListenerI @Override public void propertyChange(PropertyChangeEvent evt) { - if (!av.getWrapAlignment()) + String eventName = evt.getPropertyName(); + + if (av.getWrapAlignment()) { - if (evt.getPropertyName().equals("startres")) + if (eventName.equals(ViewportRanges.STARTRES)) + { + repaint(); + } + } + else + { + int scrollX = 0; + if (eventName.equals(ViewportRanges.STARTRES)) { - // scroll - startres and endres both change - // Make sure we're not trying to draw a panel // larger than the visible window ViewportRanges vpRanges = av.getRanges(); - int scrollX = (int) evt.getNewValue() - (int) evt.getOldValue(); - if (scrollX > vpRanges.getEndRes() - vpRanges.getStartRes()) + scrollX = (int) evt.getNewValue() - (int) evt.getOldValue(); + int range = vpRanges.getEndRes() - vpRanges.getStartRes(); + if (scrollX > range) { - scrollX = vpRanges.getEndRes() - vpRanges.getStartRes(); + scrollX = range; } - else if (scrollX < vpRanges.getStartRes() - vpRanges.getEndRes()) + else if (scrollX < -range) { - scrollX = vpRanges.getStartRes() - vpRanges.getEndRes(); + scrollX = -range; } - fastPaint(scrollX, 0); } - else if (evt.getPropertyName().equals("endres")) + + // Both scrolling and resizing change viewport ranges: scrolling changes + // both start and end points, but resize only changes end values. + // Here we only want to fastpaint on a scroll, with resize using a normal + // paint, so scroll events are identified as changes to the horizontal or + // vertical start value. + if (eventName.equals(ViewportRanges.STARTRES)) { - // resize - only endres changes + // scroll - startres and endres both change + fastPaint(scrollX, 0); } - else if (evt.getPropertyName().equals("startseq")) + else if (eventName.equals(ViewportRanges.STARTSEQ)) { // scroll fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue()); } - else if (evt.getPropertyName().equals("endseq")) - { - // resize - } } } }