From: gmungoc Date: Tue, 30 Jul 2019 13:52:54 +0000 (+0100) Subject: JAL-247 pass idwidth parameter to IdCanvas.drawMarker X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=1173ed15c801a5f16abcb12e05ff913628593639;p=jalview.git JAL-247 pass idwidth parameter to IdCanvas.drawMarker --- diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index ea8fcdc..87a771d 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -994,7 +994,7 @@ public class AlignmentPanel extends GAlignmentPanel implements List selection = av.getSelectionGroup() == null ? null : av.getSelectionGroup().getSequences(null); idCanvas.drawIds((Graphics2D) idGraphics, av, startSeq, endSeq - 1, - selection); + selection, idWidth); idGraphics.setFont(av.getFont()); idGraphics.translate(0, -scaleHeight); @@ -1069,7 +1069,7 @@ public class AlignmentPanel extends GAlignmentPanel implements int cHeight = av.getAlignment().getHeight() * av.getCharHeight() + hgap + annotationHeight; - int idWidth = getVisibleIdWidth(false); + final int idWidth = getVisibleIdWidth(false); int maxwidth = av.getAlignment().getVisibleWidth(); @@ -1098,7 +1098,7 @@ public class AlignmentPanel extends GAlignmentPanel implements * draw sequence ids and annotation labels (if shown) */ IdCanvas idCanvas = getIdPanel().getIdCanvas(); - idCanvas.drawIdsWrapped((Graphics2D) g, av, 0, totalHeight); + idCanvas.drawIdsWrapped((Graphics2D) g, av, 0, totalHeight, idWidth); g.translate(idWidth, 0); diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index 793c005..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,9 +375,10 @@ 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(); @@ -418,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()) @@ -434,16 +437,17 @@ public class IdCanvas extends JPanel implements ViewportListenerI } /** - * 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; @@ -486,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)