X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSeqCanvas.java;h=9de545261cec93715152ed7c8e92860e1fa6e585;hb=67affee2e65ca942447570c35526c04d64f41fe1;hp=b96c49189127c89c003ce272cda6303098fe204c;hpb=5e8ec77d921ff2d604811e5e4ba7e9211b0f48de;p=jalview.git diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index b96c491..9de5452 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -37,6 +37,7 @@ import java.awt.Graphics; import java.awt.Image; import java.awt.Panel; import java.beans.PropertyChangeEvent; +import java.util.List; public class SeqCanvas extends Panel implements ViewportListenerI { @@ -419,6 +420,9 @@ public class SeqCanvas extends Panel implements ViewportListenerI FontMetrics fm = getFontMetrics(av.getFont()); + LABEL_EAST = 0; + LABEL_WEST = 0; + if (av.getScaleRightWrapped()) { LABEL_EAST = fm.stringWidth(getMask()); @@ -440,17 +444,17 @@ public class SeqCanvas extends Panel 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)) @@ -487,11 +491,10 @@ public class SeqCanvas extends Panel implements ViewportListenerI HiddenColumns hidden = av.getAlignment().getHiddenColumns(); g.setColor(Color.blue); int res; - for (int i = 0; i < hidden.getHiddenRegions() - .size(); i++) + List positions = hidden.findHiddenRegionPositions(); + for (int pos : positions) { - res = hidden.findHiddenRegionPosition(i) - - startRes; + res = pos - startRes; if (res < 0 || res > endx - startRes) { @@ -570,7 +573,7 @@ public class SeqCanvas extends Panel implements ViewportListenerI if (av.hasHiddenColumns()) { HiddenColumns hidden = av.getAlignment().getHiddenColumns(); - for (int[] region : hidden) + for (int[] region : hidden.getHiddenColumnsCopy()) { int hideStart = region[0]; int hideEnd = region[1]; @@ -873,32 +876,44 @@ public class SeqCanvas extends Panel implements ViewportListenerI @Override public void propertyChange(PropertyChangeEvent evt) { + String eventName = evt.getPropertyName(); + if (!av.getWrapAlignment()) { - if (evt.getPropertyName().equals("startres") - || evt.getPropertyName().equals("endres")) + int scrollX = 0; + if (eventName.equals(ViewportRanges.STARTRES)) { // 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; } + } + + // 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)) + { + // scroll - startres and endres both change fastPaint(scrollX, 0); } - else if (evt.getPropertyName().equals("startseq") - || evt.getPropertyName().equals("endseq")) + else if (eventName.equals(ViewportRanges.STARTSEQ)) { + // scroll fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue()); } } - } }