JAL-4367 Limit right and top adjustments
[jalview.git] / src / jalview / gui / AnnotationLabels.java
index 6b98944..7c5afcd 100755 (executable)
@@ -793,9 +793,15 @@ public class AnnotationLabels extends JPanel
     {
       Dimension d = ap.annotationScroller.getPreferredSize();
       int dif = evt.getY() - oldY;
+      dif -= dif % ap.av.getCharHeight();
 
-      dif /= ap.av.getCharHeight();
-      dif *= ap.av.getCharHeight();
+      // don't allow setting an annotation panel height larger than visible
+      // (otherwise you can't get back)
+      if (d.height - dif > ap.idPanelHolder.getHeight()
+              - ap.getIdSpaceFillerPanel1().getHeight())
+      {
+        return;
+      }
 
       if ((d.height - dif) > 20)
       {
@@ -1112,7 +1118,7 @@ public class AnnotationLabels extends JPanel
     if (av.hasHiddenColumns())
     {
       Iterator<int[]> it = av.getAlignment().getHiddenColumns()
-              .getVisContigsIterator(0, sq.getLength(), false);
+              .getVisContigsIterator(0, sq.getLength() + 1, false);
       omitHidden = new String[] { sq.getSequenceStringFromIterator(it) };
     }
 
@@ -1206,8 +1212,8 @@ public class AnnotationLabels extends JPanel
     if (ap != null)
     {
       iwa = ap.idwidthAdjuster;
-      if ((Cache.getDefault(ADJUST_ANNOTATION_LABELS_WIDTH_PREF, true)
-              || Jalview.isHeadlessMode()))
+      if (Cache.getDefault(ADJUST_ANNOTATION_LABELS_WIDTH_PREF, true)
+              || Jalview.isHeadlessMode())
       {
         Graphics2D g2d = (Graphics2D) g;
         Graphics dummy = g2d.create();