X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationLabels.java;h=94f8790d2235cfafc1c9723c7163f9a248b4eb55;hb=1f346fcfa0e00be0adaa82b394e6ce8b7b9e416b;hp=a3f7e0001b728b1644bd50213e940814411a120c;hpb=56b3e093761bc8b409ffc66fae03d5be40edea89;p=jalview.git diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index a3f7e00..94f8790 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -1112,7 +1112,7 @@ public class AnnotationLabels extends JPanel if (av.hasHiddenColumns()) { Iterator it = av.getAlignment().getHiddenColumns() - .getVisContigsIterator(0, sq.getLength(), false); + .getVisContigsIterator(0, sq.getLength() + 1, false); omitHidden = new String[] { sq.getSequenceStringFromIterator(it) }; } @@ -1198,7 +1198,8 @@ public class AnnotationLabels extends JPanel * @param width * Width for scaling labels */ - public void drawComponent(Graphics g, boolean clip, int givenWidth, boolean forGUI) + public void drawComponent(Graphics g, boolean clip, int givenWidth, + boolean forGUI) { int width = givenWidth; IdwidthAdjuster iwa = null; @@ -1210,8 +1211,8 @@ public class AnnotationLabels extends JPanel { Graphics2D g2d = (Graphics2D) g; Graphics dummy = g2d.create(); - int newAnnotationIdWidth = drawLabels(dummy, clip, width, false, forGUI, - null, false); + int newAnnotationIdWidth = drawLabels(dummy, clip, width, false, + forGUI, null, false); dummy.dispose(); Dimension d = ap.calculateDefaultAlignmentIdWidth(); int alignmentIdWidth = d.width; @@ -1245,8 +1246,10 @@ public class AnnotationLabels extends JPanel } else { - int newAnnotationIdWidth = drawLabels(g, clip, width, false, forGUI, null, false); - width = Math.max(newAnnotationIdWidth, givenWidth); + int newAnnotationIdWidth = drawLabels(g, clip, width, false, forGUI, + null, false); + width = newAnnotationIdWidth < givenWidth ? givenWidth + : Math.min(newAnnotationIdWidth, givenWidth); } drawLabels(g, clip, width, true, forGUI, null, false); } @@ -1258,21 +1261,28 @@ public class AnnotationLabels extends JPanel * fmetrics must be supplied. * * @param g - * Graphics2D instance (used for rendering and font scaling if no fmetrics supplied) + * Graphics2D instance (used for rendering and font scaling if no + * fmetrics supplied) * @param clip * - true indicates that only current visible area needs to be * rendered * @param width * Width for scaling labels - * @param actuallyDraw - when false, no graphics are rendered to g0 - * @param forGUI - when false, GUI relevant marks like indicators for dragging annotation panel height are not rendered + * @param actuallyDraw + * - when false, no graphics are rendered to g0 + * @param forGUI + * - when false, GUI relevant marks like indicators for dragging + * annotation panel height are not rendered * @param fmetrics * FontMetrics if Graphics object g is null - * @param includeHidden - when true returned width includes labels in hidden row width calculation + * @param includeHidden + * - when true returned width includes labels in hidden row width + * calculation * @return the width of the annotation labels. */ public int drawLabels(Graphics g0, boolean clip, int width, - boolean actuallyDraw, boolean forGUI, FontMetrics fmetrics, boolean includeHidden) + boolean actuallyDraw, boolean forGUI, FontMetrics fmetrics, + boolean includeHidden) { if (clip) { @@ -1554,7 +1564,8 @@ public class AnnotationLabels extends JPanel } } - if (!resizePanel && dragEvent != null && aa != null) + if (!resizePanel && dragEvent != null && aa != null && selectedRow > -1 + && selectedRow < aa.length) { if (actuallyDraw && g != null) {