X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=541c253be796dadb0943a6868953858eeb6e6c72;hb=af259f508805faf2da90585ee9a67cd7853bf5aa;hp=484173cf5564e0a081dd51c40c93ab28a09d348b;hpb=b2829c5d7e7815e5e261d39964ade91ed5225510;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index 484173c..541c253 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -20,10 +20,6 @@ */ package jalview.gui; -import jalview.datamodel.SequenceI; -import jalview.viewmodel.ViewportListenerI; -import jalview.viewmodel.ViewportRanges; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; @@ -37,6 +33,10 @@ import java.util.List; import javax.swing.JPanel; +import jalview.datamodel.SequenceI; +import jalview.viewmodel.ViewportListenerI; +import jalview.viewmodel.ViewportRanges; + /** * DOCUMENT ME! * @@ -137,7 +137,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI g.drawString(s.getDisplayId(av.getShowJVSuffix()), xPos, (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5)); - if (hiddenRows) + if (hiddenRows && av.getShowHiddenMarkers()) { drawMarker(g, av, i, starty, ypos); } @@ -258,19 +258,19 @@ public class IdCanvas extends JPanel implements ViewportListenerI } /** - * Draws sequence ids from sequence index starty to endy (inclusive), with the - * font and other display settings configured on the viewport. Ids of + * Draws sequence ids from sequence index startSeq to endSeq (inclusive), with + * the font and other display settings configured on the viewport. Ids of * sequences included in the selection are coloured grey, otherwise the * current id colour for the sequence id is used. * * @param g * @param alignViewport - * @param starty - * @param endy + * @param startSeq + * @param endSeq * @param selection */ - void drawIds(Graphics2D g, AlignViewport alignViewport, final int starty, - final int endy, List selection) + void drawIds(Graphics2D g, AlignViewport alignViewport, final int startSeq, + final int endSeq, List selection) { Font font = alignViewport.getFont(); if (alignViewport.isSeqNameItalics()) @@ -295,11 +295,11 @@ public class IdCanvas extends JPanel implements ViewportListenerI Color currentColor = Color.white; Color currentTextColor = Color.black; - boolean hasHiddenRows = av.hasHiddenRows(); + boolean hasHiddenRows = alignViewport.hasHiddenRows(); if (alignViewport.getWrapAlignment()) { - drawIdsWrapped(starty, hasHiddenRows); + drawIdsWrapped(g, alignViewport, startSeq, getHeight()); return; } @@ -308,7 +308,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI int xPos = 0; // Now draw the id strings - for (int i = starty; i <= endy; i++) + for (int i = startSeq; i <= endSeq; i++) { SequenceI sequence = alignViewport.getAlignment().getSequenceAt(i); @@ -320,6 +320,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI if (hasHiddenRows || alignViewport.isDisplayReferenceSeq()) { g.setFont(getHiddenFont(sequence, alignViewport)); + fm = g.getFontMetrics(); } // Selected sequence colours @@ -328,8 +329,8 @@ public class IdCanvas extends JPanel implements ViewportListenerI currentColor = Color.black; currentTextColor = Color.white; } - else if ((av.getSelectionGroup() != null) && av.getSelectionGroup() - .getSequences(null).contains(sequence)) + else if ((alignViewport.getSelectionGroup() != null) && alignViewport + .getSelectionGroup().getSequences(null).contains(sequence)) { currentColor = Color.lightGray; currentTextColor = Color.black; @@ -343,7 +344,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI g.setColor(currentColor); int charHeight = alignViewport.getCharHeight(); - g.fillRect(0, (i - starty) * charHeight, + g.fillRect(0, (i - startSeq) * charHeight, getWidth(), charHeight); g.setColor(currentTextColor); @@ -356,56 +357,45 @@ public class IdCanvas extends JPanel implements ViewportListenerI xPos = panelWidth - fm.stringWidth(string) - 4; } - g.drawString(string, xPos, (((i - starty) * charHeight) + charHeight) + g.drawString(string, xPos, (((i - startSeq) * charHeight) + charHeight) - (charHeight / 5)); - if (hasHiddenRows) + if (hasHiddenRows && av.getShowHiddenMarkers()) { - drawMarker(g, alignViewport, i, starty, 0); + drawMarker(g, alignViewport, i, startSeq, 0); } } } /** - * Draws sequence ids in wrapped mode + * Draws sequence ids, and annotation labels if annotations are shown, in + * wrapped mode * - * @param starty - * @param hasHiddenRows + * @param g + * @param alignViewport + * @param startSeq */ - protected void drawIdsWrapped(int starty, boolean hasHiddenRows) + void drawIdsWrapped(Graphics2D g, AlignViewport alignViewport, + int startSeq, int pageHeight) { - int maxwidth = av.getAlignment().getWidth(); - int alheight = av.getAlignment().getHeight(); + int alignmentWidth = alignViewport.getAlignment().getWidth(); + final int alheight = alignViewport.getAlignment().getHeight(); - if (av.hasHiddenColumns()) - { - maxwidth = av.getAlignment().getHiddenColumns() - .absoluteToVisibleColumn(maxwidth) - 1; - } + /* + * assumption: SeqCanvas.calculateWrappedGeometry has been called + */ + SeqCanvas seqCanvas = alignViewport.getAlignPanel() + .getSeqPanel().seqCanvas; - int annotationHeight = 0; + final int charHeight = alignViewport.getCharHeight(); AnnotationLabels labels = null; - if (av.isShowAnnotation()) - { - if (ap == null) - { - ap = new AnnotationPanel(av); - } - - annotationHeight = ap.adjustPanelHeight(); - labels = new AnnotationLabels(av); - } - - int hgap = av.getCharHeight(); - if (av.getScaleAboveWrapped()) + if (alignViewport.isShowAnnotation()) { - hgap += av.getCharHeight(); + labels = new AnnotationLabels(alignViewport); } - int cHeight = alheight * av.getCharHeight() + hgap + annotationHeight; - - ViewportRanges ranges = av.getRanges(); + ViewportRanges ranges = alignViewport.getRanges(); int rowSize = ranges.getViewportWidth(); @@ -413,34 +403,34 @@ public class IdCanvas extends JPanel implements ViewportListenerI * draw repeating sequence ids until out of sequence data or * out of visible space, whichever comes first */ - int ypos = hgap; - int row = ranges.getStartRes(); - while ((ypos <= getHeight()) && (row < maxwidth)) + boolean hasHiddenRows = alignViewport.hasHiddenRows(); + int ypos = seqCanvas.wrappedSpaceAboveAlignment; + int rowStartRes = ranges.getStartRes(); + while ((ypos <= pageHeight) && (rowStartRes < alignmentWidth)) { - for (int i = starty; i < alheight; i++) + for (int i = startSeq; i < alheight; i++) { - SequenceI s = av.getAlignment().getSequenceAt(i); - if (hasHiddenRows || av.isDisplayReferenceSeq()) + SequenceI s = alignViewport.getAlignment().getSequenceAt(i); + if (hasHiddenRows || alignViewport.isDisplayReferenceSeq()) { - gg.setFont(getHiddenFont(s, av)); + g.setFont(getHiddenFont(s, alignViewport)); } else { - gg.setFont(getIdfont()); + g.setFont(getIdfont()); } - - drawIdString(gg, hasHiddenRows, s, i, 0, ypos); + drawIdString(g, hasHiddenRows, s, i, 0, ypos); } - if (labels != null && av.isShowAnnotation()) + if (labels != null && alignViewport.isShowAnnotation()) { - gg.translate(0, ypos + (alheight * av.getCharHeight())); - labels.drawComponent(gg, getWidth()); - gg.translate(0, -ypos - (alheight * av.getCharHeight())); + g.translate(0, ypos + (alheight * charHeight)); + labels.drawComponent(g, getWidth()); + g.translate(0, -ypos - (alheight * charHeight)); } - ypos += cHeight; - row += rowSize; + ypos += seqCanvas.wrappedRepeatHeightPx; + rowStartRes += rowSize; } }