X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=14ae0336141748f86b8d17b4e8a275c87cd7f53e;hb=8d25e88f6a9d1bea9569c23e425df7b1b498fd14;hp=a9af26df1a6491e57f5520eef23b0c7998d73822;hpb=3da878124135ff033f42d19d8733891b09e953cd;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index a9af26d..14ae033 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -59,7 +59,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI int imgHeight = 0; - boolean fastPaint = false; + private boolean fastPaint = false; List searchResults; @@ -137,7 +137,8 @@ public class IdCanvas extends JPanel implements ViewportListenerI g.drawString(s.getDisplayId(av.getShowJVSuffix()), xPos, (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5)); - if (hiddenRows) + // JAL-3253-applet was just hiddenRows here. ccfc48e (gmungoc) added getShowHiddenMarkers test + if (hiddenRows && av.getShowHiddenMarkers()) { drawMarker(g, av, i, starty, ypos); } @@ -152,6 +153,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI */ public void fastPaint(int vertical) { + /* * for now, not attempting fast paint of wrapped ids... */ @@ -220,7 +222,10 @@ public class IdCanvas extends JPanel implements ViewportListenerI @Override public void paintComponent(Graphics g) { - //super.paintComponent(g); // BH 2019 + if (av.getAlignPanel().getHoldRepaint()) + { + return; + } g.setColor(Color.white); g.fillRect(0, 0, getWidth(), getHeight()); @@ -245,7 +250,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI if (oldHeight != imgHeight || image.getWidth(this) != getWidth()) { - image = new BufferedImage(getWidth(), imgHeight, + image = new BufferedImage(getWidth(), imgHeight, BufferedImage.TYPE_INT_RGB); } @@ -364,7 +369,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI g.drawString(string, xPos, (((i - startSeq) * charHeight) + charHeight) - (charHeight / 5)); - if (hasHiddenRows) + if (hasHiddenRows && av.getShowHiddenMarkers()) { drawMarker(g, alignViewport, i, startSeq, 0); } @@ -385,32 +390,49 @@ public class IdCanvas extends JPanel implements ViewportListenerI int alignmentWidth = alignViewport.getAlignment().getWidth(); final int alheight = alignViewport.getAlignment().getHeight(); - int annotationHeight = 0; + +// int annotationHeight = 0; + + /* (former) + * assumption: SeqCanvas.calculateWrappedGeometry has been called + * + * was based on the fact that SeqCanvas was added as a child prior to IdCanvas, + * and children are processed in order of addition. + * + * It's probably fine. But... + * + */ + SeqCanvas seqCanvas = alignViewport.getAlignPanel() + .getSeqPanel().seqCanvas; + // ...better: let's call it now + seqCanvas.calculateWrappedGeometry(); + + final int charHeight = alignViewport.getCharHeight(); AnnotationLabels labels = null; if (alignViewport.isShowAnnotation()) { + // BH when was ap == null? if (ap == null) { ap = new AnnotationPanel(alignViewport); } - annotationHeight = ap.adjustPanelHeight(); +// annotationHeight = ap.adjustPanelHeight(); labels = new AnnotationLabels(alignViewport); } - final int charHeight = alignViewport.getCharHeight(); - int hgap = charHeight; - if (alignViewport.getScaleAboveWrapped()) - { - hgap += charHeight; - } - - /* - * height of alignment + gap + annotations (if shown) - */ - int cHeight = alheight * charHeight + hgap - + annotationHeight; - +// int hgap = charHeight; +// if (alignViewport.getScaleAboveWrapped()) +// { +// hgap += charHeight; +// } +// +// /* +// * height of alignment + gap + annotations (if shown) +// */ +// int cHeight = alheight * charHeight + hgap +// + annotationHeight; +// ViewportRanges ranges = alignViewport.getRanges(); int rowSize = ranges.getViewportWidth(); @@ -420,7 +442,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI * out of visible space, whichever comes first */ boolean hasHiddenRows = alignViewport.hasHiddenRows(); - int ypos = hgap; + int ypos = seqCanvas.wrappedSpaceAboveAlignment; int rowStartRes = ranges.getStartRes(); while ((ypos <= pageHeight) && (rowStartRes < alignmentWidth)) { @@ -445,7 +467,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI g.translate(0, -ypos - (alheight * charHeight)); } - ypos += cHeight; + ypos += seqCanvas.wrappedRepeatHeightPx; rowStartRes += rowSize; } } @@ -581,20 +603,34 @@ public class IdCanvas extends JPanel implements ViewportListenerI public void propertyChange(PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); - if (propertyName.equals(ViewportRanges.STARTSEQ) - || (av.getWrapAlignment() - && propertyName.equals(ViewportRanges.STARTRES))) + switch (propertyName) { + case ViewportRanges.STARTSEQ: fastPaint((int) evt.getNewValue() - (int) evt.getOldValue()); - } - else if (propertyName.equals(ViewportRanges.STARTRESANDSEQ)) - { + break; + case ViewportRanges.STARTRES: + if (av.getWrapAlignment()) + { + fastPaint((int) evt.getNewValue() - (int) evt.getOldValue()); + } + break; + case ViewportRanges.STARTRESANDSEQ: fastPaint(((int[]) evt.getNewValue())[1] - ((int[]) evt.getOldValue())[1]); - } - else if (propertyName.equals(ViewportRanges.MOVE_VIEWPORT)) - { + break; + case ViewportRanges.MOVE_VIEWPORT: repaint(); + break; + default: } } + + /** + * Clears the flag that allows a 'fast paint' on the next repaint, so + * requiring a full repaint + */ + public void setNoFastPaint() + { + fastPaint = false; + } }