X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=b408c1ba0ce335dfcedf10ed0c5b25d043a5a59c;hb=refs%2Fheads%2Fbug%2FJAL-247autoIdWidthSeqMarker;hp=cf88c904add63efd0a7553608b7a6df45ef17031;hpb=6a18ba9e7e4bd4deee0337dfd072b959596ca4b5;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index cf88c90..b408c1b 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -85,20 +85,21 @@ public class IdCanvas extends JPanel implements ViewportListenerI * DOCUMENT ME! * * @param g - * DOCUMENT ME! + * DOCUMENT ME! * @param hiddenRows - * true - check and display hidden row marker if need be + * true - check and display hidden row marker if need be * @param s - * DOCUMENT ME! + * DOCUMENT ME! * @param i - * DOCUMENT ME! + * DOCUMENT ME! * @param starty - * DOCUMENT ME! + * DOCUMENT ME! * @param ypos - * DOCUMENT ME! + * DOCUMENT ME! + * @param idWidth */ public void drawIdString(Graphics2D g, boolean hiddenRows, SequenceI s, - int i, int starty, int ypos) + int i, int starty, int ypos, int idWidth) { int xPos = 0; int panelWidth = getWidth(); @@ -139,7 +140,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI if (hiddenRows) { - drawMarker(g, av, i, starty, ypos); + drawMarker(g, av, i, starty, ypos, idWidth); } } @@ -196,7 +197,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI gg.translate(0, transY); - drawIds(gg, av, ss, es, searchResults); + drawIds(gg, av, ss, es, searchResults, getWidth()); gg.translate(0, -transY); @@ -252,7 +253,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI gg.setColor(Color.white); gg.fillRect(0, 0, getWidth(), imgHeight); - drawIds(gg, av, av.getRanges().getStartSeq(), av.getRanges().getEndSeq(), searchResults); + drawIds(gg, av, av.getRanges().getStartSeq(), av.getRanges().getEndSeq(), searchResults, getWidth()); g.drawImage(image, 0, 0, this); } @@ -260,17 +261,18 @@ public class IdCanvas extends JPanel implements ViewportListenerI /** * 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. + * sequences included in the selection are coloured grey, otherwise the current + * id colour for the sequence id is used. * * @param g * @param alignViewport * @param startSeq * @param endSeq * @param selection + * @param idWidth */ void drawIds(Graphics2D g, AlignViewport alignViewport, final int startSeq, - final int endSeq, List selection) + final int endSeq, List selection, int idWidth) { Font font = alignViewport.getFont(); if (alignViewport.isSeqNameItalics()) @@ -299,7 +301,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI if (alignViewport.getWrapAlignment()) { - drawIdsWrapped(g, alignViewport, startSeq, getHeight()); + drawIdsWrapped(g, alignViewport, startSeq, getHeight(), getWidth()); return; } @@ -361,7 +363,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI if (hasHiddenRows) { - drawMarker(g, alignViewport, i, startSeq, 0); + drawMarker(g, alignViewport, i, startSeq, 0, idWidth); } } } @@ -373,45 +375,28 @@ public class IdCanvas extends JPanel implements ViewportListenerI * @param g * @param alignViewport * @param startSeq + * @param idWidth */ void drawIdsWrapped(Graphics2D g, AlignViewport alignViewport, - int startSeq, int pageHeight) + int startSeq, int pageHeight, int idWidth) { int alignmentWidth = alignViewport.getAlignment().getWidth(); final int alheight = alignViewport.getAlignment().getHeight(); - if (alignViewport.hasHiddenColumns()) - { - alignmentWidth = alignViewport.getAlignment().getHiddenColumns() - .absoluteToVisibleColumn(alignmentWidth) - 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 (alignViewport.isShowAnnotation()) { - if (ap == null) - { - ap = new AnnotationPanel(alignViewport); - } - 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; - ViewportRanges ranges = alignViewport.getRanges(); int rowSize = ranges.getViewportWidth(); @@ -421,7 +406,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)) { @@ -436,7 +421,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI { g.setFont(getIdfont()); } - drawIdString(g, hasHiddenRows, s, i, 0, ypos); + drawIdString(g, hasHiddenRows, s, i, 0, ypos, idWidth); } if (labels != null && alignViewport.isShowAnnotation()) @@ -446,22 +431,23 @@ public class IdCanvas extends JPanel implements ViewportListenerI g.translate(0, -ypos - (alheight * charHeight)); } - ypos += cHeight; + ypos += seqCanvas.wrappedRepeatHeightPx; rowStartRes += rowSize; } } /** - * Draws a marker (a blue right-pointing triangle) between sequences to - * indicate hidden sequences. + * Draws a marker (a blue right-pointing triangle) between sequences to indicate + * hidden sequences. * * @param g * @param alignViewport * @param seqIndex * @param starty * @param yoffset + * @param idWidth */ - void drawMarker(Graphics2D g, AlignViewport alignViewport, int seqIndex, int starty, int yoffset) + void drawMarker(Graphics2D g, AlignViewport alignViewport, int seqIndex, int starty, int yoffset, int idWidth) { SequenceI[] hseqs = alignViewport.getAlignment() .getHiddenSequences().hiddenSequences; @@ -504,9 +490,8 @@ public class IdCanvas extends JPanel implements ViewportListenerI /* * vertices of the triangle, below or above hidden seqs */ - int[] xPoints = new int[] - { getWidth() - charHeight, - getWidth() - charHeight, getWidth() }; + int[] xPoints = new int[] { idWidth - charHeight, idWidth - charHeight, + idWidth }; int yShift = seqIndex - starty; if (below)