X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSeqCanvas.java;h=3b79f1200d6298b91017742d9a8deab340224e90;hb=692669611f7244598bd34df92e8a3e5cbaf9bd2e;hp=b499a7486e95c61aead93f41d821b6358a98492b;hpb=8213e48c6973494f7a6e22e1a97290520a461d1b;p=jalview.git diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index b499a74..3b79f12 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -22,10 +22,10 @@ package jalview.appletgui; import jalview.datamodel.AlignmentI; import jalview.datamodel.HiddenColumns; -import jalview.datamodel.HiddenColumns.VisibleBlocksVisBoundsIterator; import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.datamodel.VisibleContigsIterator; import jalview.renderer.ScaleRenderer; import jalview.renderer.ScaleRenderer.ScaleMark; import jalview.viewmodel.AlignmentViewport; @@ -40,6 +40,7 @@ import java.awt.Panel; import java.beans.PropertyChangeEvent; import java.util.Iterator; +@SuppressWarnings("serial") public class SeqCanvas extends Panel implements ViewportListenerI { FeatureRenderer fr; @@ -131,16 +132,9 @@ public class SeqCanvas extends Panel implements ViewportListenerI if (av.hasHiddenColumns()) { startx = av.getAlignment().getHiddenColumns() - .adjustForHiddenColumns(startx); + .visibleToAbsoluteColumn(startx); endx = av.getAlignment().getHiddenColumns() - .adjustForHiddenColumns(endx); - } - - int maxwidth = av.getAlignment().getWidth(); - if (av.hasHiddenColumns()) - { - maxwidth = av.getAlignment().getHiddenColumns() - .findColumnPosition(maxwidth) - 1; + .visibleToAbsoluteColumn(endx); } // WEST SCALE @@ -181,7 +175,7 @@ public class SeqCanvas extends Panel implements ViewportListenerI if (av.hasHiddenColumns()) { endx = av.getAlignment().getHiddenColumns() - .adjustForHiddenColumns(endx); + .visibleToAbsoluteColumn(endx); } SequenceI seq; @@ -418,71 +412,65 @@ public class SeqCanvas extends Panel implements ViewportListenerI int canvasHeight, int startRes) { AlignmentI al = av.getAlignment(); - + FontMetrics fm = getFontMetrics(av.getFont()); - + LABEL_EAST = 0; LABEL_WEST = 0; - + if (av.getScaleRightWrapped()) { LABEL_EAST = fm.stringWidth(getMask()); } - + if (av.getScaleLeftWrapped()) { LABEL_WEST = fm.stringWidth(getMask()); } - + int hgap = avcharHeight; if (av.getScaleAboveWrapped()) { hgap += avcharHeight; } - + int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / avcharWidth; int cHeight = av.getAlignment().getHeight() * avcharHeight; - + av.setWrappedWidth(cWidth); - + av.getRanges().setViewportStartAndWidth(startRes, cWidth); - + int endx; int ypos = hgap; - - int maxwidth = av.getAlignment().getWidth(); - - if (av.hasHiddenColumns()) - { - maxwidth = av.getAlignment().getHiddenColumns() - .findColumnPosition(maxwidth); - } - + + int maxwidth = av.getAlignment().getVisibleWidth(); + while ((ypos <= canvasHeight) && (startRes < maxwidth)) { endx = startRes + cWidth - 1; - + if (endx > maxwidth) { endx = maxwidth; } - + g.setColor(Color.black); - + if (av.getScaleLeftWrapped()) { drawWestScale(g, startRes, endx, ypos); } - + if (av.getScaleRightWrapped()) { g.translate(canvasWidth - LABEL_EAST, 0); drawEastScale(g, startRes, endx, ypos); g.translate(-(canvasWidth - LABEL_EAST), 0); } - + g.translate(LABEL_WEST, 0); - + if (av.getScaleAboveWrapped()) { drawNorthScale(g, startRes, endx, ypos); @@ -492,27 +480,31 @@ public class SeqCanvas extends Panel implements ViewportListenerI HiddenColumns hidden = av.getAlignment().getHiddenColumns(); g.setColor(Color.blue); int res; - Iterator it = hidden.getBoundedStartIterator(startRes, + Iterator it = hidden.getStartRegionIterator(startRes, endx + 1); while (it.hasNext()) { res = it.next() - startRes; gg.fillPolygon( new int[] - { res * avcharWidth - avcharHeight / 4, res * avcharWidth + avcharHeight / 4, res * avcharWidth }, + { res * avcharWidth - avcharHeight / 4, + res * avcharWidth + avcharHeight / 4, + res * avcharWidth }, new int[] - { ypos - (avcharHeight / 2), ypos - (avcharHeight / 2), ypos - (avcharHeight / 2) + 8 }, 3); + { ypos - (avcharHeight / 2), ypos - (avcharHeight / 2), + ypos - (avcharHeight / 2) + 8 }, + 3); } } - + if (g.getClip() == null) { g.setClip(0, 0, cWidth * avcharWidth, canvasHeight); } - + drawPanel(g, startRes, endx, 0, al.getHeight() - 1, ypos); g.setClip(null); - + if (av.isShowAnnotation()) { g.translate(0, cHeight + ypos + 4); @@ -520,17 +512,17 @@ public class SeqCanvas extends Panel implements ViewportListenerI { annotations = new AnnotationPanel(av); } - + annotations.drawComponent(g, startRes, endx + 1); g.translate(0, -cHeight - ypos - 4); } g.translate(-LABEL_WEST, 0); - + ypos += cHeight + getAnnotationHeight() + hgap; - + startRes += cWidth; } - + } AnnotationPanel annotations; @@ -565,8 +557,8 @@ public class SeqCanvas extends Panel implements ViewportListenerI int blockEnd; HiddenColumns hidden = av.getAlignment().getHiddenColumns(); - VisibleBlocksVisBoundsIterator regions = (VisibleBlocksVisBoundsIterator) hidden - .getVisibleBlocksIterator(startRes, endRes, true); + VisibleContigsIterator regions = hidden + .getVisContigsIterator(startRes, endRes + 1, true); while (regions.hasNext()) { @@ -854,15 +846,37 @@ public class SeqCanvas extends Panel implements ViewportListenerI { String eventName = evt.getPropertyName(); + if (eventName.equals(SequenceGroup.SEQ_GROUP_CHANGED)) + { + fastPaint = true; + repaint(); + return; + } + else if (eventName.equals(ViewportRanges.MOVE_VIEWPORT)) + { + fastPaint = false; + repaint(); + return; + } + if (!av.getWrapAlignment()) { int scrollX = 0; - if (eventName.equals(ViewportRanges.STARTRES)) + if (eventName.equals(ViewportRanges.STARTRES) + || eventName.equals(ViewportRanges.STARTRESANDSEQ)) { // Make sure we're not trying to draw a panel // larger than the visible window + if (eventName.equals(ViewportRanges.STARTRES)) + { + scrollX = (int) evt.getNewValue() - (int) evt.getOldValue(); + } + else + { + scrollX = ((int[]) evt.getNewValue())[0] + - ((int[]) evt.getOldValue())[0]; + } ViewportRanges vpRanges = av.getRanges(); - scrollX = (int) evt.getNewValue() - (int) evt.getOldValue(); int range = vpRanges.getEndRes() - vpRanges.getStartRes(); if (scrollX > range) { @@ -889,7 +903,26 @@ public class SeqCanvas extends Panel implements ViewportListenerI // scroll fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue()); } + else if (eventName.equals(ViewportRanges.STARTRESANDSEQ)) + { + fastPaint(scrollX, 0); + } } } + /** + * Ensure that a full paint is done next, for whatever reason. This was + * necessary for JavaScript; apparently in Java the timing is just right on + * multiple threads (EventQueue-0, Consensus, Conservation) that we can get + * away with one fast paint before the others, but this ensures that in the + * end we get a full paint. Problem arose in relation to copy/paste, where the + * paste was not finalized with a full paint. + * + * @author hansonr 2019.04.17 + */ + public void clearFastPaint() + { + fastPaint = false; + } + }